summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-05-24 11:11:51 (GMT)
committerSteven Knight <knight@baldmt.com>2004-05-24 11:11:51 (GMT)
commit86e13b6f44ca46079fb23ede280ec3e682f2eb1d (patch)
treeb08bde980825dcc5889aa7bef7190785203280ba
parenta29a5edcad30b950b1a1a7cb621065ba05adccb1 (diff)
downloadSCons-86e13b6f44ca46079fb23ede280ec3e682f2eb1d.zip
SCons-86e13b6f44ca46079fb23ede280ec3e682f2eb1d.tar.gz
SCons-86e13b6f44ca46079fb23ede280ec3e682f2eb1d.tar.bz2
Fix use of --debug=explain with SConsignFile(). (Chad Austin)
-rw-r--r--src/engine/SCons/Node/__init__.py6
-rw-r--r--test/explain.py217
2 files changed, 129 insertions, 94 deletions
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 75b3a6d..66e1420 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -836,7 +836,11 @@ class Node:
result[k] = s
return result
- osig = dictify(old.bkids, old.bkidsigs)
+ try:
+ osig = dictify(old.bkids, old.bkidsigs)
+ except AttributeError:
+ return "Cannot explain why `%s' is being rebuilt: No previous build information found\n" % self
+
newkids = map(str, self.binfo.bkids)
nsig = dictify(newkids, self.binfo.bkidsigs)
diff --git a/test/explain.py b/test/explain.py
index d46d410..e3f80e4 100644
--- a/test/explain.py
+++ b/test/explain.py
@@ -28,6 +28,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
Test the --debug=explain option.
"""
+import os.path
+import string
import sys
import TestSCons
@@ -35,9 +37,14 @@ python = TestSCons.python
test = TestSCons.TestSCons()
-test.subdir('src')
+test.subdir('work1', ['work1', 'src'], ['work1', 'src', 'subdir'],
+ 'work2', ['work2', 'src'], ['work2', 'src', 'subdir'])
-test.write(['src', 'cat.py'], r"""
+subdir_file6 = os.path.join('subdir', 'file6')
+subdir_file6_in = os.path.join('subdir', 'file6.in')
+cat_py = test.workpath('cat.py')
+
+test.write(cat_py, r"""
import sys
def process(outfp, infp):
@@ -62,7 +69,7 @@ for f in sys.argv[2:]:
sys.exit(0)
""")
-test.write(['src', 'SConstruct'], """
+SConstruct_contents = """\
import re
include_re = re.compile(r'^include\s+(\S+)$', re.M)
@@ -77,7 +84,7 @@ kscan = Scanner(name = 'kfile',
argument = None,
skeys = ['.k'])
-cat = Builder(action = r"%s cat.py $TARGET $SOURCES")
+cat = Builder(action = r"%s %s $TARGET $SOURCES")
env = Environment()
env.Append(BUILDERS = {'Cat':cat},
@@ -89,62 +96,68 @@ env.Install('../inc', 'aaa')
env.InstallAs('../inc/bbb.k', 'bbb.k')
env.Install('../inc', 'ddd')
env.InstallAs('../inc/eee', 'eee.in')
-""" % (python,))
+""" % (python, cat_py)
+
+args = '--debug=explain .'
-test.write(['src', 'SConscript'], """\
+#
+test.write(['work1', 'src', 'SConstruct'], SConstruct_contents)
+
+test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file1', 'file1.in')
env.Cat('file2', 'file2.k')
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
-env.Command('file4', 'file4.in', r"%s cat.py $TARGET - $SOURCES")
+env.Command('file4', 'file4.in', r"%s %s $TARGET - $SOURCES")
env.Cat('file5', 'file5.k')
-""" % (python,))
+env.Cat('subdir/file6', 'subdir/file6.in')
+""" % (python, cat_py))
-test.write(['src', 'aaa'], "aaa 1\n")
-test.write(['src', 'bbb.k'], """\
+test.write(['work1', 'src', 'aaa'], "aaa 1\n")
+test.write(['work1', 'src', 'bbb.k'], """\
bbb.k 1
include ccc
include ../inc/ddd
include ../inc/eee
""")
-test.write(['src', 'ccc'], "ccc 1\n")
-test.write(['src', 'ddd'], "ddd 1\n")
-test.write(['src', 'eee.in'], "eee.in 1\n")
+test.write(['work1', 'src', 'ccc'], "ccc 1\n")
+test.write(['work1', 'src', 'ddd'], "ddd 1\n")
+test.write(['work1', 'src', 'eee.in'], "eee.in 1\n")
-test.write(['src', 'file1.in'], "file1.in 1\n")
+test.write(['work1', 'src', 'file1.in'], "file1.in 1\n")
-test.write(['src', 'file2.k'], """\
+test.write(['work1', 'src', 'file2.k'], """\
file2.k 1 line 1
include xxx
include yyy
file2.k 1 line 4
""")
-test.write(['src', 'file4.in'], "file4.in 1\n")
+test.write(['work1', 'src', 'file4.in'], "file4.in 1\n")
-test.write(['src', 'xxx'], "xxx 1\n")
-test.write(['src', 'yyy'], "yyy 1\n")
-test.write(['src', 'zzz'], "zzz 1\n")
+test.write(['work1', 'src', 'xxx'], "xxx 1\n")
+test.write(['work1', 'src', 'yyy'], "yyy 1\n")
+test.write(['work1', 'src', 'zzz'], "zzz 1\n")
-test.write(['src', 'file5.k'], """\
+test.write(['work1', 'src', 'file5.k'], """\
file5.k 1 line 1
include ../inc/aaa
include ../inc/bbb.k
file5.k 1 line 4
""")
-args = '--debug=explain .'
+test.write(['work1', 'src', 'subdir', 'file6.in'], "subdir/file6.in 1\n")
#
-test.run(chdir='src', arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
scons: building `file1' because it doesn't exist
-%s cat.py file1 file1.in
+%s %s file1 file1.in
scons: building `file2' because it doesn't exist
-%s cat.py file2 file2.k
+%s %s file2 file2.k
scons: building `file3' because it doesn't exist
-%s cat.py file3 xxx yyy zzz
+%s %s file3 xxx yyy zzz
scons: building `file4' because it doesn't exist
-%s cat.py file4 - file4.in
+%s %s file4 - file4.in
scons: building `%s' because it doesn't exist
Install file: "aaa" as "%s"
scons: building `%s' because it doesn't exist
@@ -154,31 +167,35 @@ Install file: "eee.in" as "%s"
scons: building `%s' because it doesn't exist
Install file: "bbb.k" as "%s"
scons: building `file5' because it doesn't exist
-%s cat.py file5 file5.k
-""" % (python,
- python,
- python,
- python,
- test.workpath('inc', 'aaa'),
- test.workpath('inc', 'aaa'),
- test.workpath('inc', 'ddd'),
- test.workpath('inc', 'ddd'),
- test.workpath('inc', 'eee'),
- test.workpath('inc', 'eee'),
- test.workpath('inc', 'bbb.k'),
- test.workpath('inc', 'bbb.k'),
- python,)))
-
-test.must_match(['src', 'file1'], "file1.in 1\n")
-test.must_match(['src', 'file2'], """\
+%s %s file5 file5.k
+scons: building `%s' because it doesn't exist
+%s %s %s %s
+""" % (python, cat_py,
+ python, cat_py,
+ python, cat_py,
+ python, cat_py,
+ test.workpath('work1', 'inc', 'aaa'),
+ test.workpath('work1', 'inc', 'aaa'),
+ test.workpath('work1', 'inc', 'ddd'),
+ test.workpath('work1', 'inc', 'ddd'),
+ test.workpath('work1', 'inc', 'eee'),
+ test.workpath('work1', 'inc', 'eee'),
+ test.workpath('work1', 'inc', 'bbb.k'),
+ test.workpath('work1', 'inc', 'bbb.k'),
+ python, cat_py,
+ subdir_file6,
+ python, cat_py, subdir_file6, subdir_file6_in)))
+
+test.must_match(['work1', 'src', 'file1'], "file1.in 1\n")
+test.must_match(['work1', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 1
file2.k 1 line 4
""")
-test.must_match(['src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n")
-test.must_match(['src', 'file4'], "file4.in 1\n")
-test.must_match(['src', 'file5'], """\
+test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n")
+test.must_match(['work1', 'src', 'file4'], "file4.in 1\n")
+test.must_match(['work1', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 1
@@ -189,46 +206,46 @@ file5.k 1 line 4
""")
#
-test.write(['src', 'file1.in'], "file1.in 2\n")
-test.write(['src', 'yyy'], "yyy 2\n")
-test.write(['src', 'zzz'], "zzz 2\n")
-test.write(['src', 'bbb.k'], "bbb.k 2\ninclude ccc\n")
+test.write(['work1', 'src', 'file1.in'], "file1.in 2\n")
+test.write(['work1', 'src', 'yyy'], "yyy 2\n")
+test.write(['work1', 'src', 'zzz'], "zzz 2\n")
+test.write(['work1', 'src', 'bbb.k'], "bbb.k 2\ninclude ccc\n")
-test.run(chdir='src', arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file1' because `file1.in' changed
-%s cat.py file1 file1.in
+%s %s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
-%s cat.py file2 file2.k
+%s %s file2 file2.k
scons: rebuilding `file3' because:
`yyy' changed
`zzz' changed
-%s cat.py file3 xxx yyy zzz
+%s %s file3 xxx yyy zzz
scons: rebuilding `%s' because:
`%s' is no longer a dependency
`%s' is no longer a dependency
`bbb.k' changed
Install file: "bbb.k" as "%s"
scons: rebuilding `file5' because `%s' changed
-%s cat.py file5 file5.k
-""" % (python,
- python,
- python,
- test.workpath('inc', 'bbb.k'),
- test.workpath('inc', 'ddd'),
- test.workpath('inc', 'eee'),
- test.workpath('inc', 'bbb.k'),
- test.workpath('inc', 'bbb.k'),
- python)))
-
-test.must_match(['src', 'file1'], "file1.in 2\n")
-test.must_match(['src', 'file2'], """\
+%s %s file5 file5.k
+""" % (python, cat_py,
+ python, cat_py,
+ python, cat_py,
+ test.workpath('work1', 'inc', 'bbb.k'),
+ test.workpath('work1', 'inc', 'ddd'),
+ test.workpath('work1', 'inc', 'eee'),
+ test.workpath('work1', 'inc', 'bbb.k'),
+ test.workpath('work1', 'inc', 'bbb.k'),
+ python, cat_py)))
+
+test.must_match(['work1', 'src', 'file1'], "file1.in 2\n")
+test.must_match(['work1', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 2
file2.k 1 line 4
""")
-test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
-test.must_match(['src', 'file5'], """\
+test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
+test.must_match(['work1', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 2
@@ -237,59 +254,73 @@ file5.k 1 line 4
""")
#
-test.write(['src', 'SConscript'], """\
+test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['xxx', 'yyy'])
""")
-test.run(chdir='src', arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is no longer a dependency
-%s cat.py file3 xxx yyy
-""" % (python,)))
+%s %s file3 xxx yyy
+""" % (python, cat_py)))
-test.must_match(['src', 'file3'], "xxx 1\nyyy 2\n")
+test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\n")
#
-test.write(['src', 'SConscript'], """\
+test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
""")
-test.run(chdir='src', arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is a new dependency
-%s cat.py file3 xxx yyy zzz
-""" % (python,)))
+%s %s file3 xxx yyy zzz
+""" % (python, cat_py)))
-test.must_match(['src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
+test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
#
-test.write(['src', 'SConscript'], """\
+test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['zzz', 'yyy', 'xxx'])
""")
-test.run(chdir='src', arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file3' because the dependency order changed:
old: ['xxx', 'yyy', 'zzz']
new: ['zzz', 'yyy', 'xxx']
-%s cat.py file3 zzz yyy xxx
-""" % (python,)))
+%s %s file3 zzz yyy xxx
+""" % (python, cat_py)))
-test.must_match(['src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
+test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
#
-test.write(['src', 'SConscript'], """\
+test.write(['work1', 'src', 'SConscript'], """\
Import("env")
-env.Command('file4', 'file4.in', r"%s cat.py $TARGET $SOURCES")
-""" % (python,))
+env.Command('file4', 'file4.in', r"%s %s $TARGET $SOURCES")
+""" % (python, cat_py))
-test.run(chdir='src',arguments=args, stdout=test.wrap_stdout("""\
+test.run(chdir='work1/src',arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file4' because the build action changed:
- old: %s cat.py $TARGET - $SOURCES
- new: %s cat.py $TARGET $SOURCES
-%s cat.py file4 file4.in
-""" % (python, python, python)))
+ old: %s %s $TARGET - $SOURCES
+ new: %s %s $TARGET $SOURCES
+%s %s file4 file4.in
+""" % (python, cat_py,
+ python, cat_py,
+ python, cat_py)))
+
+test.must_match(['work1', 'src', 'file4'], "file4.in 1\n")
+
+test.up_to_date(chdir='work1/src',arguments='.')
+
+# Test the transition when you turn ON SConsignFile().
+# This will (or might) rebuild things, but we don't care what,
+# we just want to make sure we don't blow up.
+test.write(['work1', 'src', 'SConstruct'],
+ "SConsignFile()\n" + SConstruct_contents)
+
+test.run(chdir='work1/src', arguments=args)
-test.must_match(['src', 'file4'], "file4.in 1\n")
+test.up_to_date(chdir='work1/src',arguments='.')
test.pass_test()