diff options
| author | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
|---|---|---|
| committer | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
| commit | 0941093e0e5a030faa49968457638a3a6aee7ad8 (patch) | |
| tree | 6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/scons-time | |
| download | SCons-2.4.0.zip SCons-2.4.0.tar.gz SCons-2.4.0.tar.bz2 | |
release 2.4.02.4.0
Diffstat (limited to 'test/scons-time')
70 files changed, 4824 insertions, 0 deletions
diff --git a/test/scons-time/func/basic.py b/test/scons-time/func/basic.py new file mode 100644 index 0000000..fe24f99 --- /dev/null +++ b/test/scons-time/func/basic.py @@ -0,0 +1,55 @@ +#!/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 basic operation of the "func" subcommand. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +test.profile_data('foo.prof', 'prof.py', '_main', """\ +def _main(): + pass +""") + +expect = r'\d.\d\d\d prof\.py:1\(_main\)' + '\n' + +test.run(arguments = 'func foo.prof', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/chdir.py b/test/scons-time/func/chdir.py new file mode 100644 index 0000000..1aea7ad --- /dev/null +++ b/test/scons-time/func/chdir.py @@ -0,0 +1,70 @@ +#!/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 func -C and --chdir options change directory before +globbing for files. +""" + +import re + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +test.subdir('profs') + +input = """\ +def _main(): + pass +""" + +expect = [] +for i in range(9): + i = str(i) + test.subdir(i) + test.profile_data('profs/foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) + s = r'\d.\d\d\d %s/prof\.py:1\(_main\)' % re.escape(test.workpath(i)) + expect.append(s + '\n') + +expect = ''.join(expect) + +test.run(arguments = 'func -C profs foo-*.prof', stdout = expect) + +test.run(arguments = 'func --chdir profs foo-?.prof', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/file.py b/test/scons-time/func/file.py new file mode 100644 index 0000000..8e12123 --- /dev/null +++ b/test/scons-time/func/file.py @@ -0,0 +1,108 @@ +#!/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 config files specified with the -f and --file options +affect how the func subcommand processes things. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +test.profile_data('foo-001-0.prof', 'prof1.py', '_main', """\ +def _main(): + pass +""") + +test.profile_data('foo-002-0.prof', 'prof2.py', '_main', """\ +# line 1 (intentional comment to adjust starting line numbers) +def _main(): + pass +""") + + +test.write('st1.conf', """\ +prefix = 'foo-001' +""") + +expect1 = r'\d.\d\d\d prof1\.py:1\(_main\)' + '\n' + +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 +set label 3 "label 1.5" at 0.5,0.5 right +set label 4 "label 1.6" at 0.6,0.4 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.\d* +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') + +test.must_contain_exactly_lines(test.stdout(), expect2, find=TestSCons_time.search_re_in_list) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/format-gnuplot.py b/test/scons-time/func/format-gnuplot.py new file mode 100644 index 0000000..2231936 --- /dev/null +++ b/test/scons-time/func/format-gnuplot.py @@ -0,0 +1,88 @@ +#!/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 the func --format=gnuplot option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re, + diff = TestSCons_time.diff_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +content = """\ +def _main(): + pass +""" + +test.profile_data('foo-000-0.prof', 'prof.py', '_main', content) +test.profile_data('foo-000-1.prof', 'prof.py', '_main', content) +test.profile_data('foo-000-2.prof', 'prof.py', '_main', content) + +test.profile_data('foo-001-0.prof', 'prof.py', '_main', content) +test.profile_data('foo-001-1.prof', 'prof.py', '_main', content) +test.profile_data('foo-001-2.prof', 'prof.py', '_main', content) + +expect_notitle = r"""set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 \d.\d\d\d +1 \d.\d\d\d +e +# Full build +0 \d.\d\d\d +1 \d.\d\d\d +e +# Up-to-date build +0 \d.\d\d\d +1 \d.\d\d\d +e +""" + +expect_title = 'set title "TITLE"\n' + expect_notitle + +test.run(arguments = 'func --fmt gnuplot', stdout=expect_notitle) + +test.run(arguments = 'func --fmt=gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'func --format gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'func --format=gnuplot', stdout=expect_notitle) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/funcglob.py b/test/scons-time/func/funcglob.py new file mode 100644 index 0000000..6240404 --- /dev/null +++ b/test/scons-time/func/funcglob.py @@ -0,0 +1,63 @@ +#!/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 func subcommands globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +input = """\ +def _main(): + pass +""" + +expect = [] +for i in range(9): + test.subdir(str(i)) + test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) + expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) + +expect = ''.join(expect) + +test.run(arguments = 'func foo-*.prof', stdout = expect) + +test.run(arguments = 'func foo-?.prof', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/function.py b/test/scons-time/func/function.py new file mode 100644 index 0000000..c76bb2f --- /dev/null +++ b/test/scons-time/func/function.py @@ -0,0 +1,64 @@ +#!/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 use of the --func and --function options to select functions +other than the default _main(). +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +test.profile_data('foo.prof', 'prof.py', '_main', """\ +def f1(): + pass +def f3(): + pass +def _main(): + f1() + f3() +""") + +expect1 = r'\d.\d\d\d prof\.py:1\(f1\)' + '\n' +expect3 = r'\d.\d\d\d prof\.py:3\(f3\)' + '\n' + +test.run(arguments = 'func --func f1 foo.prof', stdout = expect1) + +test.run(arguments = 'func --function f3 foo.prof', stdout = expect3) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/help.py b/test/scons-time/func/help.py new file mode 100644 index 0000000..61a1a6d --- /dev/null +++ b/test/scons-time/func/help.py @@ -0,0 +1,63 @@ +#!/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 the func subcommand help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + "Usage: scons-time func [OPTIONS] FILE [...]\n", + " -C DIR, --chdir=DIR Change to DIR before looking for files\n", + " -h, --help Print this help and exit\n", +] + +test.run(arguments = 'func -h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'func -?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'func --help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'help func') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/no-args.py b/test/scons-time/func/no-args.py new file mode 100644 index 0000000..4e2df8d --- /dev/null +++ b/test/scons-time/func/no-args.py @@ -0,0 +1,49 @@ +#!/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 the error from the func subcommand when no arguments are specified. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: func: No arguments specified. + No *.prof files found in "%s". + Type "scons-time help func" for help. +""" % test.workpath() + +test.run(arguments = 'func', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/prefix.py b/test/scons-time/func/prefix.py new file mode 100644 index 0000000..67a0c6b --- /dev/null +++ b/test/scons-time/func/prefix.py @@ -0,0 +1,71 @@ +#!/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 func -p and --prefix options specify what log files to use. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +input = """\ +def _main(): + pass +""" + +foo_lines = [] +bar_lines = [] + +for i in range(2): + test.profile_data('foo-%s.prof' % i, 'prof.py', '_main', input) + foo_lines.append(r'\d.\d\d\d prof\.py:1\(_main\)' + '\n') + +for i in range(4): + test.profile_data('bar-%s.prof' % i, 'prof.py', '_main', input) + bar_lines.append(r'\d.\d\d\d prof\.py:1\(_main\)' + '\n') + +foo_expect = ''.join(foo_lines) +bar_expect = ''.join(bar_lines) + +test.run(arguments = 'func -p bar', stdout = bar_expect) + +test.run(arguments = 'func --prefix=foo', stdout = foo_expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/func/tail.py b/test/scons-time/func/tail.py new file mode 100644 index 0000000..afd3f83 --- /dev/null +++ b/test/scons-time/func/tail.py @@ -0,0 +1,62 @@ +#!/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 func subcommand only prints results for the last number +of files specified with the -t and --tail options. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +try: + import pstats +except ImportError: + test.skip_test('No pstats module, skipping test.\n') + +input = """\ +def _main(): + pass +""" + +expect = [] +for i in range(9): + test.subdir(str(i)) + test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) + expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) + +test.run(arguments = 'func -t 3 foo-*.prof', stdout = ''.join(expect[-3:])) + +test.run(arguments = 'func --tail 5 foo-*.prof', stdout = ''.join(expect[-5:])) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/help/all-subcommands.py b/test/scons-time/help/all-subcommands.py new file mode 100644 index 0000000..03ddc46 --- /dev/null +++ b/test/scons-time/help/all-subcommands.py @@ -0,0 +1,63 @@ +#!/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 all subcommands show up in the global help. + +This makes sure that each do_*() function attached to the SConsTimer +class has a line in the help string. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +# Compile the scons-time script as a module. +c = compile(test.read(test.program, mode='r'), test.program, 'exec') + +# Evaluate the module in a global name space so we can get at SConsTimer. +globals = {} +try: eval(c, globals) +except: pass + +# Extract all subcommands from the the do_*() functions. +functions = list(globals['SConsTimer'].__dict__.keys()) +do_funcs = [x for x in functions if x[:3] == 'do_'] + +subcommands = [x[3:] for x in do_funcs] + +expect = [' %s ' % x for x in subcommands] + +test.run(arguments = 'help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/help/options.py b/test/scons-time/help/options.py new file mode 100644 index 0000000..8fd192d --- /dev/null +++ b/test/scons-time/help/options.py @@ -0,0 +1,65 @@ +#!/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 'help' subcommand and -h, -? and --help options print +the default help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + 'Usage: scons-time SUBCOMMAND [ARGUMENTS]\n', + 'Type "scons-time help SUBCOMMAND" for help on a specific subcommand.\n', + 'Available subcommands:\n', + ' help Provides help\n', +] + +test.run(arguments = 'help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = '-h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = '-?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = '--help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/chdir.py b/test/scons-time/mem/chdir.py new file mode 100644 index 0000000..5bf618c --- /dev/null +++ b/test/scons-time/mem/chdir.py @@ -0,0 +1,63 @@ +#!/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 mem -C and --chdir options change directory before +globbing for files. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 1000 2000 3000 4000 %s\n' + +for i in range(9): + logfile_name = os.path.join('logs', 'foo-%s.log' % i) + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'mem -C logs foo-*.log', stdout = expect) + +test.run(arguments = 'mem --chdir logs foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/file.py b/test/scons-time/mem/file.py new file mode 100644 index 0000000..fb329a0 --- /dev/null +++ b/test/scons-time/mem/file.py @@ -0,0 +1,84 @@ +#!/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 config files specified with the -f and --file options +affect how the mem subcommand processes things. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-001-0.log') + +test.fake_logfile('foo-002-0.log') + + +test.write('st1.conf', """\ +prefix = 'foo-001' +""") + +expect1 = """\ + pre-read post-read pre-build post-build + 1000 2000 3000 4000 foo-001-0.log +""" + +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, \ + '-' 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) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/format-gnuplot.py b/test/scons-time/mem/format-gnuplot.py new file mode 100644 index 0000000..5f3e9cd --- /dev/null +++ b/test/scons-time/mem/format-gnuplot.py @@ -0,0 +1,78 @@ +#!/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 the mem --format=gnuplot option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect_notitle = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 4000.000 +1 4001.000 +e +# Full build +0 4000.000 +1 4001.000 +e +# Up-to-date build +0 4000.000 +1 4001.000 +e +""" + +expect_title = 'set title "TITLE"\n' + expect_notitle + +test.run(arguments = 'mem --fmt gnuplot', stdout=expect_notitle) + +test.run(arguments = 'mem --fmt=gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'mem --format gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'mem --format=gnuplot', stdout=expect_notitle) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/help.py b/test/scons-time/mem/help.py new file mode 100644 index 0000000..4ff34fa --- /dev/null +++ b/test/scons-time/mem/help.py @@ -0,0 +1,63 @@ +#!/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 the "mem" subcommand help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + "Usage: scons-time mem [OPTIONS] FILE [...]\n", + " -C DIR, --chdir=DIR Change to DIR before looking for files\n", + " -h, --help Print this help and exit\n", +] + +test.run(arguments = 'mem -h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'mem -?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'mem --help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'help mem') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/memglob.py b/test/scons-time/mem/memglob.py new file mode 100644 index 0000000..820021e --- /dev/null +++ b/test/scons-time/mem/memglob.py @@ -0,0 +1,58 @@ +#!/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 mem subommand globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 1000 2000 3000 4000 %s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'mem foo-*.log', stdout = expect) + +test.run(arguments = 'mem foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/no-args.py b/test/scons-time/mem/no-args.py new file mode 100644 index 0000000..0d1380f --- /dev/null +++ b/test/scons-time/mem/no-args.py @@ -0,0 +1,49 @@ +#!/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 the error when no arguments are specified to the mem subcommand. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: mem: No arguments specified. + No *.log files found in "%s". + Type "scons-time help mem" for help. +""" % test.workpath() + +test.run(arguments = 'mem', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/prefix.py b/test/scons-time/mem/prefix.py new file mode 100644 index 0000000..faca54d --- /dev/null +++ b/test/scons-time/mem/prefix.py @@ -0,0 +1,68 @@ +#!/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 mem -p and --prefix options specify what log files to use. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +header = ' pre-read post-read pre-build post-build\n' + +line_fmt = ' 1000 2000 3000 4000 %s\n' + +foo_lines = [ header ] +bar_lines = [ header ] + +for i in range(3): + logfile_name = os.path.join('foo-%s.log' % i) + test.fake_logfile(logfile_name) + foo_lines.append(line_fmt % logfile_name) + + logfile_name = os.path.join('bar-%s.log' % i) + test.fake_logfile(logfile_name) + bar_lines.append(line_fmt % logfile_name) + +foo_expect = ''.join(foo_lines) +bar_expect = ''.join(bar_lines) + +test.run(arguments = 'mem -p bar', stdout = bar_expect) + +test.run(arguments = 'mem --prefix=foo', stdout = foo_expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/stage.py b/test/scons-time/mem/stage.py new file mode 100644 index 0000000..849c71e --- /dev/null +++ b/test/scons-time/mem/stage.py @@ -0,0 +1,89 @@ +#!/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 the mem --stage option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 %(index)s000.000 +1 %(index)s001.000 +e +# Full build +0 %(index)s000.000 +1 %(index)s001.000 +e +# Up-to-date build +0 %(index)s000.000 +1 %(index)s001.000 +e +""" + +pre_read = expect % {'index' : 1} +post_read = expect % {'index' : 2} +pre_build = expect % {'index' : 3} +post_build = expect % {'index' : 4} + +test.run(arguments = 'mem --fmt gnuplot --stage pre-read', stdout=pre_read) + +test.run(arguments = 'mem --fmt gnuplot --stage=post-read', stdout=post_read) + +test.run(arguments = 'mem --fmt gnuplot --stage=pre-build', stdout=pre_build) + +test.run(arguments = 'mem --fmt gnuplot --stage post-build', stdout=post_build) + +expect = """\ +scons-time: mem: Unrecognized stage "unknown". +""" + +test.run(arguments = 'mem --fmt gnuplot --stage unknown', + status = 1, + stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/mem/tail.py b/test/scons-time/mem/tail.py new file mode 100644 index 0000000..cd00274 --- /dev/null +++ b/test/scons-time/mem/tail.py @@ -0,0 +1,61 @@ +#!/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 mem subcommand only prints results for the last number +of files specified with the -t and --tail options. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + + +header = ' pre-read post-read pre-build post-build\n' + +lines = [] + +line_fmt = ' 1000 2000 3000 4000 %s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect3 = [header] + lines[-3:] +expect5 = [header] + lines[-5:] + +test.run(arguments = 'mem -t 3 foo-*.log', stdout = ''.join(expect3)) + +test.run(arguments = 'mem --tail 5 foo-*.log', stdout = ''.join(expect5)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/no-args.py b/test/scons-time/no-args.py new file mode 100644 index 0000000..1ea6901 --- /dev/null +++ b/test/scons-time/no-args.py @@ -0,0 +1,48 @@ +#!/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 invoking scons-test with no arguments prints the +fall-back message and exits non-zero. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +Type "scons-time help" for usage. +""" + +test.run(arguments = '', status=1, stderr=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/chdir.py b/test/scons-time/obj/chdir.py new file mode 100644 index 0000000..4b77f8a --- /dev/null +++ b/test/scons-time/obj/chdir.py @@ -0,0 +1,63 @@ +#!/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 obj -C and --chdir options change directory before +globbing for files. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 1101%(i)s 1102%(i)s 1103%(i)s 1104%(i)s %(logfile_name)s\n' + +for i in range(9): + logfile_name = os.path.join('logs', 'foo-%s.log' % i) + test.fake_logfile(logfile_name, i) + lines.append(line_fmt % locals()) + +expect = ''.join(lines) + +test.run(arguments = 'obj -C logs Environment.Base foo-*.log', stdout = expect) + +test.run(arguments = 'obj --chdir logs Environment.Base foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/file.py b/test/scons-time/obj/file.py new file mode 100644 index 0000000..5076d7f --- /dev/null +++ b/test/scons-time/obj/file.py @@ -0,0 +1,84 @@ +#!/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 config files specified with the -f and --file options +affect how the obj subcommand processes things. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-001-0.log') + +test.fake_logfile('foo-002-0.log') + + +test.write('st1.conf', """\ +prefix = 'foo-001' +""") + +expect1 = """\ + pre-read post-read pre-build post-build + 16010 16020 16030 16040 foo-001-0.log +""" + +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, \ + '-' 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) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/format-gnuplot.py b/test/scons-time/obj/format-gnuplot.py new file mode 100644 index 0000000..cdded16 --- /dev/null +++ b/test/scons-time/obj/format-gnuplot.py @@ -0,0 +1,82 @@ +#!/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 the obj --format=gnuplot option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect_notitle = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 20040.000 +1 20041.000 +e +# Full build +0 20040.000 +1 20041.000 +e +# Up-to-date build +0 20040.000 +1 20041.000 +e +""" + +expect_title = 'set title "TITLE"\n' + expect_notitle + +test.run(arguments = 'obj --fmt gnuplot Node.Node', + stdout=expect_notitle) + +test.run(arguments = 'obj --fmt=gnuplot --title TITLE Node.Node', + stdout=expect_title) + +test.run(arguments = 'obj --format gnuplot --title TITLE Node.Node', + stdout=expect_title) + +test.run(arguments = 'obj --format=gnuplot Node.Node', + stdout=expect_notitle) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/help.py b/test/scons-time/obj/help.py new file mode 100644 index 0000000..d4cc1bd --- /dev/null +++ b/test/scons-time/obj/help.py @@ -0,0 +1,63 @@ +#!/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 the "obj" subcommand help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + "Usage: scons-time obj [OPTIONS] OBJECT FILE [...]\n", + " -C DIR, --chdir=DIR Change to DIR before looking for files\n", + " -h, --help Print this help and exit\n", +] + +test.run(arguments = 'obj -h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'obj -?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'obj --help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'help obj') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/no-args.py b/test/scons-time/obj/no-args.py new file mode 100644 index 0000000..9350b79 --- /dev/null +++ b/test/scons-time/obj/no-args.py @@ -0,0 +1,48 @@ +#!/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 the error when no arguments are specified to the obj subcommand. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: obj: Must specify an object name. + Type "scons-time help obj" for help. +""" + +test.run(arguments = 'obj', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/no-files.py b/test/scons-time/obj/no-files.py new file mode 100644 index 0000000..50e5df1 --- /dev/null +++ b/test/scons-time/obj/no-files.py @@ -0,0 +1,50 @@ +#!/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 the error when the obj subcommand is passed object argument but no +file arguments. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: obj: No arguments specified. + No *.log files found in "%s". + Type "scons-time help obj" for help. +""" % test.workpath() + +test.run(arguments = 'obj fake.object', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/objglob.py b/test/scons-time/obj/objglob.py new file mode 100644 index 0000000..2105355 --- /dev/null +++ b/test/scons-time/obj/objglob.py @@ -0,0 +1,58 @@ +#!/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 obj subcommand globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' pre-read post-read pre-build post-build\n' +] + +line_fmt = ' 601%(i)s 602%(i)s 603%(i)s 604%(i)s %(logfile_name)s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name, i) + lines.append(line_fmt % locals()) + +expect = ''.join(lines) + +test.run(arguments = 'obj Builder.BuilderBase foo-*.log', stdout = expect) + +test.run(arguments = 'obj Builder.BuilderBase foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/prefix.py b/test/scons-time/obj/prefix.py new file mode 100644 index 0000000..0bee5f7 --- /dev/null +++ b/test/scons-time/obj/prefix.py @@ -0,0 +1,68 @@ +#!/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 obj -p and --prefix options specify what log files to use. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +header = ' pre-read post-read pre-build post-build\n' + +line_fmt = ' 11010 11020 11030 11040 %s\n' + +foo_lines = [ header ] +bar_lines = [ header ] + +for i in range(3): + logfile_name = os.path.join('foo-%s.log' % i) + test.fake_logfile(logfile_name) + foo_lines.append(line_fmt % logfile_name) + + logfile_name = os.path.join('bar-%s.log' % i) + test.fake_logfile(logfile_name) + bar_lines.append(line_fmt % logfile_name) + +foo_expect = ''.join(foo_lines) +bar_expect = ''.join(bar_lines) + +test.run(arguments = 'obj -p bar Environment.Base', stdout = bar_expect) + +test.run(arguments = 'obj --prefix=foo Environment.Base', stdout = foo_expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/stage.py b/test/scons-time/obj/stage.py new file mode 100644 index 0000000..7361f69 --- /dev/null +++ b/test/scons-time/obj/stage.py @@ -0,0 +1,94 @@ +#!/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 the obj --stage option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 50%(index)s0.000 +1 50%(index)s1.000 +e +# Full build +0 50%(index)s0.000 +1 50%(index)s1.000 +e +# Up-to-date build +0 50%(index)s0.000 +1 50%(index)s1.000 +e +""" + +pre_read = expect % {'index' : 1} +post_read = expect % {'index' : 2} +pre_build = expect % {'index' : 3} +post_build = expect % {'index' : 4} + +test.run(arguments = 'obj --fmt gnuplot --stage pre-read Action.ListAction', + stdout=pre_read) + +test.run(arguments = 'obj --fmt gnuplot --stage=post-read Action.ListAction', + stdout=post_read) + +test.run(arguments = 'obj --fmt gnuplot --stage=pre-build Action.ListAction', + stdout=pre_build) + +test.run(arguments = 'obj --fmt gnuplot --stage post-build Action.ListAction', + stdout=post_build) + +expect = """\ +scons-time: obj: Unrecognized stage "unknown". + Type "scons-time help obj" for help. +""" + +test.run(arguments = 'obj --fmt gnuplot --stage unknown', + status = 1, + stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/obj/tail.py b/test/scons-time/obj/tail.py new file mode 100644 index 0000000..341a905 --- /dev/null +++ b/test/scons-time/obj/tail.py @@ -0,0 +1,61 @@ +#!/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 obj subcommand only prints results for the last number +of files specified with the -t and --tail options. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + + +header = ' pre-read post-read pre-build post-build\n' + +lines = [] + +line_fmt = ' 1501%(i)s 1502%(i)s 1503%(i)s 1504%(i)s %(logfile_name)s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name, i) + lines.append(line_fmt % locals()) + +expect3 = ''.join([header] + lines[-3:]) +expect5 = ''.join([header] + lines[-5:]) + +test.run(arguments = 'obj -t 3 Node.FS foo-*.log', stdout = expect3) + +test.run(arguments = 'obj --tail 5 Node.FS foo-*.log', stdout = expect5) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/aegis.py b/test/scons-time/run/aegis.py new file mode 100644 index 0000000..09c6aad --- /dev/null +++ b/test/scons-time/run/aegis.py @@ -0,0 +1,79 @@ +#!/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 the ability to "check out" an SCons delta from a fake +Aegis utility. +""" + +import re + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar') + +my_aegis_py = test.write_fake_aegis_py('my_aegis.py') + +test.write('config', """\ +aegis = r'%(my_aegis_py)s' +""" % locals()) + +test.run(arguments = 'run -f config --aegis xyzzy.0.1 --number 321,329 foo.tar') + +test.must_exist('foo-321-0.log', + 'foo-321-0.prof', + 'foo-321-1.log', + 'foo-321-1.prof', + 'foo-321-2.log', + 'foo-321-2.prof') + +test.must_exist('foo-329-0.log', + 'foo-329-0.prof', + 'foo-329-1.log', + 'foo-329-1.prof', + 'foo-329-2.log', + 'foo-329-2.prof') + +expect = [ + 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')) + +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-617-2.log', re_find) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/archive/dir.py b/test/scons-time/run/archive/dir.py new file mode 100644 index 0000000..590d568 --- /dev/null +++ b/test/scons-time/run/archive/dir.py @@ -0,0 +1,55 @@ +#!/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 basic generation of timing information from an input fake-project +directory tree. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo') + +test.run(arguments = 'run foo') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/archive/tar-gz.py b/test/scons-time/run/archive/tar-gz.py new file mode 100644 index 0000000..af11c33 --- /dev/null +++ b/test/scons-time/run/archive/tar-gz.py @@ -0,0 +1,55 @@ +#!/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 basic generation of timing information from an input fake-project +.tar.gz file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run foo.tar.gz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/archive/tar.py b/test/scons-time/run/archive/tar.py new file mode 100644 index 0000000..a85dacf --- /dev/null +++ b/test/scons-time/run/archive/tar.py @@ -0,0 +1,55 @@ +#!/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 basic generation of timing information from an input fake-project +.tar file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar') + +test.run(arguments = 'run foo.tar') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/archive/tgz.py b/test/scons-time/run/archive/tgz.py new file mode 100644 index 0000000..c349e02 --- /dev/null +++ b/test/scons-time/run/archive/tgz.py @@ -0,0 +1,55 @@ +#!/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 basic generation of timing information from an input fake-project +.tgz file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tgz') + +test.run(arguments = 'run foo.tgz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/archive/zip.py b/test/scons-time/run/archive/zip.py new file mode 100644 index 0000000..4620440 --- /dev/null +++ b/test/scons-time/run/archive/zip.py @@ -0,0 +1,57 @@ +#!/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 basic generation of timing information from an input fake-project +.zip file. +""" + +import sys + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.zip') + +test.run(arguments = 'run foo.zip') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/archive_list.py b/test/scons-time/run/config/archive_list.py new file mode 100644 index 0000000..d393a69 --- /dev/null +++ b/test/scons-time/run/config/archive_list.py @@ -0,0 +1,83 @@ +#!/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 specifying a list of archives through the archive_list setting +in a config file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.write('config', """\ +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', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.must_exist('foo-file') + + +test.write_sample_project('bar.tar.gz') + +test.run(arguments = 'run -f config bar.tar.gz') + +test.must_not_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + +test.must_exist('bar-000-0.log', + 'bar-000-0.prof', + 'bar-000-1.log', + 'bar-000-1.prof', + 'bar-000-2.log', + 'bar-000-2.prof') + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/initial_commands.py b/test/scons-time/run/config/initial_commands.py new file mode 100644 index 0000000..167ed49 --- /dev/null +++ b/test/scons-time/run/config/initial_commands.py @@ -0,0 +1,62 @@ +#!/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 specifying a list of initial commands through a config file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.write('config', """\ +def touch(arg): + open(arg, 'w') +initial_commands = [(touch, 'touch %%%%s', r'%s')] +""" % test.workpath('INITIAL')) + +test.run(arguments = 'run -f config foo.tar.gz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.must_exist('INITIAL') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/prefix.py b/test/scons-time/run/config/prefix.py new file mode 100644 index 0000000..5ef673b --- /dev/null +++ b/test/scons-time/run/config/prefix.py @@ -0,0 +1,58 @@ +#!/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 specifying an alternate file prefix through a config file. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.write('config', """\ +prefix = 'bar' +""") + +test.run(arguments = 'run -f config foo.tar.gz') + +test.must_exist('bar-000-0.log', + 'bar-000-0.prof', + 'bar-000-1.log', + 'bar-000-1.prof', + 'bar-000-2.log', + 'bar-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py new file mode 100644 index 0000000..6cf965b --- /dev/null +++ b/test/scons-time/run/config/python.py @@ -0,0 +1,74 @@ +#!/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 specifying an alternate Python executable in a config file. +""" + +import os + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar.gz') + +my_python_py = test.workpath('my_python.py') + +test.write('config', """\ +python = r'%(my_python_py)s' +""" % locals()) + +test.write(my_python_py, """\ +#!/usr/bin/env python +import sys +profile = '' +for arg in sys.argv[1:]: + if arg.startswith('--profile='): + profile = arg[10:] + break +print 'my_python.py: %s' % profile +""") + +os.chmod(my_python_py, 0755) + +test.run(arguments = 'run -f config foo.tar.gz') + +prof0 = test.workpath('foo-000-0.prof') +prof1 = test.workpath('foo-000-1.prof') +prof2 = test.workpath('foo-000-2.prof') + +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/scons.py b/test/scons-time/run/config/scons.py new file mode 100644 index 0000000..73f041d --- /dev/null +++ b/test/scons-time/run/config/scons.py @@ -0,0 +1,70 @@ +#!/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 specifying an alternate SCons through a config file. +""" + + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar.gz') + +my_scons_py = test.workpath('my_scons.py') + +test.write('config', """\ +scons = r'%(my_scons_py)s' +""" % locals()) + +test.write(my_scons_py, """\ +import sys +profile = '' +for arg in sys.argv[1:]: + if arg.startswith('--profile='): + profile = arg[10:] + break +print 'my_scons.py: %s' % profile +""") + +test.run(arguments = 'run -f config foo.tar.gz') + +prof0 = test.workpath('foo-000-0.prof') +prof1 = test.workpath('foo-000-1.prof') +prof2 = test.workpath('foo-000-2.prof') + +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/subdir.py b/test/scons-time/run/config/subdir.py new file mode 100644 index 0000000..1d7ca8e --- /dev/null +++ b/test/scons-time/run/config/subdir.py @@ -0,0 +1,71 @@ +#!/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 picking up the subdir value from a config file. +""" + +import os +import re + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz', 'subdir') + +test.write('config', """\ +subdir = 'subdir' +""") + +test.run(arguments = 'run -f config foo.tar.gz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +content = test.read(test.workpath('foo-000-0.log'), mode='r') + +expect = [ + 'SConstruct file directory: .*%ssubdir$' % re.escape(os.sep), +] + +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-000-0.log', re_find) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/config/targets.py b/test/scons-time/run/config/targets.py new file mode 100644 index 0000000..482a44d --- /dev/null +++ b/test/scons-time/run/config/targets.py @@ -0,0 +1,92 @@ +#!/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 specifying a list of targets through a config file. +""" + +import os +import re + +import TestSCons_time + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.write('config', """\ +targets = 'target1 target2' +""") + +test.run(arguments = 'run -f config foo.tar.gz') + +scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) +src_engine = re.escape(test.workpath('src', 'engine')) + +prof1 = re.escape(test.workpath('foo-000-1.prof')) +prof2 = re.escape(test.workpath('foo-000-2.prof')) + +sep = re.escape(os.sep) + +expect = """\ +%(scons_py)s + --debug=count + --debug=memory + --debug=time + --debug=memoizer + --profile=%(prof1)s + target1 + target2 +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: .*scons-time-.*%(sep)sfoo +""" % locals() + +test.must_match('foo-000-1.log', expect, mode='r') + +expect = """\ +%(scons_py)s + --debug=count + --debug=memory + --debug=time + --debug=memoizer + --profile=%(prof2)s + target1 + target2 +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: .*scons-time-.*%(sep)sfoo +""" % locals() + +test.must_match('foo-000-2.log', expect, mode='r') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/help.py b/test/scons-time/run/option/help.py new file mode 100644 index 0000000..d7f2b29 --- /dev/null +++ b/test/scons-time/run/option/help.py @@ -0,0 +1,65 @@ +#!/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 run -h option (and variants) prints help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + "Usage: scons-time run [OPTIONS] [FILE ...]\n", + " -h, --help Print this help and exit\n", + " -n, --no-exec No execute, just print command lines\n", + " -q, --quiet Don't print command lines\n", + " -v, --verbose Display output of commands\n", +] + +test.run(arguments = 'run -h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'run -?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'run --help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'help run') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/next-run.py b/test/scons-time/run/option/next-run.py new file mode 100644 index 0000000..7e729cb --- /dev/null +++ b/test/scons-time/run/option/next-run.py @@ -0,0 +1,105 @@ +#!/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 script finds the next run number based on the +contents of the directory, even when specified with --outdir. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('sub') + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run foo.tar.gz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.must_not_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + +test.run(arguments = 'run foo.tar.gz') + +test.must_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + +test.must_not_exist('foo-002-0.log', + 'foo-002-0.prof', + 'foo-002-1.log', + 'foo-002-1.prof', + 'foo-002-2.log', + 'foo-002-2.prof') + +test.run(arguments = 'run foo.tar.gz') + +test.must_exist('foo-002-0.log', + 'foo-002-0.prof', + 'foo-002-1.log', + 'foo-002-1.prof', + 'foo-002-2.log', + 'foo-002-2.prof') + +test.run(arguments = 'run --outdir sub foo.tar.gz') + +test.must_exist(['sub', 'foo-000-0.log'], + ['sub', 'foo-000-0.prof'], + ['sub', 'foo-000-1.log'], + ['sub', 'foo-000-1.prof'], + ['sub', 'foo-000-2.log'], + ['sub', 'foo-000-2.prof']) + +test.must_not_exist('foo-003-0.log', + 'foo-003-0.prof', + 'foo-003-1.log', + 'foo-003-1.prof', + 'foo-003-2.log', + 'foo-003-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/no-args.py b/test/scons-time/run/option/no-args.py new file mode 100644 index 0000000..e01f24b --- /dev/null +++ b/test/scons-time/run/option/no-args.py @@ -0,0 +1,48 @@ +#!/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 the error when the run command is passed no arguments. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: run: No arguments or -f config file specified. + Type "scons-time help run" for help. +""" + +test.run(arguments = 'run', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/no-exec.py b/test/scons-time/run/option/no-exec.py new file mode 100644 index 0000000..db6757c --- /dev/null +++ b/test/scons-time/run/option/no-exec.py @@ -0,0 +1,55 @@ +#!/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 run -n and --no-exec options don't actually create the +expected output files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run -n foo.tar.gz') + +test.run(arguments = 'run --no-exec foo.tar.gz') + +test.must_not_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/number.py b/test/scons-time/run/option/number.py new file mode 100644 index 0000000..0e87c2d --- /dev/null +++ b/test/scons-time/run/option/number.py @@ -0,0 +1,54 @@ +#!/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 the run --number option specifies the run number. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run --number 77 foo.tar.gz') + +test.must_exist('foo-077-0.log', + 'foo-077-0.prof', + 'foo-077-1.log', + 'foo-077-1.prof', + 'foo-077-2.log', + 'foo-077-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/outdir.py b/test/scons-time/run/option/outdir.py new file mode 100644 index 0000000..370974b --- /dev/null +++ b/test/scons-time/run/option/outdir.py @@ -0,0 +1,57 @@ + +#!/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 specifying an alternate output directory with the --outdir option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('sub') + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run --outdir sub foo.tar.gz') + +test.must_exist(['sub', 'foo-000-0.log'], + ['sub', 'foo-000-0.prof'], + ['sub', 'foo-000-1.log'], + ['sub', 'foo-000-1.prof'], + ['sub', 'foo-000-2.log'], + ['sub', 'foo-000-2.prof']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/prefix.py b/test/scons-time/run/option/prefix.py new file mode 100644 index 0000000..df13cd0 --- /dev/null +++ b/test/scons-time/run/option/prefix.py @@ -0,0 +1,54 @@ +#!/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 specifying an alternate file prefix with the --prefix option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz') + +test.run(arguments = 'run --prefix bar foo.tar.gz') + +test.must_exist('bar-000-0.log', + 'bar-000-0.prof', + 'bar-000-1.log', + 'bar-000-1.prof', + 'bar-000-2.log', + 'bar-000-2.prof') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py new file mode 100644 index 0000000..a28e23f --- /dev/null +++ b/test/scons-time/run/option/python.py @@ -0,0 +1,70 @@ +#!/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 the run --python option to specify an alternatie Python executable. +""" + +import os + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar.gz') + +my_python_py = test.workpath('my_python.py') + +test.write(my_python_py, """\ +#!/usr/bin/env python +import sys +profile = '' +for arg in sys.argv[1:]: + if arg.startswith('--profile='): + profile = arg[10:] + break +sys.stdout.write('my_python.py: %s\\n' % profile) +""") + +os.chmod(my_python_py, 0755) + +test.run(arguments = 'run --python %s foo.tar.gz' % my_python_py) + +prof0 = test.workpath('foo-000-0.prof') +prof1 = test.workpath('foo-000-1.prof') +prof2 = test.workpath('foo-000-2.prof') + +test.must_match('foo-000-0.log', "my_python.py: %s\n" % prof0) +test.must_match('foo-000-1.log', "my_python.py: %s\n" % prof1) +test.must_match('foo-000-2.log', "my_python.py: %s\n" % prof2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/quiet.py b/test/scons-time/run/option/quiet.py new file mode 100644 index 0000000..2910e8e --- /dev/null +++ b/test/scons-time/run/option/quiet.py @@ -0,0 +1,88 @@ +#!/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 run -q and --quiet options suppress build output. +""" + +import re + +import TestSCons_time + +python = TestSCons_time.python + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re, + diff = TestSCons_time.diff_re) + +scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) +src_engine = re.escape(test.workpath('src', 'engine')) + +tmp_scons_time = test.tempdir_re() +tmp_scons_time_foo = test.tempdir_re('foo') + + +test.write_fake_scons_py() + +foo_tar_gz = test.write_sample_project('foo.tar.gz') + +expect = """\ +%(scons_py)s + --version +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +""" % locals() + +test.run(arguments = 'run -q foo.tar.gz', stdout = expect) + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +scons_py = test.workpath('src/script/scons.py') + +src_engine = test.workpath('src/engine') + +test.run(arguments = 'run -q foo.tar.gz', stdout = expect) + +test.must_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + +test.run(arguments = 'run --quiet foo.tar.gz', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/scons.py b/test/scons-time/run/option/scons.py new file mode 100644 index 0000000..0bf883b --- /dev/null +++ b/test/scons-time/run/option/scons.py @@ -0,0 +1,65 @@ +#!/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 the run --scons option to specify an alternatie SCons script. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar.gz') + +my_scons_py = test.workpath('my_scons.py') + +test.write(my_scons_py, """\ +import sys +profile = '' +for arg in sys.argv[1:]: + if arg.startswith('--profile='): + profile = arg[10:] + break +print 'my_scons.py: %s' % profile +""") + +test.run(arguments = 'run --scons %s foo.tar.gz' % my_scons_py) + +prof0 = test.workpath('foo-000-0.prof') +prof1 = test.workpath('foo-000-1.prof') +prof2 = test.workpath('foo-000-2.prof') + +test.must_match('foo-000-0.log', "my_scons.py: %s\n" % prof0) +test.must_match('foo-000-1.log', "my_scons.py: %s\n" % prof1) +test.must_match('foo-000-2.log', "my_scons.py: %s\n" % prof2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/subdir.py b/test/scons-time/run/option/subdir.py new file mode 100644 index 0000000..ef8bc81 --- /dev/null +++ b/test/scons-time/run/option/subdir.py @@ -0,0 +1,67 @@ +#!/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 we change to a subdirectory before building if asked to do so. +""" + +import os +import re + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_fake_scons_py() + +test.write_sample_project('foo.tar.gz', 'subdir') + +test.run(arguments = 'run --subdir subdir foo.tar.gz') + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +expect = [ + 'SConstruct file directory: .*%ssubdir$' % re.escape(os.sep), +] + +content = test.read(test.workpath('foo-000-0.log'), mode='r') + +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-000-0.log', re_find) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py new file mode 100644 index 0000000..5fc6d64 --- /dev/null +++ b/test/scons-time/run/option/verbose.py @@ -0,0 +1,154 @@ +#!/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 run -v and --verbose options display command output. +""" + +import sys +import re + +import TestSCons_time + +_python_ = re.escape('"' + sys.executable + '"') + + +test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re, + diff = TestSCons_time.diff_re) + +scons_py = re.escape(test.workpath('src', 'script', 'scons.py')) +src_engine = re.escape(test.workpath('src', 'engine')) + +tmp_scons_time = test.tempdir_re() +tmp_scons_time_foo = test.tempdir_re('foo') + + +test.write_fake_scons_py() + +foo_tar_gz = test.write_sample_project('foo.tar.gz') + +expect = """\ +%(scons_py)s + --version +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +""" % locals() + +test.run(arguments = 'run -q foo.tar.gz', stdout = expect) + +test.must_exist('foo-000-0.log', + 'foo-000-0.prof', + 'foo-000-1.log', + 'foo-000-1.prof', + 'foo-000-2.log', + 'foo-000-2.prof') + +time_re = r'\[\d\d:\d\d:\d\d\]' + +scons_flags = '--debug=count --debug=memory --debug=time --debug=memoizer' + + +expect = """\ +scons-time%(time_re)s: mkdir %(tmp_scons_time)s +scons-time%(time_re)s: cd %(tmp_scons_time)s +scons-time%(time_re)s: tar xzf %(foo_tar_gz)s +scons-time%(time_re)s: cd foo +scons-time%(time_re)s: find \\* -type f | xargs cat > /dev/null +scons-time%(time_re)s: export SCONS_LIB_DIR=%(src_engine)s +scons-time%(time_re)s: %(_python_)s %(scons_py)s --version +%(scons_py)s + --version +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof0)s --help 2>&1 \\| tee %(log0)s +%(scons_py)s + --debug=count + --debug=memory + --debug=time + --debug=memoizer + --profile=%(prof0)s + --help +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof1)s 2>&1 \\| tee %(log1)s +%(scons_py)s + --debug=count + --debug=memory + --debug=time + --debug=memoizer + --profile=%(prof1)s +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +scons-time%(time_re)s: %(_python_)s %(scons_py)s %(scons_flags)s --profile=%(prof2)s 2>&1 \\| tee %(log2)s +%(scons_py)s + --debug=count + --debug=memory + --debug=time + --debug=memoizer + --profile=%(prof2)s +SCONS_LIB_DIR = %(src_engine)s +SConstruct file directory: %(tmp_scons_time_foo)s +scons-time%(time_re)s: cd .* +scons-time%(time_re)s: rm -rf %(tmp_scons_time)s +""" + +foo_tar_gz = re.escape(foo_tar_gz) + +log0 = re.escape(test.workpath('foo-001-0.log')) +log1 = re.escape(test.workpath('foo-001-1.log')) +log2 = re.escape(test.workpath('foo-001-2.log')) + +prof0 = re.escape(test.workpath('foo-001-0.prof')) +prof1 = re.escape(test.workpath('foo-001-1.prof')) +prof2 = re.escape(test.workpath('foo-001-2.prof')) + +test.run(arguments = 'run -v foo.tar.gz', stdout = expect % locals()) + +test.must_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + +log0 = re.escape(test.workpath('foo-002-0.log')) +log1 = re.escape(test.workpath('foo-002-1.log')) +log2 = re.escape(test.workpath('foo-002-2.log')) + +prof0 = re.escape(test.workpath('foo-002-0.prof')) +prof1 = re.escape(test.workpath('foo-002-1.prof')) +prof2 = re.escape(test.workpath('foo-002-2.prof')) + +test.run(arguments = 'run --verbose foo.tar.gz', stdout = expect % locals()) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/run/subversion.py b/test/scons-time/run/subversion.py new file mode 100644 index 0000000..f895760 --- /dev/null +++ b/test/scons-time/run/subversion.py @@ -0,0 +1,81 @@ +#!/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 ability to "check out" an SCons revision from a fake +Subversion utility. +""" + +import re +import tempfile + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.write_sample_project('foo.tar') + +_python_ = TestSCons_time._python_ +my_svn_py = test.write_fake_svn_py('my_svn.py') + +test.write('config', """\ +svn = r'%(_python_)s %(my_svn_py)s' +""" % locals()) + +test.run(arguments = 'run -f config --svn http://xyzzy --number 617,716 foo.tar') + +test.must_exist('foo-617-0.log', + 'foo-617-0.prof', + 'foo-617-1.log', + 'foo-617-1.prof', + 'foo-617-2.log', + 'foo-617-2.prof') + +test.must_exist('foo-716-0.log', + 'foo-716-0.prof', + 'foo-716-1.log', + 'foo-716-1.prof', + 'foo-716-2.log', + 'foo-716-2.prof') + +expect = [ + 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') + +def re_find(content, line): + return re.search(line, content) +test.must_contain_all_lines(content, expect, 'foo-617-2.log', re_find) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/chdir.py b/test/scons-time/time/chdir.py new file mode 100644 index 0000000..762de75 --- /dev/null +++ b/test/scons-time/time/chdir.py @@ -0,0 +1,63 @@ +#!/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 -C and --chdir options change directory before +globbing for files. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +lines = [ + ' Total SConscripts SCons commands\n' +] + +line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' + +for i in range(9): + logfile_name = os.path.join('logs', 'foo-%s.log' % i) + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'time -C logs foo-*.log', stdout = expect) + +test.run(arguments = 'time --chdir logs foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/empty.py b/test/scons-time/time/empty.py new file mode 100644 index 0000000..a59a014 --- /dev/null +++ b/test/scons-time/time/empty.py @@ -0,0 +1,97 @@ +#!/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 range(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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/file.py b/test/scons-time/time/file.py new file mode 100644 index 0000000..4c3271b --- /dev/null +++ b/test/scons-time/time/file.py @@ -0,0 +1,84 @@ +#!/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 config files specified with the -f and --file options +affect how the time subcommand processes things. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-001-0.log') + +test.fake_logfile('foo-002-0.log') + + +test.write('st1.conf', """\ +prefix = 'foo-001' +""") + +expect1 = """\ + Total SConscripts SCons commands + 11.123456 22.234567 33.345678 44.456789 foo-001-0.log +""" + +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, \ + '-' 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) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/format-gnuplot.py b/test/scons-time/time/format-gnuplot.py new file mode 100644 index 0000000..7b38626 --- /dev/null +++ b/test/scons-time/time/format-gnuplot.py @@ -0,0 +1,78 @@ +#!/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 the time --format=gnuplot option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect_notitle = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 11.123456 +1 11.123456 +e +# Full build +0 11.123456 +1 11.123456 +e +# Up-to-date build +0 11.123456 +1 11.123456 +e +""" + +expect_title = 'set title "TITLE"\n' + expect_notitle + +test.run(arguments = 'time --fmt gnuplot', stdout=expect_notitle) + +test.run(arguments = 'time --fmt=gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'time --format gnuplot --title TITLE', stdout=expect_title) + +test.run(arguments = 'time --format=gnuplot', stdout=expect_notitle) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/help.py b/test/scons-time/time/help.py new file mode 100644 index 0000000..3df60f7 --- /dev/null +++ b/test/scons-time/time/help.py @@ -0,0 +1,63 @@ +#!/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 the "time" subcommand help. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = [ + "Usage: scons-time time [OPTIONS] FILE [...]\n", + " -C DIR, --chdir=DIR Change to DIR before looking for files\n", + " -h, --help Print this help and exit\n", +] + +test.run(arguments = 'time -h') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'time -?') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'time --help') + +test.must_contain_all_lines(test.stdout(), expect) + +test.run(arguments = 'help time') + +test.must_contain_all_lines(test.stdout(), expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/no-args.py b/test/scons-time/time/no-args.py new file mode 100644 index 0000000..56ed4a1 --- /dev/null +++ b/test/scons-time/time/no-args.py @@ -0,0 +1,49 @@ +#!/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 the error when the time subcommand is passed no arguments. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: mem: No arguments specified. + No *.log files found in "%s". + Type "scons-time help mem" for help. +""" % test.workpath() + +test.run(arguments = 'mem', status = 1, stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/no-result.py b/test/scons-time/time/no-result.py new file mode 100644 index 0000000..fbd2de9 --- /dev/null +++ b/test/scons-time/time/no-result.py @@ -0,0 +1,81 @@ +#!/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 range(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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/prefix.py b/test/scons-time/time/prefix.py new file mode 100644 index 0000000..00a1f52 --- /dev/null +++ b/test/scons-time/time/prefix.py @@ -0,0 +1,68 @@ +#!/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 -p and --prefix options specify what log files to use. +""" + +import os.path + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.subdir('logs') + +header = ' Total SConscripts SCons commands\n' + +line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' + +foo_lines = [ header ] +bar_lines = [ header ] + +for i in range(3): + logfile_name = os.path.join('foo-%s.log' % i) + test.fake_logfile(logfile_name) + foo_lines.append(line_fmt % logfile_name) + + logfile_name = os.path.join('bar-%s.log' % i) + test.fake_logfile(logfile_name) + bar_lines.append(line_fmt % logfile_name) + +foo_expect = ''.join(foo_lines) +bar_expect = ''.join(bar_lines) + +test.run(arguments = 'time -p bar', stdout = bar_expect) + +test.run(arguments = 'time --prefix=foo', stdout = foo_expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/tail.py b/test/scons-time/time/tail.py new file mode 100644 index 0000000..c89f904 --- /dev/null +++ b/test/scons-time/time/tail.py @@ -0,0 +1,61 @@ +#!/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 only prints results for the last number +of files specified with the -t and --tail options. +""" + +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' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect3 = [header] + lines[-3:] +expect5 = [header] + lines[-5:] + +test.run(arguments = 'time -t 3 foo-*.log', stdout = ''.join(expect3)) + +test.run(arguments = 'time --tail 5 foo-*.log', stdout = ''.join(expect5)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/timeglob.py b/test/scons-time/time/timeglob.py new file mode 100644 index 0000000..1a76d9f --- /dev/null +++ b/test/scons-time/time/timeglob.py @@ -0,0 +1,58 @@ +#!/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 globs for files. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +lines = [ + ' Total SConscripts SCons commands\n' +] + +line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' + +for i in range(9): + logfile_name = 'foo-%s.log' % i + test.fake_logfile(logfile_name) + lines.append(line_fmt % logfile_name) + +expect = ''.join(lines) + +test.run(arguments = 'time foo-*.log', stdout = expect) + +test.run(arguments = 'time foo-?.log', stdout = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/time/which.py b/test/scons-time/time/which.py new file mode 100644 index 0000000..170ce49 --- /dev/null +++ b/test/scons-time/time/which.py @@ -0,0 +1,90 @@ +#!/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 the time --which option. +""" + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +test.fake_logfile('foo-000-0.log', 0) +test.fake_logfile('foo-000-1.log', 0) +test.fake_logfile('foo-000-2.log', 0) + +test.fake_logfile('foo-001-0.log', 1) +test.fake_logfile('foo-001-1.log', 1) +test.fake_logfile('foo-001-2.log', 1) + +expect = """\ +set key bottom left +plot '-' title "Startup" with lines lt 1, \\ + '-' title "Full build" with lines lt 2, \\ + '-' title "Up-to-date build" with lines lt 3 +# Startup +0 %(time)s +1 %(time)s +e +# Full build +0 %(time)s +1 %(time)s +e +# Up-to-date build +0 %(time)s +1 %(time)s +e +""" + +total = expect % {'time' : 11.123456} +SConscripts = expect % {'time' : 22.234567} +SCons = expect % {'time' : 33.345678} +commands = expect % {'time' : 44.456789} + +test.run(arguments = 'time --fmt gnuplot --which total', stdout=total) + +test.run(arguments = 'time --fmt gnuplot --which=SConscripts', stdout=SConscripts) + +test.run(arguments = 'time --fmt gnuplot --which=SCons', stdout=SCons) + +test.run(arguments = 'time --fmt gnuplot --which commands', stdout=commands) + +expect = """\ +scons-time: time: Unrecognized timer "unknown". + Type "scons-time help time" for help. +""" + +test.run(arguments = 'time --fmt gnuplot --which unknown', + status = 1, + stderr = expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/scons-time/unknown.py b/test/scons-time/unknown.py new file mode 100644 index 0000000..7cb3370 --- /dev/null +++ b/test/scons-time/unknown.py @@ -0,0 +1,50 @@ +#!/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 invoking scons-test with an unknown argument generates +the appropriate error message and exits non-zero. +""" + + +import TestSCons_time + +test = TestSCons_time.TestSCons_time() + +expect = """\ +scons-time: Unknown subcommand "unknown". +Type "scons-time help" for usage. +""" + +test.run(arguments = 'unknown', status=1, stderr=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |
