summaryrefslogtreecommitdiffstats
path: root/test/option
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2007-04-13 23:36:39 (GMT)
committerSteven Knight <knight@baldmt.com>2007-04-13 23:36:39 (GMT)
commit43e86764943c659f53bf0d1d101708bbdf7d07e6 (patch)
tree7b0e2eadcaf969c35e8bab578471b404a5a7d380 /test/option
parent2174f491d8e103b7af77aa089070503a7b0863c1 (diff)
downloadSCons-43e86764943c659f53bf0d1d101708bbdf7d07e6.zip
SCons-43e86764943c659f53bf0d1d101708bbdf7d07e6.tar.gz
SCons-43e86764943c659f53bf0d1d101708bbdf7d07e6.tar.bz2
Merged revisions 1826-1882 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1828 | stevenknight | 2007-02-12 13:29:17 -0600 (Mon, 12 Feb 2007) | 1 line 0.96.D588 - Speed up Builder suffix-matching. ........ r1829 | stevenknight | 2007-02-14 08:12:32 -0600 (Wed, 14 Feb 2007) | 1 line 0.96.D589 - The scons command, branch 0.96.94. ........ r1830 | stevenknight | 2007-02-14 09:49:44 -0600 (Wed, 14 Feb 2007) | 1 line 0.96.D590 - Fix the scons-doc .tar.gz file packaging. ........ r1835 | stevenknight | 2007-02-15 11:03:20 -0600 (Thu, 15 Feb 2007) | 1 line 0.96.D591 - Update the release HOWTO. ........ r1836 | stevenknight | 2007-02-15 13:39:24 -0600 (Thu, 15 Feb 2007) | 1 line 0.96.D592 - The scons command, branch 0.96.95. ........ r1837 | stevenknight | 2007-02-15 18:34:18 -0600 (Thu, 15 Feb 2007) | 1 line 0.96.D593 - Back out (comment out) Windows registry installer changes. ........ r1838 | stevenknight | 2007-02-16 10:37:28 -0600 (Fri, 16 Feb 2007) | 1 line 0.96.D594 - Update Debian packaging to remove hard-coded references to Python 2.2. (Jean-Baptiste Lab) ........ r1839 | stevenknight | 2007-02-20 09:34:23 -0600 (Tue, 20 Feb 2007) | 1 line 0.96.D595 - Documentation fixes. In the construction variable appendix, use cross-referenced links to entries. ........ r1840 | stevenknight | 2007-02-21 05:11:35 -0600 (Wed, 21 Feb 2007) | 1 line 0.96.D596 - Handle Java '.class' attributes after non-word tokens without assuming it introduces an inner class. ........ r1841 | stevenknight | 2007-02-21 22:33:28 -0600 (Wed, 21 Feb 2007) | 1 line 0.96.D597 - CPPDEFINES regression ........ r1842 | stevenknight | 2007-02-22 14:19:10 -0600 (Thu, 22 Feb 2007) | 1 line 0.96.D598 - Do not detect a Java anonymous class when the first non-skipped token after "new" is a closing brace. ........ r1843 | stevenknight | 2007-02-23 10:45:06 -0600 (Fri, 23 Feb 2007) | 1 line 0.96.D599 - Better [Errno 21] Is a directory error message. ........ r1844 | stevenknight | 2007-02-23 13:32:11 -0600 (Fri, 23 Feb 2007) | 1 line 0.96.D600 - Fix expansion of non-Node objects within a PathList (maximum recursion / unhashable type bug). ........ r1847 | stevenknight | 2007-03-02 00:12:27 -0600 (Fri, 02 Mar 2007) | 1 line 0.96.D601 - Generate SCons API documentation from the docstrings using epydoc. ........ r1848 | stevenknight | 2007-03-02 14:10:06 -0600 (Fri, 02 Mar 2007) | 1 line 0.96.D602 - Fix use of custom include and lib paths with Visual Studio 8. (Richard Viney) ........ r1849 | stevenknight | 2007-03-03 01:00:22 -0600 (Sat, 03 Mar 2007) | 1 line 0.96.D603 - Man page fix: ParseDepends(). User's Guide updates: NoCache(), Clean(), fix CPPDEFINES output, markers for to-be-documented features, white space clean-up. ........ r1850 | stevenknight | 2007-03-06 02:29:08 -0600 (Tue, 06 Mar 2007) | 1 line 0.96.D604 - Fix use of --debug=presub with the Actions for our out-of-the-box Builders. ........ r1851 | stevenknight | 2007-03-06 09:10:43 -0600 (Tue, 06 Mar 2007) | 1 line 0.96.D605 - User Guide updates: --random, AlwaysBuild(), --tree=, --debug=presub, --debug=stacktrace. ........ r1852 | stevenknight | 2007-03-06 15:38:06 -0600 (Tue, 06 Mar 2007) | 1 line 0.96.D606 - Have the Intel toolchain use the default smart linking logic. (Dmitry Grigorenko and Gary Oberbrunner) ........ r1853 | stevenknight | 2007-03-06 17:56:44 -0600 (Tue, 06 Mar 2007) | 1 line 0.96.D607 - Fix tests: ActionTests.py for presub change, command detection in test/Intel/icpc-link.py. ........ r1854 | stevenknight | 2007-03-08 09:35:25 -0600 (Thu, 08 Mar 2007) | 1 line 0.96.D608 - Better selection of .NET Framework SDK paths. (Richard Viney) ........ r1855 | stevenknight | 2007-03-08 10:34:37 -0600 (Thu, 08 Mar 2007) | 1 line 0.96.D609 - Don't re-run TeX if the triggering strings (\makeindex, \bibliography, \tableofcontents) are commented out. (Matthias Troffaes) ........ r1856 | stevenknight | 2007-03-09 16:18:36 -0600 (Fri, 09 Mar 2007) | 1 line 0.96.D610 - Teach the new PathList module to handle nested lists within CPPPATH and the like. ........ r1857 | stevenknight | 2007-03-10 23:30:29 -0600 (Sat, 10 Mar 2007) | 1 line 0.96.D611 - Qt builders_used failure. ........ r1858 | stevenknight | 2007-03-11 15:33:34 -0500 (Sun, 11 Mar 2007) | 1 line 0.96.D612 - Document limitations of --implicit-cache w.r.t. CPPPATH/LIBPATH/etc. ........ r1859 | stevenknight | 2007-03-11 21:11:26 -0500 (Sun, 11 Mar 2007) | 1 line 0.96.D613 - Document --debug=findlibs and --taskmastertrace in the User's Guide. ........ r1860 | stevenknight | 2007-03-12 13:28:42 -0500 (Mon, 12 Mar 2007) | 1 line 0.96.D614 - Remove deleted cons file from the User's Guide MANIFEST. Fix epydoc API build if the build directory is outside the current directory. ........ r1861 | stevenknight | 2007-03-13 13:03:56 -0500 (Tue, 13 Mar 2007) | 2 lines Ignore '*.pyc' files in the compat/ subdirectory. ........ r1862 | stevenknight | 2007-03-13 19:08:19 -0500 (Tue, 13 Mar 2007) | 1 line 0.96.D615 - Fix use of $VAR expansions within CPPPATH/LIBPATH values when the expansion is itself a Dir node concatenated with a string. ........ r1866 | stevenknight | 2007-03-16 01:46:10 -0500 (Fri, 16 Mar 2007) | 1 line 0.96.D616 - Back off to the 0.96.94 of Builder.py (with some performance improvements). ........ r1867 | stevenknight | 2007-03-16 11:20:39 -0500 (Fri, 16 Mar 2007) | 1 line 0.96.D617 - Fix an unnamed variable error if we can't map the Visual Studio version to a default framework version. ........ r1868 | stevenknight | 2007-03-16 12:08:18 -0500 (Fri, 16 Mar 2007) | 1 line 0.96.D618 - Quote the MSVS build target in command lines to handle spaces target name. (Jeff Mahovsky) ........ r1869 | stevenknight | 2007-03-16 13:30:06 -0500 (Fri, 16 Mar 2007) | 1 line 0.96.D619 - Portability fixes for tests run on Windows. ........ r1870 | stevenknight | 2007-03-20 00:18:04 -0500 (Tue, 20 Mar 2007) | 1 line 0.96.D620 - Windows portability fixes: test scripts and infrastructure, detect vcexpress.exe. ........ r1871 | garyo | 2007-03-21 18:32:54 -0500 (Wed, 21 Mar 2007) | 1 line Fix bug where site_scons dir was added to sys.path as relative, not absolute. Added test case. Bug reported by Timothy Woods; thanks for the test case! ........ r1872 | stevenknight | 2007-03-22 09:43:23 -0500 (Thu, 22 Mar 2007) | 1 line 0.96.D622 - Add mention of site_scons fix to src/CHANGES.txt. ........ r1873 | stevenknight | 2007-04-02 23:49:36 -0500 (Mon, 02 Apr 2007) | 1 line 0.96.D623 - Parallel build dependencies with multiple entries in children. (Adam Simpkins) ........ r1874 | stevenknight | 2007-04-04 07:45:05 -0500 (Wed, 04 Apr 2007) | 1 line 0.96.D624 - Make all necessary LaTeX auxiliary files Precious, so bibliography contents aren't affected by whether the auxiliary files exist or not. (Joel B. Mohler) ........ r1875 | stevenknight | 2007-04-04 13:15:39 -0500 (Wed, 04 Apr 2007) | 1 line 0.96.D625 - Fix --debug-time value when -j option is used. ........ r1876 | stevenknight | 2007-04-09 19:40:08 -0500 (Mon, 09 Apr 2007) | 1 line 0.96.D626 - Fix man page example of propagating external user environment. Eliminate cut-and-paste sentence in NoCache() description. (Helmut Grohne, Joe Bloggs) [Issue 1626] [Issue 1627] ........ r1877 | stevenknight | 2007-04-09 23:20:14 -0500 (Mon, 09 Apr 2007) | 1 line 0.96.D627 - Re-run latex after bibtex runs. (Rob Managan) ........ r1878 | stevenknight | 2007-04-11 23:38:17 -0500 (Wed, 11 Apr 2007) | 1 line 0.96.D628 - Fix typo in the User's Guide. [issue 1600] ........ r1879 | stevenknight | 2007-04-12 01:06:35 -0500 (Thu, 12 Apr 2007) | 1 line 0.96.D629 - Avoid name conflicts with compat/ modules (specifically _subprocess.py). ........ r1880 | stevenknight | 2007-04-12 01:33:42 -0500 (Thu, 12 Apr 2007) | 1 line 0.96.D630 - Portability fixes and other improvements in test scripts. ........ r1882 | stevenknight | 2007-04-13 16:42:02 -0500 (Fri, 13 Apr 2007) | 1 line 0.96.D631 - The scons command, branch 0.96.96. ........
Diffstat (limited to 'test/option')
-rw-r--r--test/option/debug-pdb.py41
-rw-r--r--test/option/debug-presub.py203
-rw-r--r--test/option/debug-time.py146
3 files changed, 333 insertions, 57 deletions
diff --git a/test/option/debug-pdb.py b/test/option/debug-pdb.py
new file mode 100644
index 0000000..fa703d5
--- /dev/null
+++ b/test/option/debug-pdb.py
@@ -0,0 +1,41 @@
+#!/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__"
+
+import string
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+env = Environment()
+""")
+
+test.run(arguments = "--debug=pdb", stdin = "n\ns\nq\n")
+test.fail_test(string.find(test.stdout(), "(Pdb)") == -1)
+test.fail_test(string.find(test.stdout(), "SCons") == -1)
+
+test.pass_test()
diff --git a/test/option/debug-presub.py b/test/option/debug-presub.py
new file mode 100644
index 0000000..cdbefbd
--- /dev/null
+++ b/test/option/debug-presub.py
@@ -0,0 +1,203 @@
+#!/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__"
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('cat.py', """\
+import sys
+open(sys.argv[2], "wb").write(open(sys.argv[1], "rb").read())
+sys.exit(0)
+""")
+
+test.write('SConstruct', """\
+def cat(env, source, target):
+ target = str(target[0])
+ source = map(str, source)
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(src, "rb").read())
+ f.close()
+FILE = Builder(action="$FILECOM")
+TEMP = Builder(action="$TEMPCOM")
+LIST = Builder(action="$LISTCOM")
+FUNC = Builder(action=cat)
+env = Environment(PYTHON=r'%(_python_)s',
+ BUILDERS = {'FILE':FILE, 'TEMP':TEMP, 'LIST':LIST, 'FUNC':FUNC},
+ FILECOM="$PYTHON cat.py $SOURCES $TARGET",
+ TEMPCOM="$PYTHON cat.py $SOURCES temp\\n$PYTHON cat.py temp $TARGET",
+ LISTCOM=["$PYTHON cat.py $SOURCES temp", "$PYTHON cat.py temp $TARGET"],
+ FUNCCOM=cat)
+env.Command('file01.out', 'file01.in', "$FILECOM")
+env.Command('file02.out', 'file02.in', ["$FILECOM"])
+env.Command('file03.out', 'file03.in', "$TEMPCOM")
+env.Command('file04.out', 'file04.in', ["$TEMPCOM"])
+env.Command('file05.out', 'file05.in', "$LISTCOM")
+env.Command('file06.out', 'file06.in', ["$LISTCOM"])
+env.Command('file07.out', 'file07.in', cat)
+env.Command('file08.out', 'file08.in', "$FUNCCOM")
+env.Command('file09.out', 'file09.in', ["$FUNCCOM"])
+env.FILE('file11.out', 'file11.in')
+env.FILE('file12.out', 'file12.in')
+env.TEMP('file13.out', 'file13.in')
+env.TEMP('file14.out', 'file14.in')
+env.LIST('file15.out', 'file15.in')
+env.LIST('file16.out', 'file16.in')
+env.FUNC('file17.out', 'file17.in')
+env.FUNC('file18.out', 'file18.in')
+
+env2 = Environment(PYTHON=r'%(_python_)s',
+ CCCOM="$PYTHON cat.py $SOURCES $TARGET")
+env2.Object('file20.obj', 'file20.c')
+""" % locals())
+
+test.write('file01.in', "file01.in\n")
+test.write('file02.in', "file02.in\n")
+test.write('file03.in', "file03.in\n")
+test.write('file04.in', "file04.in\n")
+test.write('file05.in', "file05.in\n")
+test.write('file06.in', "file06.in\n")
+test.write('file07.in', "file07.in\n")
+test.write('file08.in', "file08.in\n")
+test.write('file09.in', "file09.in\n")
+test.write('file11.in', "file11.in\n")
+test.write('file12.in', "file12.in\n")
+test.write('file13.in', "file13.in\n")
+test.write('file14.in', "file14.in\n")
+test.write('file15.in', "file15.in\n")
+test.write('file16.in', "file16.in\n")
+test.write('file17.in', "file17.in\n")
+test.write('file18.in', "file18.in\n")
+
+test.write('file20.c', "file20.c\n")
+
+expect = """\
+Building file01.out with action:
+ $PYTHON cat.py $SOURCES $TARGET
+%(_python_)s cat.py file01.in file01.out
+Building file02.out with action:
+ $PYTHON cat.py $SOURCES $TARGET
+%(_python_)s cat.py file02.in file02.out
+Building file03.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file03.in temp
+Building file03.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file03.out
+Building file04.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file04.in temp
+Building file04.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file04.out
+Building file05.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file05.in temp
+Building file05.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file05.out
+Building file06.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file06.in temp
+Building file06.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file06.out
+Building file07.out with action:
+ cat(target, source, env)
+cat(["file07.out"], ["file07.in"])
+Building file08.out with action:
+ cat(target, source, env)
+cat(["file08.out"], ["file08.in"])
+Building file09.out with action:
+ cat(target, source, env)
+cat(["file09.out"], ["file09.in"])
+Building file11.out with action:
+ $PYTHON cat.py $SOURCES $TARGET
+%(_python_)s cat.py file11.in file11.out
+Building file12.out with action:
+ $PYTHON cat.py $SOURCES $TARGET
+%(_python_)s cat.py file12.in file12.out
+Building file13.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file13.in temp
+Building file13.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file13.out
+Building file14.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file14.in temp
+Building file14.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file14.out
+Building file15.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file15.in temp
+Building file15.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file15.out
+Building file16.out with action:
+ $PYTHON cat.py $SOURCES temp
+%(_python_)s cat.py file16.in temp
+Building file16.out with action:
+ $PYTHON cat.py temp $TARGET
+%(_python_)s cat.py temp file16.out
+Building file17.out with action:
+ cat(target, source, env)
+cat(["file17.out"], ["file17.in"])
+Building file18.out with action:
+ cat(target, source, env)
+cat(["file18.out"], ["file18.in"])
+Building file20.obj with action:
+ $PYTHON cat.py $SOURCES $TARGET
+%(_python_)s cat.py file20.c file20.obj
+""" % locals()
+
+test.run(arguments = "--debug=presub .", stdout=test.wrap_stdout(expect))
+
+test.must_match('file01.out', "file01.in\n")
+test.must_match('file02.out', "file02.in\n")
+test.must_match('file03.out', "file03.in\n")
+test.must_match('file04.out', "file04.in\n")
+test.must_match('file05.out', "file05.in\n")
+test.must_match('file06.out', "file06.in\n")
+test.must_match('file07.out', "file07.in\n")
+test.must_match('file08.out', "file08.in\n")
+test.must_match('file09.out', "file09.in\n")
+test.must_match('file11.out', "file11.in\n")
+test.must_match('file12.out', "file12.in\n")
+test.must_match('file13.out', "file13.in\n")
+test.must_match('file14.out', "file14.in\n")
+test.must_match('file15.out', "file15.in\n")
+test.must_match('file16.out', "file16.in\n")
+test.must_match('file17.out', "file17.in\n")
+test.must_match('file18.out', "file18.in\n")
+
+test.must_match('file20.obj', "file20.c\n")
+
+test.pass_test()
diff --git a/test/option/debug-time.py b/test/option/debug-time.py
index b1471ba..51cfacf 100644
--- a/test/option/debug-time.py
+++ b/test/option/debug-time.py
@@ -30,49 +30,51 @@ import string
import re
import time
+_python_ = TestSCons._python_
+
test = TestSCons.TestSCons()
-test.write('SConstruct', """
-env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx')
-env.Program('foo', Split('foo.c bar.c'))
+test.write('sleep_cat.py', """\
+import sys
+import time
+time.sleep(int(sys.argv[1]))
+fp = open(sys.argv[2], 'wb')
+for arg in sys.argv[3:]:
+ fp.write(open(arg, 'rb').read())
+fp.close()
+sys.exit(0)
""")
-test.write('foo.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-#include "foo.h"
-int main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("f1.c\n");
- exit (0);
-}
-""")
+test.write('SConstruct', """
+env = Environment(PYTHON = r'%(_python_)s',
+ SLEEP_CAT = r'sleep_cat.py',
+ CATCOM = '$PYTHON $SLEEP_CAT $SECONDS $TARGET $SOURCES',
+ SECONDS = ARGUMENTS.get('SLEEP', '0'))
+f1 = env.Command('f1.out', 'f1.in', '$CATCOM')
+f2 = env.Command('f2.out', 'f2.in', '$CATCOM')
+f3 = env.Command('f3.out', 'f3.in', '$CATCOM')
+f4 = env.Command('f4.out', 'f4.in', '$CATCOM')
+env.Command('output', [f1, f2, f3, f4], '$CATCOM')
+""" % locals())
-test.write('bar.c', """
-#include "bar.h"
-""")
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write('f4.in', "f4.in\n")
-test.write('foo.h', """
-#ifndef FOO_H
-#define FOO_H
-#include "bar.h"
-#endif
-""")
-test.write('bar.h', """
-#ifndef BAR_H
-#define BAR_H
-#include "foo.h"
-#endif
-""")
-def num(match, line):
- return float(re.search(match, line).group(1))
+def num(s, match):
+ return float(re.search(match, s).group(1))
+
+def within_tolerance(expected, actual, tolerance):
+ return abs((expected-actual)/actual) <= tolerance
+
+
-# Try to make things a little more equal by measuring Python overhead
-# executing a minimal file, and reading the scons.py script itself from
-# disk so that it's already been cached.
+# Try to make our results a little more accurate and repeatable by
+# measuring Python overhead executing a minimal file, and reading the
+# scons.py script itself from disk so that it's already been cached.
test.write('pass.py', "pass\n")
test.read(test.program)
@@ -80,55 +82,85 @@ start_time = time.time()
test.run(program=TestSCons.python, arguments=test.workpath('pass.py'))
overhead = time.time() - start_time
+
+
start_time = time.time()
-test.run(arguments = "--debug=time .")
+test.run(arguments = "-j1 --debug=time . SLEEP=0")
complete_time = time.time() - start_time
+
+
expected_total_time = complete_time - overhead
-lines = string.split(test.stdout(), '\n')
-expected_command_time = 0.0
-for cmdline in filter(lambda x: x[:23] == "Command execution time:", lines):
- n = num(r'Command execution time: (\d+\.\d+) seconds', cmdline)
- expected_command_time = expected_command_time + n
+pattern = r'Command execution time: (\d+\.\d+) seconds'
+times = map(float, re.findall(pattern, test.stdout()))
+expected_command_time = reduce(lambda x, y: x + y, times, 0.0)
-stdout = test.stdout()
-total_time = num(r'Total build time: (\d+\.\d+) seconds', stdout)
-sconscript_time = num(r'Total SConscript file execution time: (\d+\.\d+) seconds', stdout)
-scons_time = num(r'Total SCons execution time: (\d+\.\d+) seconds', stdout)
-command_time = num(r'Total command execution time: (\d+\.\d+) seconds', stdout)
+stdout = test.stdout()
-def within_tolerance(expected, actual, tolerance):
- return abs((expected-actual)/actual) <= tolerance
+total_time = num(stdout, r'Total build time: (\d+\.\d+) seconds')
+sconscript_time = num(stdout, r'Total SConscript file execution time: (\d+\.\d+) seconds')
+scons_time = num(stdout, r'Total SCons execution time: (\d+\.\d+) seconds')
+command_time = num(stdout, r'Total command execution time: (\d+\.\d+) seconds')
failures = []
if not within_tolerance(expected_command_time, command_time, 0.01):
failures.append("""\
-SCons reported a total command execution time of %s,
-but command execution times really totalled %s,
+SCons -j1 reported a total command execution time of %(command_time)s,
+but command execution times really totalled %(expected_command_time)s,
outside of the 1%% tolerance.
-""" % (command_time, expected_command_time))
+""" % locals())
added_times = sconscript_time+scons_time+command_time
if not within_tolerance(total_time, added_times, 0.01):
failures.append("""\
-SCons reported a total build time of %s,
-but the various execution times actually totalled %s,
+SCons -j1 reported a total build time of %(total_time)s,
+but the various execution times actually totalled %(added_times)s,
outside of the 1%% tolerance.
-""" % (total_time, added_times))
+""" % locals())
if not within_tolerance(total_time, expected_total_time, 0.15):
failures.append("""\
-SCons reported total build time of %s,
-but the actual measured build time was %s
-(end-to-end time of %s less Python overhead of %s),
+SCons -j1 reported total build time of %(total_time)s,
+but the actual measured build time was %(expected_total_time)s
+(end-to-end time of %(complete_time)s less Python overhead of %(overhead)s),
outside of the 15%% tolerance.
-""" % (total_time, expected_total_time, complete_time, overhead))
+""" % locals())
if failures:
print string.join([test.stdout()] + failures, '\n')
test.fail_test(1)
+
+
+test.run(arguments = "-c")
+
+test.run(arguments = "-j4 --debug=time . SLEEP=1")
+
+
+
+stdout = test.stdout()
+
+total_time = num(stdout, r'Total build time: (\d+\.\d+) seconds')
+sconscript_time = num(stdout, r'Total SConscript file execution time: (\d+\.\d+) seconds')
+scons_time = num(stdout, r'Total SCons execution time: (\d+\.\d+) seconds')
+command_time = num(stdout, r'Total command execution time: (\d+\.\d+) seconds')
+
+failures = []
+
+added_times = sconscript_time+scons_time+command_time
+if not within_tolerance(total_time, added_times, 0.01):
+ failures.append("""\
+SCons -j4 reported a total build time of %(total_time)s,
+but the various execution times actually totalled %(added_times)s,
+outside of the 1%% tolerance.
+""" % locals())
+
+if failures:
+ print string.join([test.stdout()] + failures, '\n')
+ test.fail_test(1)
+
+
test.pass_test()