From 8ac4bd1db25e722ea2bcc2466924938fa761c31f Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 6 Jan 2010 01:56:48 +0000 Subject: Fix some tests so they can still run on Windows system without .py file associations. --- test/explain/basic.py | 99 ++++++++++++++++++++------------------- test/scons-time/run/subversion.py | 3 +- test/subdivide.py | 10 ++-- 3 files changed, 58 insertions(+), 54 deletions(-) diff --git a/test/explain/basic.py b/test/explain/basic.py index 881f01d..fec7b93 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -37,6 +37,9 @@ test = TestSCons.TestSCons() test.subdir(['src'], ['src', 'subdir']) +python = TestSCons.python +_python_ = TestSCons._python_ + subdir_file7 = os.path.join('subdir', 'file7') subdir_file7_in = os.path.join('subdir', 'file7.in') subdir_file8 = os.path.join('subdir', 'file8') @@ -75,8 +78,6 @@ for f in sys.argv[2:]: sys.exit(0) """) -test.chmod(cat_py, 0755) - SConstruct_contents = """\ import re @@ -93,8 +94,8 @@ kscan = Scanner(name = 'kfile', argument = None, skeys = ['.k']) -cat = Builder(action = [[r'%(cat_py)s', '$TARGET', '$SOURCES']]) -one_cat = Builder( action = [[r'%(cat_py)s', '$TARGET', '${SOURCES[0]}']]) +cat = Builder(action = [[r'%(_python_)s', r'%(cat_py)s', '$TARGET', '$SOURCES']]) +one_cat = Builder( action = [[r'%(_python_)s', r'%(cat_py)s', '$TARGET', '${SOURCES[0]}']]) env = Environment() env.Append(BUILDERS = {'Cat':cat, 'OneCat':one_cat}, @@ -118,7 +119,7 @@ env.Cat('file1', 'file1.in') env.Cat('file2', 'file2.k') env.Cat('file3', ['xxx', 'yyy', 'zzz']) env.Command('file4', 'file4.in', - r'%(cat_py)s $TARGET $FILE4FLAG $SOURCES', + r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES', FILE4FLAG='-') env.Cat('file5', 'file5.k') file6 = env.Cat('file6', 'file6.in') @@ -176,13 +177,13 @@ args = '--debug=explain .' expect = test.wrap_stdout("""\ scons: building `file1' because it doesn't exist -%(cat_py)s file1 file1.in +%(_python_)s %(cat_py)s file1 file1.in scons: building `file2' because it doesn't exist -%(cat_py)s file2 file2.k +%(_python_)s %(cat_py)s file2 file2.k scons: building `file3' because it doesn't exist -%(cat_py)s file3 xxx yyy zzz +%(_python_)s %(cat_py)s file3 xxx yyy zzz scons: building `file4' because it doesn't exist -%(cat_py)s file4 - file4.in +%(_python_)s %(cat_py)s file4 - file4.in scons: building `%(inc_aaa)s' because it doesn't exist Install file: "aaa" as "%(inc_aaa)s" scons: building `%(inc_ddd)s' because it doesn't exist @@ -192,15 +193,15 @@ Install file: "eee.in" as "%(inc_eee)s" scons: building `%(inc_bbb_k)s' because it doesn't exist Install file: "bbb.k" as "%(inc_bbb_k)s" scons: building `file5' because it doesn't exist -%(cat_py)s file5 file5.k +%(_python_)s %(cat_py)s file5 file5.k scons: building `file6' because it doesn't exist -%(cat_py)s file6 file6.in +%(_python_)s %(cat_py)s file6 file6.in scons: building `%(subdir_file7)s' because it doesn't exist -%(cat_py)s %(subdir_file7)s %(subdir_file7_in)s +%(_python_)s %(cat_py)s %(subdir_file7)s %(subdir_file7_in)s scons: building `%(subdir_file8)s' because it doesn't exist -%(cat_py)s %(subdir_file8)s %(subdir_file7_in)s +%(_python_)s %(cat_py)s %(subdir_file8)s %(subdir_file7_in)s scons: building `%(subdir_file9)s' because it doesn't exist -%(cat_py)s %(subdir_file9)s %(subdir_file7_in)s +%(_python_)s %(cat_py)s %(subdir_file9)s %(subdir_file7_in)s """ % locals()) test.run(chdir='src', arguments=args, stdout=expect) @@ -237,26 +238,26 @@ WriteInitialTest( locals() ) expect = test.wrap_stdout("""\ scons: rebuilding `file1' because `file1.in' changed -%(cat_py)s file1 file1.in +%(_python_)s %(cat_py)s file1 file1.in scons: rebuilding `file2' because `yyy' changed -%(cat_py)s file2 file2.k +%(_python_)s %(cat_py)s file2 file2.k scons: rebuilding `file3' because: `yyy' changed `zzz' changed -%(cat_py)s file3 xxx yyy zzz +%(_python_)s %(cat_py)s file3 xxx yyy zzz scons: rebuilding `%(inc_bbb_k)s' because: `%(inc_ddd)s' is no longer a dependency `%(inc_eee)s' is no longer a dependency `bbb.k' changed Install file: "bbb.k" as "%(inc_bbb_k)s" scons: rebuilding `file5' because `%(inc_bbb_k)s' changed -%(cat_py)s file5 file5.k +%(_python_)s %(cat_py)s file5 file5.k scons: rebuilding `file6' because AlwaysBuild() is specified -%(cat_py)s file6 file6.in +%(_python_)s %(cat_py)s file6 file6.in scons: rebuilding `%(subdir_file8)s' because: `first' is no longer a dependency `second' is a new dependency -%(cat_py)s %(subdir_file8)s %(subdir_file7_in)s +%(_python_)s %(cat_py)s %(subdir_file8)s %(subdir_file7_in)s """ % locals()) test.run(chdir='src', arguments=args, stdout=expect) @@ -286,7 +287,7 @@ env.Cat('file3', ['xxx', 'yyy']) expect = test.wrap_stdout("""\ scons: rebuilding `file3' because `zzz' is no longer a dependency -%(cat_py)s file3 xxx yyy +%(_python_)s %(cat_py)s file3 xxx yyy """ % locals()) test.run(chdir='src', arguments=args, stdout=expect) @@ -302,7 +303,7 @@ env.Cat('file3', ['xxx', 'yyy', 'zzz']) expect = test.wrap_stdout("""\ scons: rebuilding `file3' because `zzz' is a new dependency -%(cat_py)s file3 xxx yyy zzz +%(_python_)s %(cat_py)s file3 xxx yyy zzz """ % locals()) test.run(chdir='src', arguments=args, stdout=expect) @@ -316,13 +317,13 @@ Import("env") env.Cat('file3', ['zzz', 'yyy', 'xxx']) """) -cat_py_sep = string.replace(cat_py, '\\', '\\\\') +python_sep = string.replace(python, '\\', '\\\\') expect = test.wrap_stdout("""\ scons: rebuilding `file3' because the dependency order changed: - old: ['xxx', 'yyy', 'zzz', '%(cat_py_sep)s'] - new: ['zzz', 'yyy', 'xxx', '%(cat_py_sep)s'] -%(cat_py)s file3 zzz yyy xxx + old: ['xxx', 'yyy', 'zzz', '%(python_sep)s'] + new: ['zzz', 'yyy', 'xxx', '%(python_sep)s'] +%(_python_)s %(cat_py)s file3 zzz yyy xxx """ % locals()) test.run(chdir='src', arguments=args, stdout=expect) @@ -335,19 +336,19 @@ test.write(['src', 'SConscript'], """\ Import("env") f3 = File('file3') env.Cat(f3, ['zzz', 'yyy', 'xxx']) -env.AddPostAction(f3, r'%(cat_py)s ${TARGET}.yyy $SOURCES yyy') -env.AddPreAction(f3, r'%(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()) expect = test.wrap_stdout("""\ scons: rebuilding `file3' because the build action changed: - old: %(cat_py)s $TARGET $SOURCES - new: %(cat_py)s ${TARGET}.alt $SOURCES - %(cat_py)s $TARGET $SOURCES - %(cat_py)s ${TARGET}.yyy $SOURCES yyy -%(cat_py)s file3.alt zzz yyy xxx -%(cat_py)s file3 zzz yyy xxx -%(cat_py)s file3.yyy zzz yyy xxx yyy + 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='src', arguments=args, stdout=expect) @@ -362,21 +363,21 @@ test.write(['src', 'SConscript'], """\ Import("env") f3 = File('file3') env.Cat(f3, ['zzz', 'yyy', 'xxx']) -env.AddPostAction(f3, r'%(cat_py)s ${TARGET}.yyy $SOURCES xxx') -env.AddPreAction(f3, r'%(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()) expect = test.wrap_stdout("""\ scons: rebuilding `file3' because the build action changed: - old: %(cat_py)s ${TARGET}.alt $SOURCES - %(cat_py)s $TARGET $SOURCES - %(cat_py)s ${TARGET}.yyy $SOURCES yyy - new: %(cat_py)s ${TARGET}.alt $SOURCES - %(cat_py)s $TARGET $SOURCES - %(cat_py)s ${TARGET}.yyy $SOURCES xxx -%(cat_py)s file3.alt zzz yyy xxx -%(cat_py)s file3 zzz yyy xxx -%(cat_py)s file3.yyy zzz yyy xxx xxx + 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='src', arguments=args, stdout=expect) @@ -390,14 +391,14 @@ test.must_match(['src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nxxx 1\n") test.write(['src', 'SConscript'], """\ Import("env") env.Command('file4', 'file4.in', - r'%(cat_py)s $TARGET $FILE4FLAG $SOURCES', + r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES', FILE4FLAG='') """ % locals()) expect = test.wrap_stdout("""\ scons: rebuilding `file4' because the contents of the build action changed - action: %(cat_py)s $TARGET $FILE4FLAG $SOURCES -%(cat_py)s file4 file4.in + action: %(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES +%(_python_)s %(cat_py)s file4 file4.in """ % locals()) test.run(chdir='src',arguments=args, stdout=expect) diff --git a/test/scons-time/run/subversion.py b/test/scons-time/run/subversion.py index e3152fc..f895760 100644 --- a/test/scons-time/run/subversion.py +++ b/test/scons-time/run/subversion.py @@ -38,10 +38,11 @@ test = TestSCons_time.TestSCons_time() test.write_sample_project('foo.tar') +_python_ = TestSCons_time._python_ my_svn_py = test.write_fake_svn_py('my_svn.py') test.write('config', """\ -svn = r'%(my_svn_py)s' +svn = r'%(_python_)s %(my_svn_py)s' """ % locals()) test.run(arguments = 'run -f config --svn http://xyzzy --number 617,716 foo.tar') diff --git a/test/subdivide.py b/test/subdivide.py index 2802fc8..a80bc46 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -43,6 +43,8 @@ test = TestSCons.TestSCons() test.subdir('src', ['src', 'sub']) +_python_ = TestSCons._python_ + # Because this test sets SConsignFile(None), we execute our fake # scripts directly, not by feeding them to the Python executable. # That is, we chmod 0755 and us a "#!/usr/bin/env python" first @@ -81,8 +83,8 @@ test.write('SConstruct', """\ SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', - CCCOM = r'%(fake_cc_py)s $TARGET $SOURCES', - LINKCOM = r'%(fake_link_py)s $TARGET $SOURCES') + CCCOM = r'%(_python_)s %(fake_cc_py)s $TARGET $SOURCES', + LINKCOM = r'%(_python_)s %(fake_link_py)s $TARGET $SOURCES') env.PrependENVPath('PATHEXT', '.PY') env.SConscript('src/SConstruct', exports=['env']) env.Object('foo.c') @@ -92,8 +94,8 @@ test.write(['src', 'SConstruct'], """\ SConsignFile(None) env = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', - CCCOM = r'%(fake_cc_py)s $TARGET $SOURCES', - LINKCOM = r'%(fake_link_py)s $TARGET $SOURCES') + CCCOM = r'%(_python_)s %(fake_cc_py)s $TARGET $SOURCES', + LINKCOM = r'%(_python_)s %(fake_link_py)s $TARGET $SOURCES') env.PrependENVPath('PATHEXT', '.PY') p = env.Program('prog', ['main.c', '../foo$OBJSUFFIX', 'sub/bar.c']) env.Default(p) -- cgit v0.12