[pypy-svn] r59859 - pypy/build/benchmem/testing

hpk at codespeak.net hpk at codespeak.net
Tue Nov 11 08:05:40 CET 2008


Author: hpk
Date: Tue Nov 11 08:05:38 2008
New Revision: 59859

Modified:
   pypy/build/benchmem/testing/test_benchtool.py
Log:
invoke scripts more programmatically from tests
XXX one too broad functional test


Modified: pypy/build/benchmem/testing/test_benchtool.py
==============================================================================
--- pypy/build/benchmem/testing/test_benchtool.py	(original)
+++ pypy/build/benchmem/testing/test_benchtool.py	Tue Nov 11 08:05:38 2008
@@ -8,7 +8,15 @@
 def setup_module(mod):
     if sys.platform.find("linux") == -1:
         py.test.skip("linux required")
-       
+
+def runscript(opts, script="runbench.py"):
+    script = py.path.local(runbench.__file__).dirpath(script)
+    cmd = "python %s %s" % (script, opts)
+    return py.process.cmdexec(cmd)
+
+def runreport(opts):
+    return runscript(opts, script="report.py")
+
 def test_smapsrecorder():
     tmpdir = py.test.ensuretemp("smapsrecorder")
     logpath = tmpdir.join("benchlog")
@@ -94,36 +102,30 @@
         assert len(results) == 1
         assert len(results[0].lst)
 
-def test_runbench_functional():
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
-    output = py.process.cmdexec("python %s --numiter=10" %(script))
+def XXXtest_runbench_functional():
+    output = runscript("--numiter=10")
 
 def test_report_objsizes_functional():
     tmpdir = py.test.ensuretemp("test_report_functional")
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
-    py.process.cmdexec("%s --benchlog=%s --numiter=10 objsizes" %(script, benchlog))
-    report = script.dirpath("report.py")
+    runscript("--benchlog=%s --numiter=10 objsizes" %(benchlog))
     old = tmpdir.chdir()
     try:
-        py.process.cmdexec("%s --benchlog %s" %(report, benchlog,))
+        runreport("--benchlog %s" %(benchlog,))
     finally:
         old.chdir()
 
 
 def test_report_appprofiles_functional():
     tmpdir = py.test.ensuretemp("test_appp_functional")
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
-    py.process.cmdexec("%s --benchlog=%s --numiter=10 appprofiles" %(script, benchlog))
-    report = script.dirpath("report.py")
+    runscript("--benchlog=%s --numiter=10 appprofiles" %(benchlog))
     old = tmpdir.chdir()
     try:
-        py.process.cmdexec("%s --benchlog %s" %(report, benchlog,))
+        runreport("--benchlog %s" %(benchlog,))
     finally:
         old.chdir()
 
-
 def test_log_mapping():
     s = py.std.textwrap.dedent("""\
         402c2000-402c4000 rw-p 402c2000 00:00 0 
@@ -270,25 +272,21 @@
 
 def test_basesize_reporting():
     tmpdir = py.test.ensuretemp("test_basesize_reporting")
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
     print "Runner"
-    py.process.cmdexec("%s --benchlog=%s basesize" % (script, benchlog))
-    report = script.dirpath("report.py")
+    runscript("--benchlog=%s basesize" % (benchlog))
     old = tmpdir.chdir()
     try:
         print "Reporter"
-        out = py.process.cmdexec("%s --benchlog %s" %(report, benchlog,))
+        out = runreport("--benchlog %s" %(benchlog,))
         assert out.lower().find("basesize") != -1
     finally:
         old.chdir()
 
 def test_basesize_multiple_binaries_half_functional():
     tmpdir = py.test.ensuretemp("test_basesize_hf")
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
-    py.process.cmdexec("%s -e python2.5,python2.5 --benchlog=%s basesize" % (script, benchlog))
-
+    runscript("-e python2.5,python2.5 --benchlog=%s basesize" % (benchlog))
     resultset = runbench.ResultSet()
     resultset.parse(benchlog)
 
@@ -304,7 +302,7 @@
     tmpdir = py.test.ensuretemp("test_basetime_half_functional")
     script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
-    print py.process.cmdexec("%s -e python2.5,python2.5 --benchlog=%s basetime" % (script, benchlog))
+    print runscript("-e python2.5,python2.5 --benchlog=%s basetime" % (benchlog))
 
     resultset = runbench.ResultSet()
     resultset.parse(benchlog)
@@ -324,15 +322,12 @@
 
 def test_basetime_functional():
     tmpdir = py.test.ensuretemp("test_basetime_functional")
-    script = py.path.local(runbench.__file__).dirpath("runbench.py")
     benchlog = tmpdir.join("benchlog")
-    py.process.cmdexec("%s -e python2.5,python2.5 --benchlog=%s basetime" % (script, benchlog))
-
-    report = script.dirpath("report.py")
+    runscript("-e python2.5,python2.5 --benchlog=%s basetime" % (benchlog))
     old = tmpdir.chdir()
     try:
         print "Reporter"
-        out = py.process.cmdexec("%s --benchlog %s" %(report, benchlog,))
+        out = runreport("--benchlog %s" %(benchlog,))
         assert out.lower().find("basetime") != -1
     finally:
         old.chdir()



More information about the Pypy-commit mailing list