1. SCons
  2. Core
  3. SCons

Source

SCons / test / explain.py

Diff from to

File test/explain.py

 import sys
 import TestSCons
 
-python = TestSCons.python
+_python_ = TestSCons._python_
 
 test = TestSCons.TestSCons()
 
                 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},
 env.InstallAs('../inc/bbb.k', 'bbb.k')
 env.Install('../inc', 'ddd')
 env.InstallAs('../inc/eee', 'eee.in')
-""" % (python, cat_py)
+""" % locals()
 
 args = '--debug=explain .'
 
 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'], """\
 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
 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'], """\
 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'], """\
 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")
 
 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")
 
 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")
 
 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")
 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")
 #
 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")
 
 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())
 
 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")