From 4c83816c2bdd84cc67a6935142b99312416f25d6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 20 Mar 2017 15:18:31 -0700 Subject: added mode='r' for must_matches, and for one case added mode='w' for source file failing to compile with compiler complaining about mac formatted file --- test/Default.py | 61 ++++++++++++++++++++++++------------------------------- test/srcchange.py | 2 +- test/subdir.py | 8 ++++---- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/test/Default.py b/test/Default.py index e9ca96a..05944a6 100644 --- a/test/Default.py +++ b/test/Default.py @@ -36,13 +36,10 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -for dir in ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']: - - test.subdir(dir) - - test.write(os.path.join(dir, 'foo.in'), dir + "/foo.in\n"); - - test.write(os.path.join(dir, 'bar.in'), dir + "/bar.in\n"); +for dirname in ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']: + test.subdir(dirname) + test.write(os.path.join(dirname, 'foo.in'), dirname + "/foo.in\n") + test.write(os.path.join(dirname, 'bar.in'), dirname + "/bar.in\n") test.write('build.py', r""" import sys @@ -94,26 +91,24 @@ Default(env.B(target = 'bar.out', source = 'bar.in')) """ % locals()) -for dir in ['one', 'two', 'three', 'four', 'five']: +for dirname in ['one', 'two', 'three', 'four', 'five']: + test.run(chdir=dirname) # no arguments, use the Default - test.run(chdir = dir) # no arguments, use the Default - -test.must_match(test.workpath('one', 'foo.out'), "one/foo.in\n") +test.must_match(test.workpath('one', 'foo.out'), "one/foo.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('one', 'bar'))) -test.must_match(test.workpath('two', 'foo.out'), "two/foo.in\n") -test.must_match(test.workpath('two', 'bar.out'), "two/bar.in\n") +test.must_match(test.workpath('two', 'foo.out'), "two/foo.in\n", mode='r') +test.must_match(test.workpath('two', 'bar.out'), "two/bar.in\n", mode='r') -test.must_match(test.workpath('three', 'foo.out'), "three/foo.in\n") -test.must_match(test.workpath('three', 'bar.out'), "three/bar.in\n") +test.must_match(test.workpath('three', 'foo.out'), "three/foo.in\n", mode='r') +test.must_match(test.workpath('three', 'bar.out'), "three/bar.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('four', 'foo'))) test.fail_test(os.path.exists(test.workpath('four', 'bar'))) -test.must_match(test.workpath('four', 'foo bar'), "four/foo.in\n") - -test.must_match(test.workpath('five', 'foo.out'), "five/foo.in\n") -test.must_match(test.workpath('five', 'bar.out'), "five/bar.in\n") +test.must_match(test.workpath('four', 'foo bar'), "four/foo.in\n", mode='r') +test.must_match(test.workpath('five', 'foo.out'), "five/foo.in\n", mode='r') +test.must_match(test.workpath('five', 'bar.out'), "five/bar.in\n", mode='r') # Test how a None Default() argument works to disable/reset default targets. @@ -125,8 +120,8 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(None) """ % locals()) -test.run(chdir = 'six', status = 2, stderr = -"scons: *** No targets specified and no Default() targets found. Stop.\n") +test.run(chdir='six', status=2, + stderr="scons: *** No targets specified and no Default() targets found. Stop.\n") test.write(['seven', 'SConstruct'], """\ B = Builder(action = r'%(_python_)s ../build.py $TARGET $SOURCES') @@ -136,8 +131,8 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(foo, bar, None) """ % locals()) -test.run(chdir = 'seven', status = 2, stderr = -"scons: *** No targets specified and no Default() targets found. Stop.\n") +test.run(chdir='seven', status=2, + stderr="scons: *** No targets specified and no Default() targets found. Stop.\n") test.write(['eight', 'SConstruct'], """\ B = Builder(action = r'%(_python_)s ../build.py $TARGET $SOURCES') @@ -147,12 +142,10 @@ bar = env.B(target = 'bar.out', source = 'bar.in') Default(foo, None, bar) """ % locals()) -test.run(chdir = 'eight') # no arguments, use the Default +test.run(chdir='eight') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('eight', 'foo.out'))) -test.must_match(test.workpath('eight', 'bar.out'), "eight/bar.in\n") - - +test.must_match(test.workpath('eight', 'bar.out'), "eight/bar.in\n", mode='r') test.subdir('nine', ['nine', 'sub1']) @@ -175,11 +168,10 @@ Default('xxx.out') test.write(['nine', 'sub1', 'xxx.in'], "sub1/xxx.in\n") -test.run(chdir = 'nine') # no arguments, use the Default +test.run(chdir='nine') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('nine', 'xxx.out'))) -test.must_match(test.workpath('nine', 'sub1', 'xxx.out'), "sub1/xxx.in\n") - +test.must_match(test.workpath('nine', 'sub1', 'xxx.out'), "sub1/xxx.in\n", mode='r') test.subdir('ten', ['ten', 'sub2']) @@ -202,10 +194,10 @@ env.B(target = 'xxx.out', source = 'xxx.in') test.write(['ten', 'sub2', 'xxx.in'], "sub2/xxx.in\n") -test.run(chdir = 'ten') # no arguments, use the Default +test.run(chdir='ten') # no arguments, use the Default test.fail_test(os.path.exists(test.workpath('ten', 'xxx.out'))) -test.must_match(test.workpath('ten', 'sub2', 'xxx.out'), "sub2/xxx.in\n") +test.must_match(test.workpath('ten', 'sub2', 'xxx.out'), "sub2/xxx.in\n", mode='r') test.subdir('eleven') @@ -222,13 +214,12 @@ test.write(os.path.join('eleven', 'foo.in'), "eleven/foo.in\n") test.write(os.path.join('eleven', 'bar.in'), "eleven/bar.in\n") -test.run(chdir = 'eleven') # no arguments, use the Default +test.run(chdir='eleven') # no arguments, use the Default -test.must_match(test.workpath('eleven', 'foo.out'), "eleven/foo.in\n") +test.must_match(test.workpath('eleven', 'foo.out'), "eleven/foo.in\n", mode='r') test.fail_test(os.path.exists(test.workpath('eleven', 'bar'))) - test.pass_test() # Local Variables: diff --git a/test/srcchange.py b/test/srcchange.py index bef3589..f9e1523 100644 --- a/test/srcchange.py +++ b/test/srcchange.py @@ -103,7 +103,7 @@ test.must_exist(program_name) test.run(arguments='.', stdout=light_build) test.must_exist(program_name) -test.write('revnum.in', '3.3\n') +test.write('revnum.in', '3.3\n', mode='w') test.run(arguments='.') test.must_exist(program_name) diff --git a/test/subdir.py b/test/subdir.py index 67e8450..9a8b762 100644 --- a/test/subdir.py +++ b/test/subdir.py @@ -57,10 +57,10 @@ test.write(['subdir', 'f4.in'], "f4.in\n") test.run(arguments = 'subdir') -test.must_match(['subdir', 'f1.out'], "f1.in\n") -test.must_match(['subdir', 'f2.out'], "f2.in\n") -test.must_match(['subdir', 'f3.out'], "f3.in\n") -test.must_match(['subdir', 'f4.out'], "f4.in\n") +test.must_match(['subdir', 'f1.out'], "f1.in\n", mode='r') +test.must_match(['subdir', 'f2.out'], "f2.in\n", mode='r') +test.must_match(['subdir', 'f3.out'], "f3.in\n", mode='r') +test.must_match(['subdir', 'f4.out'], "f4.in\n", mode='r') test.up_to_date(arguments = 'subdir') -- cgit v0.12