summaryrefslogtreecommitdiff
path: root/test/CacheDir
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2006-11-02 16:21:36 +0000
committerSteven Knight <knight@baldmt.com>2006-11-02 16:21:36 +0000
commit6ba3fe1e1af2743602a4d0c55513deecc7e16df0 (patch)
treeea835f8b96e6c67766b4c0e6437f363d76164d39 /test/CacheDir
parent217dbbf43c5e794373a561f6258f1c684a8ca448 (diff)
downloadscons-6ba3fe1e1af2743602a4d0c55513deecc7e16df0.tar.gz
Merged revisions 1582-1665 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1585 | stevenknight | 2006-08-06 21:21:12 -0500 (Sun, 06 Aug 2006) | 1 line 0.96.D430 - Fix bug with finding Fortran modules in build directories. (Nicolas Vigier) ........ r1586 | stevenknight | 2006-08-06 22:54:39 -0500 (Sun, 06 Aug 2006) | 1 line 0.96.D431 - Fix use of BuildDir when the source file is a relative-path symlink. (Nicola Vi ........ r1587 | timot | 2006-08-10 14:45:00 -0500 (Thu, 10 Aug 2006) | 1 line fix Platform SDK init ........ r1589 | stevenknight | 2006-08-12 13:28:51 -0500 (Sat, 12 Aug 2006) | 1 line 0.96.D432 - Change the default mingw linker from g++ to gcc. (Mariusz Olko) ........ r1590 | stevenknight | 2006-08-13 11:16:32 -0500 (Sun, 13 Aug 2006) | 1 line 0.96.D433 - More runtest.py enhancements. ........ r1594 | stevenknight | 2006-08-15 04:47:46 -0500 (Tue, 15 Aug 2006) | 1 line 0.96.D434 - Print the full path of SConscript files in stack traces. (Dobes Vandermeer) ........ r1600 | timot | 2006-08-16 11:34:44 -0500 (Wed, 16 Aug 2006) | 1 line add M4 to mingw tools ........ r1611 | stevenknight | 2006-08-19 16:25:24 -0500 (Sat, 19 Aug 2006) | 1 line 0.96.D435 - Add an SCons XMLResultStream to capture test results for mailing in. Get Aegis ........ r1617 | timot | 2006-08-21 16:19:03 -0500 (Mon, 21 Aug 2006) | 1 line handling of spawnve returning an error code that is not in exitvalmap ........ r1619 | stevenknight | 2006-09-01 19:07:47 -0500 (Fri, 01 Sep 2006) | 1 line 0.96.D436 - Win32 test portability and other test fixes. ........ r1620 | stevenknight | 2006-09-02 20:21:51 -0500 (Sat, 02 Sep 2006) | 2 lines Bring msvc.py in sync with Aegis repository. ........ r1621 | stevenknight | 2006-09-02 20:23:48 -0500 (Sat, 02 Sep 2006) | 2 lines Move to keep symlink tests together. ........ r1622 | garyo | 2006-09-06 11:51:42 -0500 (Wed, 06 Sep 2006) | 1 line Fix for Issue #1370; allow exit values not in exitvalmap. Added some tests for this kind of thing. Also improved win32 err msg if command exits with nonzero to show actual cmd, not just "cmd.exe". Note this fix improves posix and win32 behavior. ........ r1623 | stevenknight | 2006-09-07 06:35:16 -0500 (Thu, 07 Sep 2006) | 1 line 0.96.D440 - Fix runtest.py with QMTest on Windows. ........ r1625 | stevenknight | 2006-09-09 09:22:15 -0500 (Sat, 09 Sep 2006) | 3 lines Comment out a long-command test which fails on older Pythons (1.5.2) on Fedora Core 3. We can restore it in the future. ........ r1626 | stevenknight | 2006-09-09 16:17:44 -0500 (Sat, 09 Sep 2006) | 1 line 0.96.D441 - Allow Python Values to be the targets of Builders. (Anonymous) ........ r1627 | stevenknight | 2006-09-09 20:25:53 -0500 (Sat, 09 Sep 2006) | 1 line 0.96.D442 - Support src_dir on SConscript() calls. (Dobes Vandermeer) ........ r1628 | stevenknight | 2006-09-10 07:28:54 -0500 (Sun, 10 Sep 2006) | 1 line 0.96.D443 - Add miscellaneous utility scripts and config changes. ........ r1629 | stevenknight | 2006-09-11 04:45:01 -0500 (Mon, 11 Sep 2006) | 1 line 0.96.D444 - Add a test case for BuildDir handling of nested SConscript files. (Adam Simpkin ........ r1630 | stevenknight | 2006-09-11 11:34:07 -0500 (Mon, 11 Sep 2006) | 1 line 0.96.D445 - Workaround bug in early versions of thePython 2.4 profiler. ........ r1631 | stevenknight | 2006-09-19 19:12:51 -0500 (Tue, 19 Sep 2006) | 1 line 0.96.D446 - Fix Visual Studio common prefix handling to only treat common prefixes on comple ........ r1632 | stevenknight | 2006-09-25 07:11:44 -0500 (Mon, 25 Sep 2006) | 1 line 0.96.D447 - Fix tests that fail due to warnings from (some versions?) of gcc. (Sohail Soman ........ r1633 | stevenknight | 2006-09-25 07:57:48 -0500 (Mon, 25 Sep 2006) | 1 line 0.96.D448 - Handle python paths with quotes in tests. ........ r1634 | stevenknight | 2006-09-25 14:38:07 -0500 (Mon, 25 Sep 2006) | 1 line 0.96.D449 - Fix SCons build when python is not in the path (e.g. on Windows). (Chad Austin) ........ r1635 | stevenknight | 2006-09-26 11:28:23 -0500 (Tue, 26 Sep 2006) | 1 line 0.96.D450 - Handle warnings from Python 2.1; make sure we still test on Python 1.5. ........ r1636 | stevenknight | 2006-09-27 05:34:23 -0500 (Wed, 27 Sep 2006) | 1 line 0.96.D451 - Avoid calling Options validators and converters twice. ........ r1637 | stevenknight | 2006-09-28 08:12:38 -0500 (Thu, 28 Sep 2006) | 1 line 0.96.D452 - Allow setting MSVS_VERSION after initialization to select the Visual Studio vers ........ r1638 | stevenknight | 2006-09-30 08:38:15 -0500 (Sat, 30 Sep 2006) | 1 line 0.96.D453 - Give the MSVC resource builder a src_builder list and .rc src_suffix. (Leanid N ........ r1639 | stevenknight | 2006-10-12 08:50:58 -0500 (Thu, 12 Oct 2006) | 1 line 0.96.D454 - Test handling of env.Append() and env.Prepend(), making sure it works on later P ........ r1640 | stevenknight | 2006-10-15 20:42:09 -0500 (Sun, 15 Oct 2006) | 1 line 0.96.D455 - Support the runtest.py -f option when using QMTest. ........ r1641 | stevenknight | 2006-10-15 21:20:02 -0500 (Sun, 15 Oct 2006) | 1 line 0.96.D456 - Fix an error in ListOption handling caused by making new copies of Options objec ........ r1642 | stevenknight | 2006-10-16 05:53:14 -0500 (Mon, 16 Oct 2006) | 1 line 0.96.D457 - Fix new Append()/Prepend() handling of dictionaries in later Python versions (2. ........ r1643 | stevenknight | 2006-10-16 07:13:16 -0500 (Mon, 16 Oct 2006) | 1 line 0.96.D458 - Allow Install() to handle directories as sources. (Matthew A. Nicholson) ........ r1644 | stevenknight | 2006-10-17 09:17:58 -0500 (Tue, 17 Oct 2006) | 1 line 0.96.D459 - Add a test to make sure SideEffect() doesn't interfere with CacheDir(). Refacto ........ r1645 | stevenknight | 2006-10-17 10:20:22 -0500 (Tue, 17 Oct 2006) | 1 line 0.96.D460 - Do not use -fPIC when using gcc on win32 (MinGW). (Jan Nijtmans) ........ r1646 | stevenknight | 2006-10-17 17:21:58 -0500 (Tue, 17 Oct 2006) | 6 lines Move all the scons.org stuff from the scons source tree itself to a directory next to the trunk, and delete the copies from the branches. There's a lot of stuff there (what with all of the documentation of the different versions) and it's ridiculous to make everyone sync it just to work on the code. ........ r1647 | stevenknight | 2006-10-17 23:18:29 -0500 (Tue, 17 Oct 2006) | 1 line 0.96.D461 - Fix the tests of runtest.py so they skip appropriately if qmtest.py isn't instal ........ r1648 | stevenknight | 2006-10-18 08:48:47 -0500 (Wed, 18 Oct 2006) | 1 line 0.96.D462 - When using --implicit-cache, do not re-scan files if the scanner returned no imp ........ r1649 | stevenknight | 2006-10-18 19:42:13 -0500 (Wed, 18 Oct 2006) | 1 line 0.96.D463 - More test portability fixes. ........ r1650 | stevenknight | 2006-10-19 00:30:23 -0500 (Thu, 19 Oct 2006) | 1 line 0.96.D464 - Add a cpp.py module that knows how to find dependencies from #include lines like ........ r1651 | stevenknight | 2006-10-20 06:49:51 -0500 (Fri, 20 Oct 2006) | 1 line 0.96.D465 - Fix unresolved variable name in win32 portion of test. ........ r1652 | stevenknight | 2006-10-23 00:20:38 -0500 (Mon, 23 Oct 2006) | 1 line 0.96.D466 - Add an option for tracing files to and from the CacheDir. ........ r1653 | stevenknight | 2006-10-23 00:29:32 -0500 (Mon, 23 Oct 2006) | 1 line 0.96.D467 - Make {Append,Prepend}Unique() handle adding elements to empty lists like {Append ........ r1654 | stevenknight | 2006-10-23 02:38:06 -0500 (Mon, 23 Oct 2006) | 1 line 0.96.D468 - Allow Debug.caller() to take multiple arguments; add a debug utility to post-pro ........ r1655 | stevenknight | 2006-10-23 03:16:42 -0500 (Mon, 23 Oct 2006) | 1 line 0.96.D469 - Reduce unnecessary calls to Node.FS.disambiguate(), undoing (?) a performance hi ........ r1656 | stevenknight | 2006-10-25 00:06:27 -0500 (Wed, 25 Oct 2006) | 1 line 0.96.D470 - More test portability fixes. ........ r1657 | stevenknight | 2006-10-25 00:16:22 -0500 (Wed, 25 Oct 2006) | 1 line 0.96.D471 - Have runtest.py fall back to the --noqmtest option (with a warning) if qmtest.py ........ r1658 | stevenknight | 2006-10-25 12:12:02 -0500 (Wed, 25 Oct 2006) | 1 line 0.96.D472 - Document the default use of the /Z7 flag for Visual Studio and ways to use /Zi. ........ r1659 | stevenknight | 2006-10-26 23:53:51 -0500 (Thu, 26 Oct 2006) | 1 line 0.96.D473 - Have runtest.py -d accomodate different Python library locations. ........ r1660 | stevenknight | 2006-10-27 00:03:59 -0500 (Fri, 27 Oct 2006) | 1 line 0.96.D474 - Patch to support running SCons under WingIDE. (Allen Bierbaum) ........ r1661 | stevenknight | 2006-10-27 12:17:27 -0500 (Fri, 27 Oct 2006) | 1 line 0.96.D475 - Restore execution of all Environment unit tests. ........ r1662 | stevenknight | 2006-10-31 23:22:58 -0600 (Tue, 31 Oct 2006) | 1 line 0.96.D476 - Eliminate unnecessary print from a test, left over from debugging. ........ r1663 | stevenknight | 2006-10-31 23:32:00 -0600 (Tue, 31 Oct 2006) | 1 line 0.96.D477 - Support creating shared object files from assembly language. (James Y. Knight) ........ r1664 | stevenknight | 2006-10-31 23:44:08 -0600 (Tue, 31 Oct 2006) | 1 line 0.96.D478 - Fix the Memoizer to deal with a compiled .pyo or .pyc file that's in a different ........ r1665 | stevenknight | 2006-11-01 21:59:18 -0600 (Wed, 01 Nov 2006) | 1 line 0.96.D479 - Put back the scons-{LICENSE,README} files in the scons-loacal package; add tests ........
Diffstat (limited to 'test/CacheDir')
-rw-r--r--test/CacheDir/BuildDir.py153
-rw-r--r--test/CacheDir/CacheDir.py157
-rw-r--r--test/CacheDir/SideEffect.py107
-rw-r--r--test/CacheDir/debug.py177
-rw-r--r--test/CacheDir/multi-targets.py70
-rw-r--r--test/CacheDir/source-scanner.py84
6 files changed, 748 insertions, 0 deletions
diff --git a/test/CacheDir/BuildDir.py b/test/CacheDir/BuildDir.py
new file mode 100644
index 00000000..d03bfa63
--- /dev/null
+++ b/test/CacheDir/BuildDir.py
@@ -0,0 +1,153 @@
+#!/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__"
+
+"""
+Test retrieving derived files from a CacheDir when a BuildDir is used.
+"""
+
+import os.path
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('cache', 'src')
+
+cache = test.workpath('cache')
+cat_out = test.workpath('cat.out')
+
+test.write(['src', 'SConstruct'], """\
+CacheDir(r'%(cache)s')
+SConscript('SConscript')
+""" % locals())
+
+test.write(['src', 'SConscript'], """\
+def cat(env, source, target):
+ target = str(target[0])
+ open('cat.out', 'ab').write(target + "\\n")
+ source = map(str, source)
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(src, "rb").read())
+ f.close()
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat('aaa.out', 'aaa.in')
+env.Cat('bbb.out', 'bbb.in')
+env.Cat('ccc.out', 'ccc.in')
+env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
+""")
+
+build_aaa_out = os.path.join('build', 'aaa.out')
+build_bbb_out = os.path.join('build', 'bbb.out')
+build_ccc_out = os.path.join('build', 'ccc.out')
+build_all = os.path.join('build', 'all')
+
+test.write(['src', 'aaa.in'], "aaa.in\n")
+test.write(['src', 'bbb.in'], "bbb.in\n")
+test.write(['src', 'ccc.in'], "ccc.in\n")
+
+#
+test.write('SConstruct', """\
+env = Environment(TWO = '2')
+env.CacheDir(r'%s')
+BuildDir('build', 'src', duplicate=0)
+SConscript('build/SConscript')
+""" % test.workpath('cache${TWO}'))
+
+# Verify that a normal build works correctly, and clean up.
+# This should populate the cache with our derived files.
+test.run()
+
+test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n")
+test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all))
+
+test.up_to_date(arguments = '.')
+
+test.run(arguments = '-c .')
+test.unlink('cat.out')
+
+# Verify that we now retrieve the derived files from cache,
+# not rebuild them. Then clean up.
+test.run(stdout = test.wrap_stdout("""\
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all)))
+
+test.must_not_exist(cat_out)
+
+test.up_to_date(arguments = '.')
+
+test.run(arguments = '-c .')
+
+# Verify that rebuilding with -n reports that everything was retrieved
+# from the cache, but that nothing really was.
+test.run(arguments = '-n .', stdout = test.wrap_stdout("""\
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+Retrieved `%s' from cache
+""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all)))
+
+test.must_not_exist(test.workpath('build', 'aaa.out'))
+test.must_not_exist(test.workpath('build', 'bbb.out'))
+test.must_not_exist(test.workpath('build', 'ccc.out'))
+test.must_not_exist(test.workpath('build', 'all'))
+
+# Verify that rebuilding with -s retrieves everything from the cache
+# even though it doesn't report anything.
+test.run(arguments = '-s .', stdout = "")
+
+test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n")
+test.must_not_exist(cat_out)
+
+test.up_to_date(arguments = '.')
+
+test.run(arguments = '-c .')
+
+# Verify that updating one input file builds its derived file and
+# dependency but that the other files are retrieved from cache.
+test.write(['src', 'bbb.in'], "bbb.in 2\n")
+
+test.run(stdout = test.wrap_stdout("""\
+Retrieved `%s' from cache
+cat(["%s"], ["%s"])
+Retrieved `%s' from cache
+cat(["%s"], ["%s", "%s", "%s"])
+""" % (build_aaa_out,
+ build_bbb_out, os.path.join('src', 'bbb.in'),
+ build_ccc_out,
+ build_all, build_aaa_out, build_bbb_out, build_ccc_out)))
+
+test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n")
+test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all))
+
+test.up_to_date(arguments = '.')
+
+
+
+test.pass_test()
diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py
new file mode 100644
index 00000000..f918707f
--- /dev/null
+++ b/test/CacheDir/CacheDir.py
@@ -0,0 +1,157 @@
+#!/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__"
+
+"""
+Test retrieving derived files from a CacheDir.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+cache = test.workpath('cache')
+
+src_aaa_out = test.workpath('src', 'aaa.out')
+src_bbb_out = test.workpath('src', 'bbb.out')
+src_ccc_out = test.workpath('src', 'ccc.out')
+src_cat_out = test.workpath('src', 'cat.out')
+src_all = test.workpath('src', 'all')
+
+test.subdir('cache', 'src')
+
+test.write(['src', 'SConstruct'], """\
+CacheDir(r'%(cache)s')
+SConscript('SConscript')
+""" % locals())
+
+test.write(['src', 'SConscript'], """\
+def cat(env, source, target):
+ target = str(target[0])
+ open('cat.out', 'ab').write(target + "\\n")
+ source = map(str, source)
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(src, "rb").read())
+ f.close()
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat('aaa.out', 'aaa.in')
+env.Cat('bbb.out', 'bbb.in')
+env.Cat('ccc.out', 'ccc.in')
+env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
+""")
+
+test.write(['src', 'aaa.in'], "aaa.in\n")
+test.write(['src', 'bbb.in'], "bbb.in\n")
+test.write(['src', 'ccc.in'], "ccc.in\n")
+
+# Verify that building with -n and an empty cache reports that proper
+# build operations would be taken, but that nothing is actually built
+# and that the cache is still empty.
+test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\
+cat(["aaa.out"], ["aaa.in"])
+cat(["bbb.out"], ["bbb.in"])
+cat(["ccc.out"], ["ccc.in"])
+cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
+"""))
+
+test.must_not_exist(src_aaa_out)
+test.must_not_exist(src_bbb_out)
+test.must_not_exist(src_ccc_out)
+test.must_not_exist(src_all)
+test.fail_test(len(os.listdir(cache)))
+
+# Verify that a normal build works correctly, and clean up.
+# This should populate the cache with our derived files.
+test.run(chdir = 'src', arguments = '.')
+
+test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
+test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n")
+
+test.up_to_date(chdir = 'src', arguments = '.')
+
+test.run(chdir = 'src', arguments = '-c .')
+test.unlink(['src', 'cat.out'])
+
+# Verify that we now retrieve the derived files from cache,
+# not rebuild them. Then clean up.
+test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
+Retrieved `aaa.out' from cache
+Retrieved `bbb.out' from cache
+Retrieved `ccc.out' from cache
+Retrieved `all' from cache
+"""))
+
+test.must_not_exist(src_cat_out)
+
+test.up_to_date(chdir = 'src', arguments = '.')
+
+test.run(chdir = 'src', arguments = '-c .')
+
+# Verify that rebuilding with -n reports that everything was retrieved
+# from the cache, but that nothing really was.
+test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\
+Retrieved `aaa.out' from cache
+Retrieved `bbb.out' from cache
+Retrieved `ccc.out' from cache
+Retrieved `all' from cache
+"""))
+
+test.must_not_exist(src_aaa_out)
+test.must_not_exist(src_bbb_out)
+test.must_not_exist(src_ccc_out)
+test.must_not_exist(src_all)
+
+# Verify that rebuilding with -s retrieves everything from the cache
+# even though it doesn't report anything.
+test.run(chdir = 'src', arguments = '-s .', stdout = "")
+
+test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n")
+test.must_not_exist(src_cat_out)
+
+test.up_to_date(chdir = 'src', arguments = '.')
+
+test.run(chdir = 'src', arguments = '-c .')
+
+# Verify that updating one input file builds its derived file and
+# dependency but that the other files are retrieved from cache.
+test.write(['src', 'bbb.in'], "bbb.in 2\n")
+
+test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\
+Retrieved `aaa.out' from cache
+cat(["bbb.out"], ["bbb.in"])
+Retrieved `ccc.out' from cache
+cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
+"""))
+
+test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n")
+test.must_match(['src', 'cat.out'], "bbb.out\nall\n")
+
+test.up_to_date(chdir = 'src', arguments = '.')
+
+
+test.pass_test()
diff --git a/test/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py
new file mode 100644
index 00000000..814a5e37
--- /dev/null
+++ b/test/CacheDir/SideEffect.py
@@ -0,0 +1,107 @@
+#!/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__"
+
+"""
+Test that use of SideEffect() doesn't interfere with CacheDir.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('cache', 'work')
+
+cache = test.workpath('cache')
+
+test.write(['work', 'SConstruct'], """\
+def copy(source, target):
+ open(target, "wb").write(open(source, "rb").read())
+
+def build(env, source, target):
+ s = str(source[0])
+ t = str(target[0])
+ copy(s, t)
+ if target[0].side_effects:
+ side_effect = open(str(target[0].side_effects[0]), "ab")
+ side_effect.write(s + ' -> ' + t + '\\n')
+
+CacheDir(r'%(cache)s')
+
+Build = Builder(action=build)
+env = Environment(BUILDERS={'Build':Build}, SUBDIR='subdir')
+env.Build('f1.out', 'f1.in')
+env.Build('f2.out', 'f2.in')
+env.Build('f3.out', 'f3.in')
+SideEffect('log.txt', ['f1.out', 'f2.out', 'f3.out'])
+""" % locals())
+
+test.write(['work', 'f1.in'], 'f1.in\n')
+test.write(['work', 'f2.in'], 'f2.in\n')
+test.write(['work', 'f3.in'], 'f3.in\n')
+
+test.run(chdir='work', arguments='f1.out f2.out')
+
+expect = """\
+f1.in -> f1.out
+f2.in -> f2.out
+"""
+
+test.must_match(['work', 'log.txt'], expect)
+
+
+
+test.write(['work', 'f2.in'], 'f2.in 2 \n')
+
+test.run(chdir='work', arguments='log.txt')
+
+expect = """\
+f1.in -> f1.out
+f2.in -> f2.out
+f2.in -> f2.out
+f3.in -> f3.out
+"""
+
+test.must_match(['work', 'log.txt'], expect)
+
+
+
+test.write(['work', 'f1.in'], 'f1.in 2 \n')
+
+test.run(chdir='work', arguments=".")
+
+expect = """\
+f1.in -> f1.out
+f2.in -> f2.out
+f2.in -> f2.out
+f3.in -> f3.out
+f1.in -> f1.out
+"""
+
+test.must_match(['work', 'log.txt'], expect)
+
+
+
+test.pass_test()
diff --git a/test/CacheDir/debug.py b/test/CacheDir/debug.py
new file mode 100644
index 00000000..ebf67f71
--- /dev/null
+++ b/test/CacheDir/debug.py
@@ -0,0 +1,177 @@
+#!/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__"
+
+"""
+Test the --cache-debug option to see if it prints the expected messages.
+
+Note that we don't check for the "race condition" message when someone
+else's build populates the CacheDir with a file in between the time we
+to build it because it doesn't exist in the CacheDir, and the time our
+build of the file completes and we push it out.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons(match=TestSCons.match_re)
+
+test.subdir('cache', 'src')
+
+cache = test.workpath('cache')
+debug_out = test.workpath('cache-debug.out')
+
+
+
+test.write(['src', 'SConstruct'], """\
+CacheDir(r'%(cache)s')
+SConscript('SConscript')
+""" % locals())
+
+test.write(['src', 'SConscript'], """\
+def cat(env, source, target):
+ target = str(target[0])
+ open('cat.out', 'ab').write(target + "\\n")
+ source = map(str, source)
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(src, "rb").read())
+ f.close()
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat('aaa.out', 'aaa.in')
+env.Cat('bbb.out', 'bbb.in')
+env.Cat('ccc.out', 'ccc.in')
+env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
+""")
+
+test.write(['src', 'aaa.in'], "aaa.in\n")
+test.write(['src', 'bbb.in'], "bbb.in\n")
+test.write(['src', 'ccc.in'], "ccc.in\n")
+
+
+
+# Test for messages about files not being in CacheDir, with -n (don't
+# actually build or push) and sendinig the message to a file.
+
+expect = \
+r"""cat\(\["aaa.out"\], \["aaa.in"\]\)
+cat\(\["bbb.out"\], \["bbb.in"\]\)
+cat\(\["ccc.out"\], \["ccc.in"\]\)
+cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\)
+"""
+
+test.run(chdir='src',
+ arguments='-n -Q --cache-debug=%s .' % debug_out,
+ stdout=expect)
+
+expect = \
+r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache
+CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache
+CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache
+CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache
+"""
+
+test.must_match(debug_out, expect, mode='r')
+
+
+
+# Test for messages about actually pushing to the cache, without -n
+# and to standard ouput.
+
+expect = \
+r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache
+cat\(\["aaa.out"\], \["aaa.in"\]\)
+CachePush\(aaa.out\): pushing to [0-9a-fA-F]+
+CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache
+cat\(\["bbb.out"\], \["bbb.in"\]\)
+CachePush\(bbb.out\): pushing to [0-9a-fA-F]+
+CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache
+cat\(\["ccc.out"\], \["ccc.in"\]\)
+CachePush\(ccc.out\): pushing to [0-9a-fA-F]+
+CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache
+cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\)
+CachePush\(all\): pushing to [0-9a-fA-F]+
+"""
+
+test.run(chdir='src',
+ arguments='-Q --cache-debug=- .',
+ stdout=expect)
+
+
+
+# Clean up the local targets.
+
+test.run(chdir='src', arguments='-c --cache-debug=%s .' % debug_out)
+test.unlink(['src', 'cat.out'])
+
+
+
+# Test for messages about retrieving files from CacheDir, with -n
+# and sending the messages to standard output.
+
+expect = \
+r"""Retrieved `aaa.out' from cache
+CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+
+Retrieved `bbb.out' from cache
+CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+
+Retrieved `ccc.out' from cache
+CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+
+Retrieved `all' from cache
+CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+
+"""
+
+test.run(chdir='src',
+ arguments='-n -Q --cache-debug=- .',
+ stdout=expect)
+
+
+
+# And finally test for message about retrieving file from CacheDir
+# *without* -n and sending the message to a file.
+
+expect = \
+r"""Retrieved `aaa.out' from cache
+Retrieved `bbb.out' from cache
+Retrieved `ccc.out' from cache
+Retrieved `all' from cache
+"""
+
+test.run(chdir='src',
+ arguments='-Q --cache-debug=%s .' % debug_out,
+ stdout=expect)
+
+expect = \
+r"""CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+
+CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+
+CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+
+CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+
+"""
+
+test.must_match(debug_out, expect, mode='r')
+
+
+
+test.pass_test()
diff --git a/test/CacheDir/multi-targets.py b/test/CacheDir/multi-targets.py
new file mode 100644
index 00000000..0de03313
--- /dev/null
+++ b/test/CacheDir/multi-targets.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__"
+
+"""
+Test that multiple target files get retrieved from a CacheDir correctly.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('cache', 'multiple')
+
+cache = test.workpath('cache')
+
+multiple_bar = test.workpath('multiple', 'bar')
+multiple_foo = test.workpath('multiple', 'foo')
+
+test.write(['multiple', 'SConstruct'], """\
+def touch(env, source, target):
+ open('foo', 'w').write("")
+ open('bar', 'w').write("")
+CacheDir(r'%(cache)s')
+env = Environment()
+env.Command(['foo', 'bar'], ['input'], touch)
+""" % locals())
+
+test.write(['multiple', 'input'], "multiple/input\n")
+
+test.run(chdir = 'multiple')
+
+test.must_exist(multiple_foo)
+test.must_exist(multiple_bar)
+
+test.run(chdir = 'multiple', arguments = '-c')
+
+test.must_not_exist(multiple_foo)
+test.must_not_exist(multiple_bar)
+
+test.run(chdir = 'multiple')
+
+test.must_exist(multiple_foo)
+test.must_exist(multiple_bar)
+
+
+
+test.pass_test()
diff --git a/test/CacheDir/source-scanner.py b/test/CacheDir/source-scanner.py
new file mode 100644
index 00000000..119a959d
--- /dev/null
+++ b/test/CacheDir/source-scanner.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__"
+
+"""
+Test retrieving derived files from a CacheDir.
+
+This tests the case reported by Jeff Petkau (SourceForge bug #694744)
+where a target is source for another target with a scanner, which used
+to cause us to push the file to the CacheDir after the build signature
+had already been cleared (as a sign that the built file should now
+be rescanned).
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+cache = test.workpath('cache')
+
+test.subdir('cache', 'subdir')
+
+test.write(['subdir', 'SConstruct'], """\
+import SCons
+
+CacheDir(r'%(cache)s')
+
+def docopy(target,source,env):
+ data = source[0].get_contents()
+ f = open(target[0].rfile().get_abspath(), "wb")
+ f.write(data)
+ f.close()
+
+def sillyScanner(node, env, dirs):
+ print 'This is never called (unless we build file.out)'
+ return []
+
+SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res'])
+
+env = Environment(tools=[],
+ SCANNERS = [SillyScanner],
+ BUILDERS = {})
+
+r = env.Command('file.res', 'file.ma', docopy)
+
+env.Command('file.out', r, docopy)
+
+# make r the default. Note that we don't even try to build file.out,
+# and so SillyScanner never runs. The bug is the same if we build
+# file.out, though.
+Default(r)
+""" % locals())
+
+test.write(['subdir', 'file.ma'], "subdir/file.ma\n")
+
+test.run(chdir = 'subdir')
+
+test.must_not_exist(test.workpath(cache, 'N', 'None'))
+
+
+
+test.pass_test()