diff options
author | Steven Knight <knight@baldmt.com> | 2004-10-24 03:57:51 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-10-24 03:57:51 (GMT) |
commit | 7739efc3870f2814ee4b2ea6f8751ccc7407e069 (patch) | |
tree | 23128dee9f60768a6b230b965281b3b1fb91b700 /test | |
parent | 35a89330d1df50811fc6912df0047148b1d98450 (diff) | |
download | SCons-7739efc3870f2814ee4b2ea6f8751ccc7407e069.zip SCons-7739efc3870f2814ee4b2ea6f8751ccc7407e069.tar.gz SCons-7739efc3870f2814ee4b2ea6f8751ccc7407e069.tar.bz2 |
Refactor Action/Executor interaction. (Kevin Quick)
Diffstat (limited to 'test')
-rw-r--r-- | test/actions.py | 2 | ||||
-rw-r--r-- | test/chdir.py | 2 | ||||
-rw-r--r-- | test/explain.py | 69 | ||||
-rw-r--r-- | test/multi.py | 45 | ||||
-rw-r--r-- | test/option--debug.py | 68 | ||||
-rw-r--r-- | test/option--warn.py | 34 | ||||
-rw-r--r-- | test/strfunction.py | 2 |
7 files changed, 132 insertions, 90 deletions
diff --git a/test/actions.py b/test/actions.py index 8a64a24..c805a05 100644 --- a/test/actions.py +++ b/test/actions.py @@ -124,7 +124,7 @@ print env.subst('$L') test.run(arguments = '-Q .', stdout = """\ foo -func(env, target, source) +func(target, source, env) arg1 arg2 scons: `.' is up to date. diff --git a/test/chdir.py b/test/chdir.py index 9a77d75..b46764b 100644 --- a/test/chdir.py +++ b/test/chdir.py @@ -250,6 +250,8 @@ os.chdir('sub') os.chdir(%(work2)s) os.chdir('sub') %(python)s %(cat_py)s .temp f2.in +os.chdir(%(work2)s) +os.chdir('sub') %(python)s %(cat_py)s f2.out .temp os.chdir(%(work2)s) """ % locals()) diff --git a/test/explain.py b/test/explain.py index eed95c4..e0819de 100644 --- a/test/explain.py +++ b/test/explain.py @@ -298,17 +298,64 @@ test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n") # 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") +""" % {'python':python, 'cat_py':cat_py}) + +test.run(chdir='work1/src', arguments=args, stdout=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 +""" % {'python':python, 'cat_py':cat_py})) + +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.must_match(['work1', 'src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nyyy 2\n") + +# +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") +""" % {'python':python, 'cat_py':cat_py}) + +test.run(chdir='work1/src', arguments=args, stdout=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 +""" % {'python':python, 'cat_py':cat_py})) + +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.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"%s %s $TARGET $FILE4FLAG $SOURCES", FILE4FLAG="") """ % (python, cat_py)) test.run(chdir='work1/src',arguments=args, stdout=test.wrap_stdout("""\ -scons: rebuilding `file4' because the build action changed: - old: %s %s file4 - file4.in - new: %s %s file4 file4.in -%s %s file4 file4.in -""" % (python, cat_py, - python, cat_py, - python, cat_py))) +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 +""" % {'python':python, 'cat_py':cat_py})), test.must_match(['work1', 'src', 'file4'], "file4.in 1\n") @@ -491,13 +538,13 @@ test.run(chdir = 'work5', arguments = "--debug=explain mode=1 .", stdout = test.wrap_stdout("""\ scons: rebuilding `f1.out' because the build action changed: - old: Copy("f1.out", "f1.in") - new: DifferentCopy(["f1.out"], ["f1.in"]) - AltCopyStage2(["f1.out"], ["f1.in"]) + old: Copy("$TARGET", "$SOURCE") + new: DifferentCopy(target, source, env) + AltCopyStage2(target, source, env) DifferentCopy(["f1.out"], ["f1.in"]) AltCopyStage2(["f1.out"], ["f1.in"]) scons: rebuilding `f2.out' because the contents of the build action changed - action: ChangingCopy(["f2.out"], ["f2.in"]) + action: ChangingCopy(target, source, env) ChangingCopy(["f2.out"], ["f2.in"]) """)) diff --git a/test/multi.py b/test/multi.py index f7161a1..8e590d9 100644 --- a/test/multi.py +++ b/test/multi.py @@ -28,10 +28,11 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test various cases where a target is "built" by multiple builder calls. """ +import TestCmd import TestSCons import os.path -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match=TestCmd.match_re) # @@ -80,10 +81,9 @@ test.write('file2b.in', 'file2b.in\n') test.run(arguments='file2.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Multiple ways to build the same target were specified for: file2.out (from ['file2a.in'] and from ['file2b.in']) -File "SConstruct", line 10, in ? -""") +""") + TestSCons.file_expr) # @@ -108,10 +108,9 @@ test.write('file3b.in', 'file3b.in\n') test.run(arguments='file3.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Two different sets of overrides were specified for the same target: file3.out -File "SConstruct", line 10, in ? -""") +""") + TestSCons.file_expr) # @@ -160,11 +159,10 @@ test.write('file5a.in', 'file5a.in\n') test.write('file5b.in', 'file5b.in\n') test.run(arguments='file5.out', - stderr=""" + stderr=TestSCons.re_escape(""" scons: warning: Two different environments were specified for target file5.out, - but they appear to have the same action: build(["file5.out"], ["file5b.in"]) -File "SConstruct", line 11, in ? -""") + but they appear to have the same action: build(target, source, env) +""") + TestSCons.file_expr) test.must_match('file5.out', "file5a.in\nfile5b.in\n") @@ -192,10 +190,9 @@ test.write('file6b.in', 'file6b.in\n') test.run(arguments='file6.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Two environments with different actions were specified for the same target: file6.out -File "SConstruct", line 11, in ? -""") +""") + TestSCons.file_expr) # @@ -248,10 +245,9 @@ test.write('file8b.in', 'file8b.in\n') test.run(arguments='file8.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Two different builders (B and C) were specified for the same target: file8.out -File "SConstruct", line 14, in ? -""") +""") + TestSCons.file_expr) # @@ -305,10 +301,9 @@ test.write('file10.in', 'file10.in\n') test.run(arguments='file10.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Two different target sets have a target in common: file10b.out -File "SConstruct", line 11, in ? -""") +""") + TestSCons.file_expr) # @@ -340,10 +335,9 @@ test.write('file11b.in', 'file11b.in\n') test.run(arguments='file11.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Two different target sets have a target in common: file11b.out -File "SConstruct", line 11, in ? -""") +""") + TestSCons.file_expr) # @@ -368,10 +362,9 @@ test.write('file12b.in', 'file12b.in\n') test.run(arguments='file12.out', status=2, - stderr=""" + stderr=TestSCons.re_escape(""" scons: *** Cannot build same target `file12a.out' as singular and list -File "SConstruct", line 11, in ? -""") +""") + TestSCons.file_expr) diff --git a/test/option--debug.py b/test/option--debug.py index e3d9960..7a80647 100644 --- a/test/option--debug.py +++ b/test/option--debug.py @@ -295,72 +295,80 @@ test.write('file17.in', "file17.in\n") test.write('file18.in', "file18.in\n") expect = """\ -Building file01.out with action(s): +Building file01.out with action: $PYTHON cat.py $SOURCES $TARGET __PYTHON__ cat.py file01.in file01.out -Building file02.out with action(s): +Building file02.out with action: $PYTHON cat.py $SOURCES $TARGET __PYTHON__ cat.py file02.in file02.out -Building file03.out with action(s): +Building file03.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file03.in temp +Building file03.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file03.out -Building file04.out with action(s): +Building file04.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file04.in temp +Building file04.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file04.out -Building file05.out with action(s): +Building file05.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file05.in temp +Building file05.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file05.out -Building file06.out with action(s): +Building file06.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file06.in temp +Building file06.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file06.out -Building file07.out with action(s): - cat(env, target, source) +Building file07.out with action: + cat(target, source, env) cat(["file07.out"], ["file07.in"]) -Building file08.out with action(s): - cat(env, target, source) +Building file08.out with action: + cat(target, source, env) cat(["file08.out"], ["file08.in"]) -Building file09.out with action(s): - cat(env, target, source) +Building file09.out with action: + cat(target, source, env) cat(["file09.out"], ["file09.in"]) -Building file11.out with action(s): +Building file11.out with action: $PYTHON cat.py $SOURCES $TARGET __PYTHON__ cat.py file11.in file11.out -Building file12.out with action(s): +Building file12.out with action: $PYTHON cat.py $SOURCES $TARGET __PYTHON__ cat.py file12.in file12.out -Building file13.out with action(s): +Building file13.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file13.in temp +Building file13.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file13.out -Building file14.out with action(s): +Building file14.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file14.in temp +Building file14.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file14.out -Building file15.out with action(s): +Building file15.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file15.in temp +Building file15.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file15.out -Building file16.out with action(s): +Building file16.out with action: $PYTHON cat.py $SOURCES temp - $PYTHON cat.py temp $TARGET __PYTHON__ cat.py file16.in temp +Building file16.out with action: + $PYTHON cat.py temp $TARGET __PYTHON__ cat.py temp file16.out -Building file17.out with action(s): - cat(env, target, source) +Building file17.out with action: + cat(target, source, env) cat(["file17.out"], ["file17.in"]) -Building file18.out with action(s): - cat(env, target, source) +Building file18.out with action: + cat(target, source, env) cat(["file18.out"], ["file18.in"]) """ expect = string.replace(expect, '__PYTHON__', TestSCons.python) diff --git a/test/option--warn.py b/test/option--warn.py index 155545b..62245ab 100644 --- a/test/option--warn.py +++ b/test/option--warn.py @@ -72,20 +72,17 @@ test.write("foo.c",""" test.run(arguments='--warn=dependency .', stderr=r""" scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found -File ".+", line \d+, in .+ -""") +""" + TestSCons.file_expr) test.run(arguments='--warn=all .', stderr=r""" scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found -File ".+", line \d+, in .+ -""") +""" + TestSCons.file_expr) test.run(arguments='--warn=all --warn=no-dependency .', stderr="") test.run(arguments='--warn=no-dependency --warn=all .', stderr=r""" scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found -File ".+", line \d+, in .+ -""") +""" + TestSCons.file_expr) @@ -101,8 +98,7 @@ SConscript('no_such_file') test.run(arguments = '--warn=missing-sconscript .', stderr = r""" scons: warning: Ignoring missing SConscript 'no_such_file' -File ".+", line \d+, in .+ -""") +""" + TestSCons.file_expr) test.run(arguments = '--warn=no-missing-sconscript .', stderr = "") @@ -127,18 +123,16 @@ test.write('file1b.in', 'file1b.in\n') test.run(arguments='file1.out', stderr=r""" scons: warning: Two different environments were specified for target file1.out, - but they appear to have the same action: build\(\["file1.out"\], \["file1b.in"\]\) -File "SConstruct", line \d+, in .+ -""") + but they appear to have the same action: build\(target, source, env\) +""" + TestSCons.file_expr) test.must_match('file1.out', "file1a.in\nfile1b.in\n") test.run(arguments='--warn=duplicate-environment file1.out', stderr=r""" scons: warning: Two different environments were specified for target file1.out, - but they appear to have the same action: build\(\["file1.out"\], \["file1b.in"\]\) -File "SConstruct", line \d+, in .+ -""") + but they appear to have the same action: build\(target, source, env\) +""" + TestSCons.file_expr) test.run(arguments='--warn=no-duplicate-environment file1.out') @@ -162,11 +156,9 @@ test.write('file3b.out', 'file3b.out\n') test.run(arguments='.', stderr=r""" scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? -File "SConstruct", line \d+, in .+ - +""" + TestSCons.file_expr + r""" scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? -File "SConstruct", line \d+, in .+ -""") +""" + TestSCons.file_expr) test.must_match(['file3a'], 'file3a.in\n') test.must_match(['file3b'], 'file3b.out\n') @@ -174,11 +166,9 @@ test.must_match(['file3b'], 'file3b.out\n') test.run(arguments='--warn=misleading-keywords .', stderr=r""" scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? -File "SConstruct", line \d+, in .+ - +""" + TestSCons.file_expr + r"""\ scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\? -File "SConstruct", line \d+, in .+ -""") +""" + TestSCons.file_expr) test.run(arguments='--warn=no-misleading-keywords .') diff --git a/test/strfunction.py b/test/strfunction.py index 6754596..4180d21 100644 --- a/test/strfunction.py +++ b/test/strfunction.py @@ -128,6 +128,7 @@ Building dict6.out from dict6.lazystr %s cat.py dict7.list .temp %s cat.py .temp dict7.out Building dict8.out from dict8.liststr +Building dict8.out from dict8.liststr func(["func.out"], ["func.in"]) Building funcstr.out from funcstr.in %s cat.py lazy.in lazy.out @@ -135,6 +136,7 @@ Building lazystr.out from lazystr.in %s cat.py list.in .temp %s cat.py .temp list.out Building liststr.out from liststr.in +Building liststr.out from liststr.in """) % (python, python, python, python, python, python, python, python)) test.pass_test() |