summaryrefslogtreecommitdiffstats
path: root/test/scons-time/func
diff options
context:
space:
mode:
Diffstat (limited to 'test/scons-time/func')
-rw-r--r--test/scons-time/func/basic.py49
-rw-r--r--test/scons-time/func/chdir.py64
-rw-r--r--test/scons-time/func/file.py80
-rw-r--r--test/scons-time/func/format-gnuplot.py82
-rw-r--r--test/scons-time/func/function.py58
-rw-r--r--test/scons-time/func/glob.py57
-rw-r--r--test/scons-time/func/help.py57
-rw-r--r--test/scons-time/func/no-args.py43
-rw-r--r--test/scons-time/func/prefix.py65
-rw-r--r--test/scons-time/func/tail.py56
10 files changed, 611 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..66c5853
--- /dev/null
+++ b/test/scons-time/func/basic.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 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()
diff --git a/test/scons-time/func/chdir.py b/test/scons-time/func/chdir.py
new file mode 100644
index 0000000..80ec93e
--- /dev/null
+++ b/test/scons-time/func/chdir.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 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 xrange(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()
diff --git a/test/scons-time/func/file.py b/test/scons-time/func/file.py
new file mode 100644
index 0000000..c9486c4
--- /dev/null
+++ b/test/scons-time/func/file.py
@@ -0,0 +1,80 @@
+#!/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(match = TestSCons_time.match_re)
+
+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', stdout = expect1)
+
+
+test.write('st2.conf', """\
+prefix = 'foo'
+title = 'ST2.CONF TITLE'
+""")
+
+expect2 = \
+r"""set title "ST2.CONF TITLE"
+set key bottom left
+plot '-' title "Startup" with lines lt 1
+# Startup
+1 0.000
+2 0.000
+e
+"""
+
+test.run(arguments = 'func --file st2.conf --fmt gnuplot', stdout = expect2)
+
+
+test.pass_test()
diff --git a/test/scons-time/func/format-gnuplot.py b/test/scons-time/func/format-gnuplot.py
new file mode 100644
index 0000000..92eb837
--- /dev/null
+++ b/test/scons-time/func/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 func --format=gnuplot option.
+"""
+
+import TestSCons_time
+
+test = TestSCons_time.TestSCons_time()
+
+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 = """\
+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 0.000
+1 0.000
+e
+# Full build
+0 0.000
+1 0.000
+e
+# Up-to-date build
+0 0.000
+1 0.000
+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()
diff --git a/test/scons-time/func/function.py b/test/scons-time/func/function.py
new file mode 100644
index 0000000..27bb94d
--- /dev/null
+++ b/test/scons-time/func/function.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 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()
diff --git a/test/scons-time/func/glob.py b/test/scons-time/func/glob.py
new file mode 100644
index 0000000..4a629ed
--- /dev/null
+++ b/test/scons-time/func/glob.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 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 xrange(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()
diff --git a/test/scons-time/func/help.py b/test/scons-time/func/help.py
new file mode 100644
index 0000000..7341ade
--- /dev/null
+++ b/test/scons-time/func/help.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 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('Standard output', test.stdout(), expect)
+
+test.run(arguments = 'func -?')
+
+test.must_contain_all_lines('Standard output', test.stdout(), expect)
+
+test.run(arguments = 'func --help')
+
+test.must_contain_all_lines('Standard output', test.stdout(), expect)
+
+test.run(arguments = 'help func')
+
+test.must_contain_all_lines('Standard output', test.stdout(), expect)
+
+test.pass_test()
diff --git a/test/scons-time/func/no-args.py b/test/scons-time/func/no-args.py
new file mode 100644
index 0000000..0767ae6
--- /dev/null
+++ b/test/scons-time/func/no-args.py
@@ -0,0 +1,43 @@
+#!/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()
diff --git a/test/scons-time/func/prefix.py b/test/scons-time/func/prefix.py
new file mode 100644
index 0000000..53dfea6
--- /dev/null
+++ b/test/scons-time/func/prefix.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 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 xrange(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 xrange(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()
diff --git a/test/scons-time/func/tail.py b/test/scons-time/func/tail.py
new file mode 100644
index 0000000..816a7a1
--- /dev/null
+++ b/test/scons-time/func/tail.py
@@ -0,0 +1,56 @@
+#!/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 xrange(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()