diff options
author | Steven Knight <knight@baldmt.com> | 2005-10-02 22:59:58 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-10-02 22:59:58 (GMT) |
commit | 1529ef17c861d83e5643e53640fd7971cf7456ef (patch) | |
tree | 69f38dbe43da93222176ef21d4170511e90a6771 /test | |
parent | 6eccd4f877951395160ff171db5d52b31da0174e (diff) | |
download | SCons-1529ef17c861d83e5643e53640fd7971cf7456ef.zip SCons-1529ef17c861d83e5643e53640fd7971cf7456ef.tar.gz SCons-1529ef17c861d83e5643e53640fd7971cf7456ef.tar.bz2 |
Report removal of multiple targets correctly when using -n -c. (Patrick Mezard)
Diffstat (limited to 'test')
-rw-r--r-- | test/option-c.py | 116 |
1 files changed, 69 insertions, 47 deletions
diff --git a/test/option-c.py b/test/option-c.py index 30ec6f8..fbad75c 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -24,6 +24,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Test various uses of the -c (clean) option. +""" + import os.path import sys import TestSCons @@ -57,6 +61,10 @@ if hasattr(os, 'symlink'): # force symlink to a file that doesn't exist os.symlink('does_not_exist', str(target[0])) env.Command(target = 'symlink2', source = 'foo1.in', action = symlink2) +# Test handling of Builder calls that have multiple targets. +env.Command(['touch1.out', 'touch2.out'], + [], + [Touch('${TARGETS[0]}'), Touch('${TARGETS[1]}')]) """ % python) test.write('foo1.in', "foo1.in\n") @@ -67,42 +75,45 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") test.run(arguments = '-c foo1.out', stdout = test.wrap_stdout("Removed foo1.out\n", cleaning=1)) -test.fail_test(os.path.exists(test.workpath('foo1.out'))) -test.fail_test(not os.path.exists(test.workpath('foo2.xxx'))) -test.fail_test(not os.path.exists(test.workpath('foo2.out'))) -test.fail_test(not os.path.exists(test.workpath('foo3.out'))) +test.must_not_exist(test.workpath('foo1.out')) +test.must_exist(test.workpath('foo2.xxx')) +test.must_exist(test.workpath('foo2.out')) +test.must_exist(test.workpath('foo3.out')) test.run(arguments = '--clean foo2.out foo2.xxx', stdout = test.wrap_stdout("Removed foo2.xxx\nRemoved foo2.out\n", cleaning=1)) -test.fail_test(os.path.exists(test.workpath('foo1.out'))) -test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) -test.fail_test(os.path.exists(test.workpath('foo2.out'))) -test.fail_test(not os.path.exists(test.workpath('foo3.out'))) +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_exist(test.workpath('foo3.out')) test.run(arguments = '--remove foo3.out', stdout = test.wrap_stdout("Removed foo3.out\n", cleaning=1)) -test.fail_test(os.path.exists(test.workpath('foo1.out'))) -test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) -test.fail_test(os.path.exists(test.workpath('foo2.out'))) -test.fail_test(os.path.exists(test.workpath('foo3.out'))) +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_not_exist(test.workpath('foo3.out')) test.run(arguments = '.') -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) if hasattr(os, 'symlink'): test.fail_test(not os.path.islink(test.workpath('symlink1'))) @@ -111,43 +122,54 @@ if hasattr(os, 'symlink'): test.run(arguments = '-c foo2.xxx', stdout = test.wrap_stdout("Removed foo2.xxx\n", cleaning=1)) -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) test.run(arguments = '-c .') -test.fail_test(os.path.exists(test.workpath('foo1.out'))) -test.fail_test(os.path.exists(test.workpath('foo2.out'))) -test.fail_test(os.path.exists(test.workpath('foo3.out'))) +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_not_exist(test.workpath('foo3.out')) +test.must_not_exist(test.workpath('touch1.out')) +test.must_not_exist(test.workpath('touch2.out')) if hasattr(os, 'symlink'): test.fail_test(os.path.islink(test.workpath('symlink1'))) test.fail_test(os.path.islink(test.workpath('symlink2'))) -test.run(arguments = 'foo1.out foo2.out foo3.out') +args = 'foo1.out foo2.out foo3.out touch1.out' -expect = test.wrap_stdout("""Removed foo1.out +expect = test.wrap_stdout("""\ +Removed foo1.out Removed foo2.xxx Removed foo2.out Removed foo3.out +Removed touch1.out +Removed touch2.out """, cleaning=1) -test.run(arguments = '-c -n foo1.out foo2.out foo3.out', stdout = expect) +test.run(arguments = args) + +test.run(arguments = '-c -n ' + args, stdout = expect) -test.run(arguments = '-n -c foo1.out foo2.out foo3.out', stdout = expect) +test.run(arguments = '-n -c ' + args, stdout = expect) -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) test.writable('.', 0) f = open(test.workpath('foo1.out')) test.run(arguments = '-c foo1.out', stdout = test.wrap_stdout("scons: Could not remove 'foo1.out': Permission denied\n", cleaning=1)) -test.fail_test(not os.path.exists(test.workpath('foo1.out'))) +test.must_exist(test.workpath('foo1.out')) f.close() test.writable('.', 1) @@ -178,15 +200,15 @@ Removed aux1.x Removed aux2.x """, cleaning=1) test.run(arguments = '-c foo2.xxx', stdout=expect) -test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") -test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) -test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") -test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") expect = test.wrap_stdout("Removed %s\n" % os.path.join('subd', 'foox.in'), cleaning = 1) test.run(arguments = '-c subd', stdout=expect) -test.fail_test(os.path.exists(test.workpath('foox.in'))) +test.must_not_exist(test.workpath('foox.in')) expect = test.wrap_stdout("""Removed foo1.out Removed foo2.xxx @@ -208,8 +230,8 @@ Removed directory subd """ % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')), cleaning = 1) test.run(arguments = '-c .', stdout=expect) -test.fail_test(os.path.exists(test.workpath('subdir', 'foon.in'))) -test.fail_test(os.path.exists(test.workpath('subdir'))) +test.must_not_exist(test.workpath('subdir', 'foon.in')) +test.must_not_exist(test.workpath('subdir')) # Ensure that Set/GetOption('clean') works correctly: @@ -224,7 +246,7 @@ assert not GetOption('clean') test.write('foo.in', '"Foo", I say!\n') test.run(arguments='foo.out') -test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n') +test.must_match(test.workpath('foo.out'), '"Foo", I say!\n') test.write('SConstruct', """ B = Builder(action = r'%s build.py $TARGETS $SOURCES') @@ -237,7 +259,7 @@ assert GetOption('clean') """%python) test.run(arguments='-c foo.out') -test.fail_test(os.path.exists(test.workpath('foo.out'))) +test.must_not_exist(test.workpath('foo.out')) test.write('SConstruct', """ B = Builder(action = r'%s build.py $TARGETS $SOURCES') @@ -246,7 +268,7 @@ env.B(target = 'foo.out', source = 'foo.in') """%python) test.run(arguments='foo.out') -test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n') +test.must_match(test.workpath('foo.out'), '"Foo", I say!\n') test.write('SConstruct', """ B = Builder(action = r'%s build.py $TARGETS $SOURCES') @@ -259,7 +281,7 @@ assert GetOption('clean') """%python) test.run(arguments='foo.out') -test.fail_test(os.path.exists(test.workpath('foo.out'))) +test.must_not_exist(test.workpath('foo.out')) test.pass_test() |