diff options
author | Mats Wichmann <mats@linux.com> | 2022-05-13 14:18:22 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2022-05-31 14:42:08 (GMT) |
commit | c7272c7367f1c3f819645d996c6d93449cf14f5b (patch) | |
tree | 0f62d0d49d2de994a3972426f31d39b2aa9e1fd1 /test/Repository | |
parent | f2eccd82e6b63a4c31ab2797d7f5368a23010295 (diff) | |
download | SCons-c7272c7367f1c3f819645d996c6d93449cf14f5b.zip SCons-c7272c7367f1c3f819645d996c6d93449cf14f5b.tar.gz SCons-c7272c7367f1c3f819645d996c6d93449cf14f5b.tar.bz2 |
Normalize use of test.sleep()
Some tests used time.sleep while others used the harness's test.sleep,
the ones that are done for file timestamp delay management now all use
test.sleep - with a consistent comment, so it's easier to spot.
There are still tests that use time.sleep with smaller intervals that
were left alone.
Affected tests were reformatted, in the spirit of gradually improving
tests that you otherwise touch...
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/Repository')
-rw-r--r-- | test/Repository/no-SConsignFile.py | 14 | ||||
-rw-r--r-- | test/Repository/variants.py | 212 |
2 files changed, 104 insertions, 122 deletions
diff --git a/test/Repository/no-SConsignFile.py b/test/Repository/no-SConsignFile.py index d7f570c..6b5b3e2 100644 --- a/test/Repository/no-SConsignFile.py +++ b/test/Repository/no-SConsignFile.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test that using Repository() works even when the Repository has no @@ -63,13 +62,10 @@ test.write(['src', 'foo.h'], """\ # Make sure it's past the max_drift time, # so the source file signatures get saved. -test.sleep(2) +test.sleep() # delay for timestamps test.run(chdir='build', arguments='.') - -test.run(program=test.workpath('build', 'foo'), - stdout="src/foo.h\nsrc/foo.c\n") - +test.run(program=test.workpath('build', 'foo'), stdout="src/foo.h\nsrc/foo.c\n") test.up_to_date(chdir='build', arguments='.') test.pass_test() diff --git a/test/Repository/variants.py b/test/Repository/variants.py index c95e853..a07d7a0 100644 --- a/test/Repository/variants.py +++ b/test/Repository/variants.py @@ -31,20 +31,22 @@ from TestSCons import TestSCons, _exe, _obj test = TestSCons() -test.subdir('repository', - ['repository', 'src1'], - ['repository', 'src2'], - ['repository', 'src2', 'include'], - ['repository', 'src2', 'xxx'], - ['repository', 'build2'], - ['repository', 'build2', 'foo'], - ['repository', 'build2', 'bar'], - 'work1', - ['work1', 'src1'], - 'work2', - ['work2', 'src2'], - ['work2', 'src2', 'include'], - ['work2', 'src2', 'xxx']) +test.subdir( + 'repository', + ['repository', 'src1'], + ['repository', 'src2'], + ['repository', 'src2', 'include'], + ['repository', 'src2', 'xxx'], + ['repository', 'build2'], + ['repository', 'build2', 'foo'], + ['repository', 'build2', 'bar'], + 'work1', + ['work1', 'src1'], + 'work2', + ['work2', 'src2'], + ['work2', 'src2', 'include'], + ['work2', 'src2', 'xxx'], +) aaa_obj = 'aaa' + _obj bbb_obj = 'bbb' + _obj @@ -56,14 +58,18 @@ repository_build1_foo_xxx = test.workpath('repository', 'build1', 'foo', 'xxx') work1_build1_foo_xxx = test.workpath('work1', 'build1', 'foo', 'xxx') work1_build1_bar_xxx = test.workpath('work1', 'build1', 'bar', 'xxx') -repository_build2_foo_src2_xxx_xxx = test.workpath('repository', 'build2', - 'foo', 'src2', 'xxx', 'xxx') -repository_build2_bar_src2_xxx_xxx = test.workpath('repository', 'build2', - 'bar', 'src2', 'xxx', 'xxx') -work2_build2_foo_src2_xxx_xxx = test.workpath('work2', 'build2', - 'foo', 'src2', 'xxx', 'xxx') -work2_build2_bar_src2_xxx_xxx = test.workpath('work2', 'build2', - 'bar', 'src2', 'xxx', 'xxx') +repository_build2_foo_src2_xxx_xxx = test.workpath( + 'repository', 'build2', 'foo', 'src2', 'xxx', 'xxx' +) +repository_build2_bar_src2_xxx_xxx = test.workpath( + 'repository', 'build2', 'bar', 'src2', 'xxx', 'xxx' +) +work2_build2_foo_src2_xxx_xxx = test.workpath( + 'work2', 'build2', 'foo', 'src2', 'xxx', 'xxx' +) +work2_build2_bar_src2_xxx_xxx = test.workpath( + 'work2', 'build2', 'bar', 'src2', 'xxx', 'xxx' +) opts = "-Y " + test.workpath('repository') @@ -73,12 +79,13 @@ OS = ARGUMENTS.get('OS', '') build1_os = "#build1/" + OS default = Environment() ccflags = { - '' : '', - 'foo' : '-DFOO', - 'bar' : '-DBAR', + '': '', + 'foo': '-DFOO', + 'bar': '-DBAR', } -env1 = Environment(CCFLAGS = default.subst('$CCFLAGS %s' % ccflags[OS]), - CPPPATH = build1_os) +env1 = Environment( + CCFLAGS=default.subst('$CCFLAGS %s' % ccflags[OS]), CPPPATH=build1_os +) VariantDir(build1_os, 'src1') SConscript(build1_os + '/SConscript', "env1") @@ -95,8 +102,9 @@ test.write(['repository', 'build2', 'foo', 'SConscript'], r""" VariantDir('src2', '#src2') default = Environment() -env2 = Environment(CCFLAGS = default.subst('$CCFLAGS -DFOO'), - CPPPATH = ['#src2/xxx', '#src2/include']) +env2 = Environment( + CCFLAGS=default.subst('$CCFLAGS -DFOO'), CPPPATH=['#src2/xxx', '#src2/include'] +) SConscript('src2/xxx/SConscript', "env2") """) @@ -105,8 +113,9 @@ test.write(['repository', 'build2', 'bar', 'SConscript'], r""" VariantDir('src2', '#src2') default = Environment() -env2 = Environment(CCFLAGS = default.subst('$CCFLAGS -DBAR'), - CPPPATH = ['#src2/xxx', '#src2/include']) +env2 = Environment( + CCFLAGS=default.subst('$CCFLAGS -DBAR'), CPPPATH=['#src2/xxx', '#src2/include'] +) SConscript('src2/xxx/SConscript', "env2") """) @@ -216,12 +225,9 @@ repository/src1/bbb.c: REPOSITORY_FOO repository/src1/main.c: REPOSITORY_FOO """) -database_name=test.get_sconsignname() - -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +database_name = test.get_sconsignname() +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) @@ -237,10 +243,8 @@ repository/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) @@ -251,15 +255,10 @@ test.writable('repository', 0) # test.up_to_date(chdir='work1', options=opts + " OS=foo", arguments='build1') -test.fail_test(os.path.exists( - test.workpath('work1', 'build1', 'foo', aaa_obj))) -test.fail_test(os.path.exists( - test.workpath('work1', 'build1', 'foo', bbb_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work1', 'build1', 'foo', main_obj))) - -test.fail_test(os.path.exists( - test.workpath('work1', 'build1', 'foo', xxx_exe))) +test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', aaa_obj))) +test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', bbb_obj))) +test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', main_obj))) +test.fail_test(os.path.exists(test.workpath('work1', 'build1', 'foo', xxx_exe))) # test.run(chdir='work1', options=opts, arguments='OS=bar .') @@ -271,18 +270,13 @@ repository/src1/bbb.c: REPOSITORY_BAR repository/src1/main.c: REPOSITORY_BAR """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) - test.up_to_date(chdir='work1', options=opts + " OS=bar", arguments='build1') -# Ensure file time stamps will be newer. -time.sleep(2) - +test.sleep() # delay for timestamps test.write(['work1', 'src1', 'iii.h'], r""" #ifdef FOO #define STRING "WORK_FOO" @@ -302,13 +296,10 @@ repository/src1/bbb.c: WORK_BAR repository/src1/main.c: WORK_BAR """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) - test.up_to_date(chdir='work1', options=opts + " OS=bar", arguments='build1') # @@ -320,38 +311,39 @@ repository/src1/bbb.c: WORK_FOO repository/src1/main.c: WORK_FOO """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) - test.up_to_date(chdir='work1', options=opts + " OS=foo", arguments='build1') - -# test.up_to_date(chdir='work2', options=opts, arguments='build2') -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'foo', 'src2', 'xxx', aaa_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'foo', 'src2', 'xxx', bbb_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'foo', 'src2', 'xxx', main_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'foo', 'src2', 'xxx', xxx_exe))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'bar', 'src2', 'xxx', aaa_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'bar', 'src2', 'xxx', bbb_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'bar', 'src2', 'xxx', main_obj))) -test.fail_test(os.path.exists(test.workpath( - 'work2', 'build2', 'bar', 'src2', 'xxx', xxx_exe))) - -# Ensure file time stamps will be newer. -time.sleep(2) - +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', aaa_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', bbb_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', main_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'foo', 'src2', 'xxx', xxx_exe)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', aaa_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', bbb_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', main_obj)) +) +test.fail_test( + os.path.exists(test.workpath('work2', 'build2', 'bar', 'src2', 'xxx', xxx_exe)) +) + +test.sleep() # delay for timestamps test.write(['work2', 'src2', 'include', 'my_string.h'], r""" #ifdef FOO #define INCLUDE_OS "FOO" @@ -362,7 +354,6 @@ test.write(['work2', 'src2', 'include', 'my_string.h'], r""" #define INCLUDE_STRING "work2/src2/include/my_string.h: %s\n" """) -# test.run(chdir='work2', options=opts, arguments='build2') test.run(program=work2_build2_foo_src2_xxx_xxx, stdout="""\ @@ -377,16 +368,12 @@ repository/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) -# Ensure file time stamps will be newer. -time.sleep(2) - +test.sleep() # delay for timestamps test.write(['work2', 'src2', 'xxx', 'include.h'], r""" #include <my_string.h> #ifdef FOO @@ -412,38 +399,37 @@ work2/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR """) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) -# test.unlink(['work2', 'src2', 'include', 'my_string.h']) - test.run(chdir='work2', options=opts, arguments='build2') -test.run(program=work2_build2_foo_src2_xxx_xxx, stdout="""\ +test.run( + program=work2_build2_foo_src2_xxx_xxx, + stdout="""\ repository/src2/include/my_string.h: FOO work2/src2/xxx/include.h: FOO repository/src2/xxx/main.c: FOO -""") +""", +) -test.run(program=work2_build2_bar_src2_xxx_xxx, stdout="""\ +test.run( + program=work2_build2_bar_src2_xxx_xxx, + stdout="""\ repository/src2/include/my_string.h: BAR work2/src2/xxx/include.h: BAR repository/src2/xxx/main.c: BAR -""") +""", +) -test.fail_test(os.path.exists( - test.workpath('repository', 'src1', database_name))) -test.fail_test(os.path.exists( - test.workpath('repository', 'src2', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src1', database_name))) +test.fail_test(os.path.exists(test.workpath('repository', 'src2', database_name))) test.fail_test(os.path.exists(test.workpath('work1', 'src1', database_name))) test.fail_test(os.path.exists(test.workpath('work2', 'src2', database_name))) -# test.pass_test() # Local Variables: |