diff options
Diffstat (limited to 'test/scons-time')
-rw-r--r-- | test/scons-time/func/file.py | 27 | ||||
-rw-r--r-- | test/scons-time/mem/file.py | 9 | ||||
-rw-r--r-- | test/scons-time/obj/file.py | 9 | ||||
-rw-r--r-- | test/scons-time/run/aegis.py | 17 | ||||
-rw-r--r-- | test/scons-time/run/config/archive_list.py | 6 | ||||
-rw-r--r-- | test/scons-time/run/option/quiet.py | 21 | ||||
-rw-r--r-- | test/scons-time/run/option/verbose.py | 21 | ||||
-rw-r--r-- | test/scons-time/run/subversion.py | 17 | ||||
-rw-r--r-- | test/scons-time/time/empty.py | 91 | ||||
-rw-r--r-- | test/scons-time/time/file.py | 9 | ||||
-rw-r--r-- | test/scons-time/time/no-result.py | 75 |
11 files changed, 227 insertions, 75 deletions
diff --git a/test/scons-time/func/file.py b/test/scons-time/func/file.py index c9486c4..079c125 100644 --- a/test/scons-time/func/file.py +++ b/test/scons-time/func/file.py @@ -31,7 +31,7 @@ affect how the func subcommand processes things. import TestSCons_time -test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) +test = TestSCons_time.TestSCons_time() try: import pstats @@ -56,22 +56,43 @@ prefix = 'foo-001' expect1 = r'\d.\d\d\d prof1\.py:1\(_main\)' + '\n' -test.run(arguments = 'func -f st1.conf', stdout = expect1) +test.run(arguments = 'func -f st1.conf', + match = TestSCons_time.match_re, + stdout = expect1) test.write('st2.conf', """\ prefix = 'foo' title = 'ST2.CONF TITLE' +vertical_bars = ( + ( 1.4, 7, None ), + ( 1.5, 7, "label 1.5" ), + ( 1.6, 7, "label 1.6" ), +) """) expect2 = \ r"""set title "ST2.CONF TITLE" set key bottom left -plot '-' title "Startup" with lines lt 1 +set label 3 "label 1.5" at 0.5,1.5 right +set label 4 "label 1.6" at 0.6,1.5 right +plot '-' title "Startup" with lines lt 1, \ + '-' notitle with lines lt 7, \ + '-' title "label 1.5" with lines lt 7, \ + '-' title "label 1.6" with lines lt 7 # Startup 1 0.000 2 0.000 e +1.4 0 +1.4 1 +e +1.5 0 +1.5 1 +e +1.6 0 +1.6 1 +e """ test.run(arguments = 'func --file st2.conf --fmt gnuplot', stdout = expect2) diff --git a/test/scons-time/mem/file.py b/test/scons-time/mem/file.py index a236df7..a1e7181 100644 --- a/test/scons-time/mem/file.py +++ b/test/scons-time/mem/file.py @@ -53,16 +53,23 @@ test.run(arguments = 'mem -f st1.conf', stdout = expect1) test.write('st2.conf', """\ prefix = 'foo' title = 'ST2.CONF TITLE' +vertical_bars = ( + ( 1.5, 7, None ), +) """) expect2 = \ r"""set title "ST2.CONF TITLE" set key bottom left -plot '-' title "Startup" with lines lt 1 +plot '-' title "Startup" with lines lt 1, \ + '-' notitle with lines lt 7 # Startup 1 4000.000 2 4000.000 e +1.5 0 +1.5 4800 +e """ test.run(arguments = 'mem --file st2.conf --fmt gnuplot', stdout = expect2) diff --git a/test/scons-time/obj/file.py b/test/scons-time/obj/file.py index c881397..3cf8e74 100644 --- a/test/scons-time/obj/file.py +++ b/test/scons-time/obj/file.py @@ -53,16 +53,23 @@ test.run(arguments = 'obj -f st1.conf Node.FS.Base', stdout = expect1) test.write('st2.conf', """\ prefix = 'foo' title = 'ST2.CONF TITLE' +vertical_bars = ( + ( 1.5, 7, None ), +) """) expect2 = \ r"""set title "ST2.CONF TITLE" set key bottom left -plot '-' title "Startup" with lines lt 1 +plot '-' title "Startup" with lines lt 1, \ + '-' notitle with lines lt 7 # Startup 1 16040.000 2 16040.000 e +1.5 0 +1.5 18000 +e """ test.run(arguments = 'obj --file st2.conf --fmt gnuplot Node.FS.Base', stdout = expect2) diff --git a/test/scons-time/run/aegis.py b/test/scons-time/run/aegis.py index 8f378cb..641f129 100644 --- a/test/scons-time/run/aegis.py +++ b/test/scons-time/run/aegis.py @@ -59,22 +59,9 @@ test.must_exist('foo-329-0.log', 'foo-329-2.log', 'foo-329-2.prof') -def tempdir_re(*args): - import os - import os.path - import string - import tempfile - - sep = re.escape(os.sep) - args = (tempfile.gettempdir(), 'scons-time-aegis-',) + args - x = apply(os.path.join, args) - x = re.escape(x) - x = string.replace(x, 'aegis\\-', 'aegis\\-[^%s]*' % sep) - return x - expect = [ - tempdir_re('src', 'script', 'scons.py'), - 'SCONS_LIB_DIR = %s' % tempdir_re('src', 'engine'), + test.tempdir_re('src', 'script', 'scons.py'), + 'SCONS_LIB_DIR = %s' % test.tempdir_re('src', 'engine'), ] content = test.read(test.workpath('foo-321-2.log')) diff --git a/test/scons-time/run/config/archive_list.py b/test/scons-time/run/config/archive_list.py index 8d48d26..8ddde3d 100644 --- a/test/scons-time/run/config/archive_list.py +++ b/test/scons-time/run/config/archive_list.py @@ -38,9 +38,11 @@ test.write_fake_scons_py() test.write_sample_project('foo.tar.gz') test.write('config', """\ -archive_list = ['foo.tar.gz'] +archive_list = ['foo.tar.gz', 'foo-file'] """) +test.write('foo-file', "foo-file\n") + test.run(arguments = 'run -f config') test.must_exist('foo-000-0.log', @@ -50,6 +52,8 @@ test.must_exist('foo-000-0.log', 'foo-000-2.log', 'foo-000-2.prof') +test.must_exist('foo-file') + test.write_sample_project('bar.tar.gz') diff --git a/test/scons-time/run/option/quiet.py b/test/scons-time/run/option/quiet.py index f5a3d8c..453829c 100644 --- a/test/scons-time/run/option/quiet.py +++ b/test/scons-time/run/option/quiet.py @@ -37,28 +37,11 @@ python = TestSCons_time.python test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) test.diff_function = TestSCons_time.diff_re - -def tempdir_re(*args): - import os,sys - import os.path - import string - import tempfile - - sep = re.escape(os.sep) - args = (tempfile.gettempdir(), 'scons-time-',) + args - x = apply(os.path.join, args) - x = re.escape(x) - x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep) - if sys.platform=='darwin': - # OSX has /tmp in /private/tmp. - x = '(/private)?' + x - return x - scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) src_engine = re.escape(test.workpath('src', 'engine')) -tmp_scons_time = tempdir_re() -tmp_scons_time_foo = tempdir_re('foo') +tmp_scons_time = test.tempdir_re() +tmp_scons_time_foo = test.tempdir_re('foo') test.write_fake_scons_py() diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index fb95dab..935e2a9 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.py @@ -38,28 +38,11 @@ _python_ = re.escape(TestSCons_time._python_) test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) test.diff_function = TestSCons_time.diff_re - -def tempdir_re(*args): - import os,sys - import os.path - import string - import tempfile - - sep = re.escape(os.sep) - args = (tempfile.gettempdir(), 'scons-time-',) + args - x = apply(os.path.join, args) - x = re.escape(x) - x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep) - if sys.platform=='darwin': - # OSX has /tmp in /private/tmp. - x = '(/private)?' + x - return x - scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) src_engine = re.escape(test.workpath('src', 'engine')) -tmp_scons_time = tempdir_re() -tmp_scons_time_foo = tempdir_re('foo') +tmp_scons_time = test.tempdir_re() +tmp_scons_time_foo = test.tempdir_re('foo') test.write_fake_scons_py() diff --git a/test/scons-time/run/subversion.py b/test/scons-time/run/subversion.py index 3839999..757f6df 100644 --- a/test/scons-time/run/subversion.py +++ b/test/scons-time/run/subversion.py @@ -60,22 +60,9 @@ test.must_exist('foo-716-0.log', 'foo-716-2.log', 'foo-716-2.prof') -def tempdir_re(*args): - import os - import os.path - import string - import tempfile - - sep = re.escape(os.sep) - args = (tempfile.gettempdir(), 'scons-time-svn-',) + args - x = apply(os.path.join, args) - x = re.escape(x) - x = string.replace(x, 'svn\\-', 'svn\\-[^%s]*' % sep) - return x - expect = [ - tempdir_re('src', 'script', 'scons.py'), - 'SCONS_LIB_DIR = %s' % tempdir_re('src', 'engine'), + test.tempdir_re('src', 'script', 'scons.py'), + 'SCONS_LIB_DIR = %s' % test.tempdir_re('src', 'engine'), ] content = test.read(test.workpath('foo-617-2.log'), mode='r') diff --git a/test/scons-time/time/empty.py b/test/scons-time/time/empty.py new file mode 100644 index 0000000..7542bfc --- /dev/null +++ b/test/scons-time/time/empty.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the time subcommand doesn't fail and prints an appropriate +error message if a log file is empty. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + + +header = ' Total SConscripts SCons commands\n' + +lines = [] + +line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' +empty_fmt = ' %s\n' + +for i in xrange(9): + logfile_name = 'foo-%s-0.log' % i + if i == 5: + test.write(test.workpath(logfile_name), "") + lines.append(empty_fmt % logfile_name) + else: + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = [header] + lines + +test.run(arguments = 'time foo-*.log', + stdout = ''.join(expect), + stderr = "file 'foo-5-0.log' has no contents!\n") + +expect = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1 +# Startup +0 11.123456 +1 11.123456 +2 11.123456 +3 11.123456 +4 11.123456 +6 11.123456 +7 11.123456 +8 11.123456 +e +""" + +stderr = "file 'foo-5-0.log' has no contents!\n" + +test.run(arguments = 'time --fmt gnuplot --which total foo-*.log', + stdout = expect, + stderr = stderr) + +expect = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1 +# Startup +e +""" + +test.run(arguments = 'time --fmt gnuplot foo-5-0.log', + stdout = expect, + stderr = stderr) + +test.pass_test() diff --git a/test/scons-time/time/file.py b/test/scons-time/time/file.py index f4046c9..96bd035 100644 --- a/test/scons-time/time/file.py +++ b/test/scons-time/time/file.py @@ -53,16 +53,23 @@ test.run(arguments = 'time -f st1.conf', stdout = expect1) test.write('st2.conf', """\ prefix = 'foo' title = 'ST2.CONF TITLE' +vertical_bars = ( + ( 1.5, 7, None ), +) """) expect2 = \ r"""set title "ST2.CONF TITLE" set key bottom left -plot '-' title "Startup" with lines lt 1 +plot '-' title "Startup" with lines lt 1, \ + '-' notitle with lines lt 7 # Startup 1 11.123456 2 11.123456 e +1.5 0 +1.5 12 +e """ test.run(arguments = 'time --file st2.conf --fmt gnuplot', stdout = expect2) diff --git a/test/scons-time/time/no-result.py b/test/scons-time/time/no-result.py new file mode 100644 index 0000000..ca345b2 --- /dev/null +++ b/test/scons-time/time/no-result.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that the time subcommand's --which option doesn't fail, and prints +an appropriate error message, if a log file doesn't have its specific +requested results. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + + +header = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1 +# Startup +""" + +footer = """\ +e +""" + +line_fmt = "%s 11.123456\n" + +lines = [] + +for i in xrange(9): + logfile_name = 'foo-%s-0.log' % i + if i == 5: + test.write(test.workpath(logfile_name), "NO RESULTS HERE!\n") + else: + test.fake_logfile(logfile_name) + lines.append(line_fmt % i) + +expect = [header] + lines + [footer] + +stderr = "file 'foo-5-0.log' has no results!\n" + + +test.run(arguments = 'time --fmt gnuplot --which total foo*.log', + stdout = ''.join(expect), + stderr = stderr) + +expect = [header] + [footer] + +test.run(arguments = 'time --fmt gnuplot foo-5-0.log', + stdout = ''.join(expect), + stderr = stderr) + +test.pass_test() |