summaryrefslogtreecommitdiffstats
path: root/test/explain.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/explain.py')
-rw-r--r--test/explain.py144
1 files changed, 82 insertions, 62 deletions
diff --git a/test/explain.py b/test/explain.py
index 7f0fbb5..f69b00f 100644
--- a/test/explain.py
+++ b/test/explain.py
@@ -33,7 +33,7 @@ import string
import sys
import TestSCons
-python = TestSCons.python
+_python_ = TestSCons._python_
test = TestSCons.TestSCons()
@@ -85,7 +85,7 @@ kscan = Scanner(name = 'kfile',
argument = None,
skeys = ['.k'])
-cat = Builder(action = r"%s %s $TARGET $SOURCES")
+cat = Builder(action = r'%(_python_)s %(cat_py)s $TARGET $SOURCES')
env = Environment()
env.Append(BUILDERS = {'Cat':cat},
@@ -97,7 +97,7 @@ env.Install('../inc', 'aaa')
env.InstallAs('../inc/bbb.k', 'bbb.k')
env.Install('../inc', 'ddd')
env.InstallAs('../inc/eee', 'eee.in')
-""" % (python, cat_py)
+""" % locals()
args = '--debug=explain .'
@@ -109,10 +109,12 @@ 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 %s $TARGET $FILE4FLAG $SOURCES", FILE4FLAG="-")
+env.Command('file4', 'file4.in',
+ r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES',
+ FILE4FLAG='-')
env.Cat('file5', 'file5.k')
env.Cat('subdir/file6', 'subdir/file6.in')
-""" % (python, cat_py))
+""" % locals())
test.write(['work1', 'src', 'aaa'], "aaa 1\n")
test.write(['work1', 'src', 'bbb.k'], """\
@@ -155,15 +157,15 @@ work1_inc_eee = test.workpath('work1', 'inc', 'eee')
work1_inc_bbb_k = test.workpath('work1', 'inc', 'bbb.k')
#
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: building `file1' because it doesn't exist
-%(python)s %(cat_py)s file1 file1.in
+%(_python_)s %(cat_py)s file1 file1.in
scons: building `file2' because it doesn't exist
-%(python)s %(cat_py)s file2 file2.k
+%(_python_)s %(cat_py)s file2 file2.k
scons: building `file3' because it doesn't exist
-%(python)s %(cat_py)s file3 xxx yyy zzz
+%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: building `file4' because it doesn't exist
-%(python)s %(cat_py)s file4 - file4.in
+%(_python_)s %(cat_py)s file4 - file4.in
scons: building `%(work1_inc_aaa)s' because it doesn't exist
Install file: "aaa" as "%(work1_inc_aaa)s"
scons: building `%(work1_inc_ddd)s' because it doesn't exist
@@ -173,10 +175,12 @@ Install file: "eee.in" as "%(work1_inc_eee)s"
scons: building `%(work1_inc_bbb_k)s' because it doesn't exist
Install file: "bbb.k" as "%(work1_inc_bbb_k)s"
scons: building `file5' because it doesn't exist
-%(python)s %(cat_py)s file5 file5.k
+%(_python_)s %(cat_py)s file5 file5.k
scons: building `%(subdir_file6)s' because it doesn't exist
-%(python)s %(cat_py)s %(subdir_file6)s %(subdir_file6_in)s
-""" % locals()))
+%(_python_)s %(cat_py)s %(subdir_file6)s %(subdir_file6_in)s
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file1'], "file1.in 1\n")
test.must_match(['work1', 'src', 'file2'], """\
@@ -203,23 +207,25 @@ 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='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file1' because `file1.in' changed
-%(python)s %(cat_py)s file1 file1.in
+%(_python_)s %(cat_py)s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
-%(python)s %(cat_py)s file2 file2.k
+%(_python_)s %(cat_py)s file2 file2.k
scons: rebuilding `file3' because:
`yyy' changed
`zzz' changed
-%(python)s %(cat_py)s file3 xxx yyy zzz
+%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: rebuilding `%(work1_inc_bbb_k)s' because:
`%(work1_inc_ddd)s' is no longer a dependency
`%(work1_inc_eee)s' is no longer a dependency
`bbb.k' changed
Install file: "bbb.k" as "%(work1_inc_bbb_k)s"
scons: rebuilding `file5' because `%(work1_inc_bbb_k)s' changed
-%(python)s %(cat_py)s file5 file5.k
-""" % locals()))
+%(_python_)s %(cat_py)s file5 file5.k
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file1'], "file1.in 2\n")
test.must_match(['work1', 'src', 'file2'], """\
@@ -243,10 +249,12 @@ Import("env")
env.Cat('file3', ['xxx', 'yyy'])
""")
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is no longer a dependency
-%(python)s %(cat_py)s file3 xxx yyy
-""" % locals()))
+%(_python_)s %(cat_py)s file3 xxx yyy
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\n")
@@ -256,10 +264,12 @@ Import("env")
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
""")
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is a new dependency
-%(python)s %(cat_py)s file3 xxx yyy zzz
-""" % locals()))
+%(_python_)s %(cat_py)s file3 xxx yyy zzz
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
@@ -269,12 +279,14 @@ Import("env")
env.Cat('file3', ['zzz', 'yyy', 'xxx'])
""")
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the dependency order changed:
old: ['xxx', 'yyy', 'zzz']
new: ['zzz', 'yyy', 'xxx']
-%(python)s %(cat_py)s file3 zzz yyy xxx
-""" % locals()))
+%(_python_)s %(cat_py)s file3 zzz yyy xxx
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
@@ -283,20 +295,22 @@ test.write(['work1', 'src', 'SConscript'], """\
Import("env")
f3 = File('file3')
env.Cat(f3, ['zzz', 'yyy', 'xxx'])
-env.AddPostAction(f3, r"%(python)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy")
-env.AddPreAction(f3, r"%(python)s %(cat_py)s ${TARGET}.alt $SOURCES")
+env.AddPostAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy')
+env.AddPreAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES')
""" % locals())
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the build action changed:
- old: %(python)s %(cat_py)s $TARGET $SOURCES
- new: %(python)s %(cat_py)s ${TARGET}.alt $SOURCES
- %(python)s %(cat_py)s $TARGET $SOURCES
- %(python)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
-%(python)s %(cat_py)s file3.alt zzz yyy xxx
-%(python)s %(cat_py)s file3 zzz yyy xxx
-%(python)s %(cat_py)s file3.yyy zzz yyy xxx yyy
-""" % locals()))
+ old: %(_python_)s %(cat_py)s $TARGET $SOURCES
+ new: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
+ %(_python_)s %(cat_py)s $TARGET $SOURCES
+ %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
+%(_python_)s %(cat_py)s file3.alt zzz yyy xxx
+%(_python_)s %(cat_py)s file3 zzz yyy xxx
+%(_python_)s %(cat_py)s file3.yyy zzz yyy xxx yyy
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n")
@@ -307,22 +321,24 @@ test.write(['work1', 'src', 'SConscript'], """\
Import("env")
f3 = File('file3')
env.Cat(f3, ['zzz', 'yyy', 'xxx'])
-env.AddPostAction(f3, r"%(python)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx")
-env.AddPreAction(f3, r"%(python)s %(cat_py)s ${TARGET}.alt $SOURCES")
+env.AddPostAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx')
+env.AddPreAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES')
""" % locals())
-test.run(chdir='work1/src', arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the build action changed:
- old: %(python)s %(cat_py)s ${TARGET}.alt $SOURCES
- %(python)s %(cat_py)s $TARGET $SOURCES
- %(python)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
- new: %(python)s %(cat_py)s ${TARGET}.alt $SOURCES
- %(python)s %(cat_py)s $TARGET $SOURCES
- %(python)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx
-%(python)s %(cat_py)s file3.alt zzz yyy xxx
-%(python)s %(cat_py)s file3 zzz yyy xxx
-%(python)s %(cat_py)s file3.yyy zzz yyy xxx xxx
-""" % locals()))
+ old: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
+ %(_python_)s %(cat_py)s $TARGET $SOURCES
+ %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
+ new: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
+ %(_python_)s %(cat_py)s $TARGET $SOURCES
+ %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx
+%(_python_)s %(cat_py)s file3.alt zzz yyy xxx
+%(_python_)s %(cat_py)s file3 zzz yyy xxx
+%(_python_)s %(cat_py)s file3.yyy zzz yyy xxx xxx
+""" % locals())
+
+test.run(chdir='work1/src', arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n")
@@ -331,14 +347,18 @@ test.must_match(['work1', 'src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nxxx 1\n")
#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
-env.Command('file4', 'file4.in', r"%(python)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES", FILE4FLAG="")
+env.Command('file4', 'file4.in',
+ r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES',
+ FILE4FLAG='')
""" % locals())
-test.run(chdir='work1/src',arguments=args, stdout=test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
scons: rebuilding `file4' because the contents of the build action changed
- action: %(python)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES
-%(python)s %(cat_py)s file4 file4.in
-""" % locals()))
+ action: %(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES
+%(_python_)s %(cat_py)s file4 file4.in
+""" % locals())
+
+test.run(chdir='work1/src',arguments=args, stdout=expect)
test.must_match(['work1', 'src', 'file4'], "file4.in 1\n")
@@ -363,7 +383,7 @@ Import("env")
env.Cat('file1', 'file1.in')
env.Cat('file2', 'file2.k')
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
-env.Command('file4', 'file4.in', r"%(python)s %(cat_py)s $TARGET - $SOURCES")
+env.Command('file4', 'file4.in', r'%(_python_)s %(cat_py)s $TARGET - $SOURCES')
env.Cat('file5', 'file5.k')
env.Cat('subdir/file6', 'subdir/file6.in')
""" % locals())
@@ -437,20 +457,20 @@ work4_inc_eee = test.workpath('work4', 'inc', 'eee')
test.run(chdir='work4/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file1' because `file1.in' changed
-%(python)s %(cat_py)s file1 file1.in
+%(_python_)s %(cat_py)s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
-%(python)s %(cat_py)s file2 file2.k
+%(_python_)s %(cat_py)s file2 file2.k
scons: rebuilding `file3' because:
`yyy' changed
`zzz' changed
-%(python)s %(cat_py)s file3 xxx yyy zzz
+%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: rebuilding `%(work4_inc_bbb_k)s' because:
`%(work4_inc_ddd)s' is no longer a dependency
`%(work4_inc_eee)s' is no longer a dependency
`bbb.k' changed
Install file: "bbb.k" as "%(work4_inc_bbb_k)s"
scons: rebuilding `file5' because `%(work4_inc_bbb_k)s' changed
-%(python)s %(cat_py)s file5 file5.k
+%(_python_)s %(cat_py)s file5 file5.k
""" % locals()))
test.must_match(['work4', 'src', 'file1'], "file1.in 2\n")