diff --git a/CHANGES.txt b/CHANGES.txt index e0691361c2..5383cb7b5f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -182,6 +182,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER Only object-like macros are replaced (not function-like), and only on a whole-word basis; recursion is limited to five levels and does not error out if that limit is reached (issue #4523). + - Minor modernization: make use of stat object's st_mode, st_mtime + and other attributes rather than indexing into stat return. - The update-release-info test is adapted to accept changed help output introduced in Python 3.12.8/3.13.1. diff --git a/RELEASE.txt b/RELEASE.txt index b98c5e6522..d386cb3397 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -164,6 +164,10 @@ FIXES only on a whole-word basis; recursion is limited to five levels and does not error out if that limit is reached (issue #4523). +- Minor modernization: make use of stat object's st_mode, st_mtime + and other attributes rather than indexing into stat return. + + IMPROVEMENTS ------------ diff --git a/SCons/CacheDir.py b/SCons/CacheDir.py index 7f8deb55e1..25e3f666f4 100644 --- a/SCons/CacheDir.py +++ b/SCons/CacheDir.py @@ -71,7 +71,7 @@ def CacheRetrieveFunc(target, source, env) -> int: except OSError: pass st = fs.stat(cachefile) - fs.chmod(t.get_internal_path(), stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + fs.chmod(t.get_internal_path(), stat.S_IMODE(st.st_mode) | stat.S_IWRITE) return 0 def CacheRetrieveString(target, source, env) -> str: diff --git a/SCons/Node/FS.py b/SCons/Node/FS.py index bdecffcfbd..694ff9f87a 100644 --- a/SCons/Node/FS.py +++ b/SCons/Node/FS.py @@ -762,6 +762,8 @@ def getmtime(self): st = self.stat() if st: + # TODO: switch to st.st_mtime, however this changes granularity + # (ST_MTIME is an int for backwards compat, st_mtime is float) return st[stat.ST_MTIME] else: return None diff --git a/SCons/Node/FSTests.py b/SCons/Node/FSTests.py index 9ae8c03e10..1b3704da9f 100644 --- a/SCons/Node/FSTests.py +++ b/SCons/Node/FSTests.py @@ -774,6 +774,7 @@ def test_update(self) -> None: ni.update(fff) + # TODO: flip this to st.st_mtime when Node/FS.py does mtime = st[stat.ST_MTIME] assert ni.timestamp == mtime, (ni.timestamp, mtime) size = st.st_size @@ -786,6 +787,7 @@ def test_update(self) -> None: st = os.stat('fff') + # TODO: flip this to st.st_mtime when Node/FS.py does mtime = st[stat.ST_MTIME] assert ni.timestamp != mtime, (ni.timestamp, mtime) size = st.st_size diff --git a/SCons/Tool/install.py b/SCons/Tool/install.py index d553e31afe..fc20586ff0 100644 --- a/SCons/Tool/install.py +++ b/SCons/Tool/install.py @@ -176,7 +176,7 @@ def copyFunc(dest, source, env) -> int: else: copy2(source, dest) st = os.stat(source) - os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + os.chmod(dest, stat.S_IMODE(st.st_mode) | stat.S_IWRITE) return 0 @@ -204,7 +204,7 @@ def copyFuncVersionedLib(dest, source, env) -> int: pass copy2(source, dest) st = os.stat(source) - os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + os.chmod(dest, stat.S_IMODE(st.st_mode) | stat.S_IWRITE) installShlibLinks(dest, source, env) return 0 diff --git a/site_scons/Utilities.py b/site_scons/Utilities.py index 7ef45a33c6..620595d7ec 100644 --- a/site_scons/Utilities.py +++ b/site_scons/Utilities.py @@ -31,7 +31,7 @@ def whereis(filename): st = os.stat(f_ext) except: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: + if stat.S_IMODE(st.st_mode) & stat.S_IXUSR: return f_ext return None diff --git a/test/Actions/append.py b/test/Actions/append.py index 01a9f23219..8205e1beff 100644 --- a/test/Actions/append.py +++ b/test/Actions/append.py @@ -63,7 +63,7 @@ def after(env, target, source): test.run(arguments='.') test.must_match('before.txt', 'Bar\n') -os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR) +os.chmod(after_exe, os.stat(after_exe).st_mode | stat.S_IXUSR) test.run(program=after_exe, stdout="Foo\n") test.pass_test() diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index ac6a96fd12..0d9f36fce9 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -50,7 +50,7 @@ def before(env, target, source): a=str(target[0]) with open(a, "wb") as f: f.write(b"Foo\\n") - os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR) + os.chmod(a, os.stat(a).st_mode | stat.S_IXUSR) with open("before.txt", "ab") as f: f.write((os.path.splitext(str(target[0]))[0] + "\\n").encode()) @@ -59,7 +59,7 @@ def after(env, target, source): a = "after_" + t with open(t, "rb") as fin, open(a, "wb") as fout: fout.write(fin.read()) - os.chmod(a, os.stat(a)[stat.ST_MODE] | stat.S_IXUSR) + os.chmod(a, os.stat(a).st_mode | stat.S_IXUSR) foo = env.Program(source='foo.c', target='foo') AddPreAction(foo, before) diff --git a/test/Chmod.py b/test/Chmod.py index 7af95b4130..87e7b15acb 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -51,6 +51,7 @@ def cat(env, source, target): f.write(infp.read()) Cat = Action(cat) +DefaultEnvironment(tools=[]) # test speedup env = Environment() env.Command( 'bar.out', @@ -154,92 +155,92 @@ def cat(env, source, target): """) test.run(options = '-n', arguments = '.', stdout = expect) -s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f1')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f1-File')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d2')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d2-Dir')).st_mode) test.fail_test(s != 0o555) test.must_not_exist('bar.out') -s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f3')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d4')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f5')).st_mode) test.fail_test(s != 0o444) test.must_not_exist('f6.out') test.must_not_exist('f7.out') -s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod')).st_mode) test.fail_test(s != 0o444) test.must_not_exist('f8.out') -s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f9')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f10')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d11')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d12')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('f13'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f13')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f14'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f14')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f15'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f15')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('d16'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d16')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('d17'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d17')).st_mode) test.fail_test(s != 0o555) -s = stat.S_IMODE(os.stat(test.workpath('d18'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d18')).st_mode) test.fail_test(s != 0o555) test.run() -s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f1')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f1-File')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d2')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d2-Dir')).st_mode) test.fail_test(s != 0o777) test.must_match('bar.out', "bar.in\n") -s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f3')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d4')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f5')).st_mode) test.fail_test(s != 0o666) test.must_match('f6.out', "f6.in\n") test.must_match('f7.out', "f7.in\n") -s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod')).st_mode) test.fail_test(s != 0o666) test.must_match('f8.out', "f8.in\n") -s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f9')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f10')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d11')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d12')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('f13'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f13')).st_mode) test.fail_test(s != 0o444) -s = stat.S_IMODE(os.stat(test.workpath('f14'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f14')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('f15'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('f15')).st_mode) test.fail_test(s != 0o666) -s = stat.S_IMODE(os.stat(test.workpath('d16'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d16')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('d17'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d17')).st_mode) test.fail_test(s != 0o777) -s = stat.S_IMODE(os.stat(test.workpath('d18'))[stat.ST_MODE]) +s = stat.S_IMODE(os.stat(test.workpath('d18')).st_mode) test.fail_test(s != 0o777) test.pass_test() diff --git a/test/Decider/MD5-timestamp-Repository.py b/test/Decider/MD5-timestamp-Repository.py index 201bdfe496..35e24f4979 100644 --- a/test/Decider/MD5-timestamp-Repository.py +++ b/test/Decider/MD5-timestamp-Repository.py @@ -58,7 +58,7 @@ test.sleep() # delay for timestamps test.write(['Repository','content1.in'], "content1.in 2\n") test.touch(['Repository','content2.in']) -time_content = os.stat(os.path.join(repository,'content3.in'))[stat.ST_MTIME] +time_content = os.stat(os.path.join(repository,'content3.in')).st_mtime test.write(['Repository','content3.in'], "content3.in 2\n") test.touch(['Repository','content3.in'], time_content) diff --git a/test/Decider/MD5-timestamp.py b/test/Decider/MD5-timestamp.py index 3815639672..b8988402b0 100644 --- a/test/Decider/MD5-timestamp.py +++ b/test/Decider/MD5-timestamp.py @@ -54,7 +54,7 @@ test.write('content1.in', "content1.in 2\n") test.touch('content2.in') -time_content = os.stat('content3.in')[stat.ST_MTIME] +time_content = os.stat('content3.in').st_mtime test.write('content3.in', "content3.in 2\n") test.touch('content3.in', time_content) diff --git a/test/Decider/timestamp.py b/test/Decider/timestamp.py index d713a621dd..1fcb9e70d2 100644 --- a/test/Decider/timestamp.py +++ b/test/Decider/timestamp.py @@ -55,8 +55,8 @@ test.run(arguments = '.') test.up_to_date(arguments = '.') -time_match = os.stat('match2.out')[stat.ST_MTIME] -time_newer = os.stat('newer2.out')[stat.ST_MTIME] +time_match = os.stat('match2.out').st_mtime +time_newer = os.stat('newer2.out').st_mtime # Now make all the source files newer than (different timestamps from) # the last time the targets were built, and touch the target files diff --git a/test/Removed/BuildDir/Old/BuildDir.py b/test/Removed/BuildDir/Old/BuildDir.py index 1a1ba02f6e..7463f21eec 100644 --- a/test/Removed/BuildDir/Old/BuildDir.py +++ b/test/Removed/BuildDir/Old/BuildDir.py @@ -224,8 +224,8 @@ def filter_tempnam(err): def equal_stats(x,y): x = os.stat(x) y = os.stat(y) - return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and - x[stat.ST_MTIME] == y[stat.ST_MTIME]) + return (stat.S_IMODE(x.st_mode) == stat.S_IMODE(y.st_mode) and + x.st_mtime == y.st_mtime) # Make sure we did duplicate the source files in build/var2, # and that their stats are the same: @@ -233,7 +233,7 @@ def equal_stats(x,y): test.must_exist(['work1', 'build', 'var2', 'f2.in']) test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f1.c'), test.workpath('work1', 'src', 'f1.c'))) test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f2.in'), test.workpath('work1', 'src', 'f2.in'))) - + # Make sure we didn't duplicate the source files in build/var3. test.must_not_exist(['work1', 'build', 'var3', 'f1.c']) test.must_not_exist(['work1', 'build', 'var3', 'f2.in']) diff --git a/test/Removed/BuildDir/Old/SConscript-build_dir.py b/test/Removed/BuildDir/Old/SConscript-build_dir.py index 0d1ba6abde..ed520370ee 100644 --- a/test/Removed/BuildDir/Old/SConscript-build_dir.py +++ b/test/Removed/BuildDir/Old/SConscript-build_dir.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__" """ Verify that specifying a build_dir argument to SConscript still works. @@ -108,7 +107,7 @@ def cat(env, source, target): # VariantDir('build/var9', '.') # SConscript('build/var9/src/SConscript') SConscript('src/SConscript', build_dir='build/var9', src_dir='.') -""") +""") test.subdir(['test', 'src'], ['test', 'alt']) @@ -152,8 +151,8 @@ def cat(env, source, target): def equal_stats(x,y): x = os.stat(x) y = os.stat(y) - return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and - x[stat.ST_MTIME] == y[stat.ST_MTIME]) + return (stat.S_IMODE(x.st_mode) == stat.S_IMODE(y.st_mode) and + x.st_mtime == y.st_mtime) # Make sure we did duplicate the source files in build/var1, # and that their stats are the same: @@ -168,12 +167,12 @@ def equal_stats(x,y): test.must_exist(test.workpath('test', 'build', 'var2', file)) test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', file), test.workpath('test', 'src', file))) - + # Make sure we didn't duplicate the source files in build/var3. test.must_not_exist(test.workpath('test', 'build', 'var3', 'aaa.in')) test.must_not_exist(test.workpath('test', 'build', 'var3', 'bbb.in')) test.must_not_exist(test.workpath('test', 'build', 'var3', 'ccc.in')) - + #XXX We can't support var4 and var5 yet, because our VariantDir linkage #XXX is to an entire source directory. We haven't yet generalized our #XXX infrastructure to be able to take the SConscript file from one source @@ -200,12 +199,12 @@ def equal_stats(x,y): test.must_exist(test.workpath('build', 'var6', file)) test.fail_test(not equal_stats(test.workpath('build', 'var6', file), test.workpath('test', 'src', file))) - + # Make sure we didn't duplicate the source files in build/var7. test.must_not_exist(test.workpath('build', 'var7', 'aaa.in')) test.must_not_exist(test.workpath('build', 'var7', 'bbb.in')) test.must_not_exist(test.workpath('build', 'var7', 'ccc.in')) - + # Make sure we didn't duplicate the source files in build/var8. test.must_not_exist(test.workpath('build', 'var8', 'aaa.in')) test.must_not_exist(test.workpath('build', 'var8', 'bbb.in')) @@ -219,6 +218,7 @@ def equal_stats(x,y): """) test.write(['test2', 'SConscript'], """\ +DefaultEnvironment(tools=[]) # test speedup env = Environment() foo_obj = env.Object('foo.c') env.Program('foo', [foo_obj, 'bar.c']) diff --git a/test/VariantDir/SConscript-variant_dir.py b/test/VariantDir/SConscript-variant_dir.py index 1e28c47a98..43c3638a1f 100644 --- a/test/VariantDir/SConscript-variant_dir.py +++ b/test/VariantDir/SConscript-variant_dir.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__" """ Verify that specifying a variant_dir argument to SConscript works properly. @@ -64,6 +63,7 @@ def cat(env, source, target): with open(str(src), "rb") as ifp: ofp.write(ifp.read()) +DefaultEnvironment(tools=[]) # test speedup env = Environment(BUILDERS={'Cat':Builder(action=cat)}, BUILD='build') @@ -138,8 +138,8 @@ def cat(env, source, target): def equal_stats(x,y): x = os.stat(x) y = os.stat(y) - return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and - x[stat.ST_MTIME] == y[stat.ST_MTIME]) + return (stat.S_IMODE(x.st_mode) == stat.S_IMODE(y.st_mode) and + x.st_mtime == y.st_mtime) # Make sure we did duplicate the source files in build/var1, # and that their stats are the same: @@ -205,6 +205,7 @@ def equal_stats(x,y): """) test.write(['test2', 'SConscript'], """\ +DefaultEnvironment(tools=[]) # test speedup env = Environment() foo_obj = env.Object('foo.c') env.Program('foo', [foo_obj, 'bar.c']) diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index bd329d8b1b..a173b86531 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -119,7 +119,7 @@ def buildIt(target, source, env): if fortran and env.Detect(fortran): if sys.platform =='win32': - env_prog = Environment(tools=['mingw'], + env_prog = Environment(tools=['mingw'], # BUILD = env['BUILD'], SRC = ENV['src'], CPPPATH=env['CPPPATH'], FORTRANPATH=env['FORTRANPATH'] ) else: @@ -276,8 +276,8 @@ def blank_output(err): def equal_stats(x,y): x = os.stat(x) y = os.stat(y) - return (stat.S_IMODE(x[stat.ST_MODE]) == stat.S_IMODE(y[stat.ST_MODE]) and - x[stat.ST_MTIME] == y[stat.ST_MTIME]) + return (stat.S_IMODE(x.st_mode) == stat.S_IMODE(y.st_mode) and + x.st_mtime == y.st_mtime) # Make sure we did duplicate the source files in build/var2, # and that their stats are the same: @@ -285,7 +285,7 @@ def equal_stats(x,y): test.must_exist(['work1', 'build', 'var2', 'f2.in']) test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f1.c'), test.workpath('work1', 'src', 'f1.c'))) test.fail_test(not equal_stats(test.workpath('work1', 'build', 'var2', 'f2.in'), test.workpath('work1', 'src', 'f2.in'))) - + # Make sure we didn't duplicate the source files in build/var3. test.must_not_exist(['work1', 'build', 'var3', 'f1.c']) test.must_not_exist(['work1', 'build', 'var3', 'f2.in']) @@ -381,7 +381,7 @@ def equal_stats(x,y): test.write( ['work3', 'SConstruct'], """\ SConscriptChdir(0) -VariantDir('build', '.', duplicate=1 ) +VariantDir('build', '.', duplicate=1 ) SConscript( 'build/SConscript' ) """) diff --git a/test/VariantDir/errors.py b/test/VariantDir/errors.py index 1ff3be3c4d..7400056e7e 100644 --- a/test/VariantDir/errors.py +++ b/test/VariantDir/errors.py @@ -65,6 +65,7 @@ def cat(env, source, target): with open(str(src), "r") as f2: f.write(f2.read()) +DefaultEnvironment(tools=[]) # test speedup env = Environment(BUILDERS={'Build':Builder(action=cat)}, SCANNERS=[Scanner(fake_scan, skeys = ['.in'])]) @@ -88,7 +89,7 @@ def cat(env, source, target): if sys.platform != 'win32': dir = os.path.join('ro-dir', 'build') test.subdir(dir) - os.chmod(dir, os.stat(dir)[stat.ST_MODE] & ~stat.S_IWUSR) + os.chmod(dir, os.stat(dir).st_mode & ~stat.S_IWUSR) test.run(chdir = 'ro-dir', arguments = ".", @@ -103,16 +104,16 @@ def cat(env, source, target): test.subdir(dir) SConscript = test.workpath(dir, 'SConscript') test.write(SConscript, '') -os.chmod(SConscript, os.stat(SConscript)[stat.ST_MODE] & ~stat.S_IWUSR) +os.chmod(SConscript, os.stat(SConscript).st_mode & ~stat.S_IWUSR) with open(SConscript, 'r'): - os.chmod(dir, os.stat(dir)[stat.ST_MODE] & ~stat.S_IWUSR) + os.chmod(dir, os.stat(dir).st_mode & ~stat.S_IWUSR) test.run(chdir = 'ro-SConscript', arguments = ".", status = 2, stderr = "scons: *** Cannot duplicate `%s' in `build': Permission denied. Stop.\n" % os.path.join('src', 'SConscript')) - os.chmod('ro-SConscript', os.stat('ro-SConscript')[stat.ST_MODE] | stat.S_IWUSR) + os.chmod('ro-SConscript', os.stat('ro-SConscript').st_mode | stat.S_IWUSR) test.run(chdir = 'ro-SConscript', arguments = ".", @@ -130,9 +131,9 @@ def cat(env, source, target): test.write([dir, 'SConscript'], '') file_in = test.workpath(dir, 'file.in') test.write(file_in, '') -os.chmod(file_in, os.stat(file_in)[stat.ST_MODE] & ~stat.S_IWUSR) +os.chmod(file_in, os.stat(file_in).st_mode & ~stat.S_IWUSR) with open(file_in, 'r'): - os.chmod(dir, os.stat(dir)[stat.ST_MODE] & ~stat.S_IWUSR) + os.chmod(dir, os.stat(dir).st_mode & ~stat.S_IWUSR) test.run(chdir = 'ro-src', arguments = ".", diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index 09115fea13..69f524e152 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -118,9 +118,9 @@ def marker(target, source, env): test.fail_test(test.zipfile_files("f3.xyzzy") != ['file16', 'file17', 'file18']) -f4_size = os.stat('f4.zip')[stat.ST_SIZE] -f4stored_size = os.stat('f4stored.zip')[stat.ST_SIZE] -f4deflated_size = os.stat('f4deflated.zip')[stat.ST_SIZE] +f4_size = os.stat('f4.zip').st_size +f4stored_size = os.stat('f4stored.zip').st_size +f4deflated_size = os.stat('f4deflated.zip').st_size test.fail_test(f4_size != f4deflated_size) test.fail_test(f4stored_size == f4deflated_size) diff --git a/test/option/option--duplicate.py b/test/option/option--duplicate.py index 74de64b646..927de86c93 100644 --- a/test/option/option--duplicate.py +++ b/test/option/option--duplicate.py @@ -28,8 +28,6 @@ SConscript settable option. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import os import sys import stat @@ -85,7 +83,7 @@ } def testLink(file, type): - nl = os.stat(file)[stat.ST_NLINK] + nl = os.stat(file).st_nlink islink = os.path.islink(file) assert criterion[type](nl, islink), \ "Expected %s to be %s (nl %d, islink %d)" \ diff --git a/test/sconsign/script/Configure.py b/test/sconsign/script/Configure.py index 2e1e9c1455..6b064b1ee8 100644 --- a/test/sconsign/script/Configure.py +++ b/test/sconsign/script/Configure.py @@ -76,16 +76,16 @@ # Value node being printed actually begins with a newline. It would # probably be good to change that to a repr() of the contents. expect = r"""=== .: -SConstruct: None \d+ \d+ +SConstruct: None \d+(\.\d*)? \d+ === .sconf_temp: conftest_%(sig_re)s_0.c: - '.*': + '.*':\s #include "math.h" %(sig_re)s \[.*\] conftest_%(sig_re)s_0_%(sig_re)s%(_obj)s: - %(_sconf_temp_conftest_0_c)s: %(sig_re)s \d+ \d+ + %(_sconf_temp_conftest_0_c)s: %(sig_re)s \d+(\.\d*)? \d+ %(CC)s: %(sig_re)s None None %(sig_re)s \[.*\] === %(CC_dir)s: diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 680eae5451..6361ff30e8 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -164,160 +164,160 @@ def process(infp, outfp): test.run_sconsign(arguments=database_name, stdout=r"""=== .: -SConstruct: None \d+ \d+ -fake_cc\.py: %(sig_re)s \d+ \d+ -fake_link\.py: %(sig_re)s \d+ \d+ +SConstruct: None \d+(\.\d*)? \d+ +fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ +fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ === sub1: -hello.c: %(sig_re)s \d+ \d+ -hello.exe: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +hello.c: %(sig_re)s \d+(\.\d*)? \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] === sub2: -hello.c: %(sig_re)s \d+ \d+ -hello.exe: %(sig_re)s \d+ \d+ - %(sub2_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +hello.c: %(sig_re)s \d+(\.\d*)? \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -inc1.h: %(sig_re)s \d+ \d+ -inc2.h: %(sig_re)s \d+ \d+ +inc1.h: %(sig_re)s \d+(\.\d*)? \d+ +inc2.h: %(sig_re)s \d+(\.\d*)? \d+ """ % locals()) test.run_sconsign(arguments="--raw " + database_name, stdout=r"""=== .: -SConstruct: {'csig': None, 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +SConstruct: {'csig': None, 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} === sub1: -hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] === sub2: -hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} """ % locals()) expect = r"""=== .: SConstruct: csig: None - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_cc\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_link\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ === sub1: hello.c: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ hello.exe: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub1_hello_obj)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_link\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] hello.obj: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub1_hello_c)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_cc\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] === sub2: hello.c: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ hello.exe: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub2_hello_obj)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_link\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] hello.obj: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub2_hello_c)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ %(sub2_inc1_h)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ %(sub2_inc2_h)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_cc\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] inc1.h: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ inc2.h: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ """ % locals() @@ -382,44 +382,44 @@ def process(infp, outfp): test.run_sconsign(arguments="-t -v " + database_name, stdout=r"""=== .: SConstruct: - timestamp: \d+ + timestamp: \d+(\.\d*)? fake_cc\.py: - timestamp: \d+ + timestamp: \d+(\.\d*)? fake_link\.py: - timestamp: \d+ + timestamp: \d+(\.\d*)? === sub1: hello.c: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.exe: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.obj: - timestamp: \d+ + timestamp: \d+(\.\d*)? === sub2: hello.c: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.exe: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.obj: - timestamp: \d+ + timestamp: \d+(\.\d*)? inc1.h: - timestamp: \d+ + timestamp: \d+(\.\d*)? inc2.h: - timestamp: \d+ + timestamp: \d+(\.\d*)? """) test.run_sconsign(arguments="-e hello.obj " + database_name, stdout=r"""=== .: === sub1: -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] === sub2: -hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals(), stderr=r"""sconsign: no entry `hello\.obj' in `\.' @@ -428,34 +428,34 @@ def process(infp, outfp): test.run_sconsign(arguments="-e hello.obj -e hello.exe -e hello.obj " + database_name, stdout=r"""=== .: === sub1: -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.exe: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] === sub2: -hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.exe: %(sig_re)s \d+ \d+ - %(sub2_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals(), stderr=r"""sconsign: no entry `hello\.obj' in `\.' diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 2225f83bbf..a355068de3 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -169,26 +169,26 @@ def process(infp, outfp): test.run_sconsign( arguments=f"-e hello.exe -e hello.obj sub1/{database_name}", - stdout=r"""hello.exe: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: None \d+ \d+ + stdout=r"""hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: None \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: None \d+ \d+ - fake_cc\.py: None \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: None \d+(\.\d*)? \d+ + fake_cc\.py: None \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals(), ) test.run_sconsign( arguments=f"-e hello.exe -e hello.obj -r sub1/{database_name}", - stdout=r"""hello.exe: %(sig_re)s '%(date_re)s' \d+ - %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+ - fake_link\.py: None '%(date_re)s' \d+ + stdout=r"""hello.exe: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + fake_link\.py: None '%(date_re)s' \d+(\.\d*)? %(sig_re)s \[.*\] -hello.obj: %(sig_re)s '%(date_re)s' \d+ - %(sub1_hello_c)s: None '%(date_re)s' \d+ - fake_cc\.py: None '%(date_re)s' \d+ +hello.obj: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + %(sub1_hello_c)s: None '%(date_re)s' \d+(\.\d*)? + fake_cc\.py: None '%(date_re)s' \d+(\.\d*)? %(sig_re)s \[.*\] """ % locals(), ) diff --git a/test/sconsign/script/dblite.py b/test/sconsign/script/dblite.py index 24d8403c47..0d05d5522c 100644 --- a/test/sconsign/script/dblite.py +++ b/test/sconsign/script/dblite.py @@ -116,24 +116,24 @@ def escape_drive_case(s): manifest = '' expect = r"""=== sub1: -hello%(_exe)s: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - %(LINK)s: None \d+ \d+ +hello%(_exe)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + %(LINK)s: None \d+(\.\d*)? \d+ %(sig_re)s \[.*%(manifest)s\] -hello%(_obj)s: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: None \d+ \d+ - %(CC)s: None \d+ \d+ +hello%(_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: None \d+(\.\d*)? \d+ + %(CC)s: None \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals() expect_r = r"""=== sub1: -hello%(_exe)s: %(sig_re)s '%(date_re)s' \d+ - %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+ - %(LINK)s: None '%(date_re)s' \d+ +hello%(_exe)s: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + %(LINK)s: None '%(date_re)s' \d+(\.\d*)? %(sig_re)s \[.*%(manifest)s\] -hello%(_obj)s: %(sig_re)s '%(date_re)s' \d+ - %(sub1_hello_c)s: None '%(date_re)s' \d+ - %(CC)s: None '%(date_re)s' \d+ +hello%(_obj)s: %(sig_re)s '%(date_re)s' \d+(\.\d*)? + %(sub1_hello_c)s: None '%(date_re)s' \d+(\.\d*)? + %(CC)s: None '%(date_re)s' \d+(\.\d*)? %(sig_re)s \[.*\] """ % locals() diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 7a41c72cb2..5760bf230f 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -168,62 +168,62 @@ def process(infp, outfp): sig_re = r'[0-9a-fA-F]{32,64}' -expect = r"""hello.c: %(sig_re)s \d+ \d+ -hello.exe: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +expect = r"""hello.c: %(sig_re)s \d+(\.\d*)? \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals() test.run_sconsign(arguments = f"sub1/{database_name}", stdout=expect) test.run_sconsign(arguments = f"--raw sub1/{database_name}", - stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+(\.\d*)?L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] """ % locals()) test.run_sconsign(arguments = f"-v sub1/{database_name}", stdout = r"""hello.c: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ hello.exe: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub1_hello_obj)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_link\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] hello.obj: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ implicit: %(sub1_hello_c)s: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ fake_cc\.py: csig: %(sig_re)s - timestamp: \d+ + timestamp: \d+(\.\d*)? size: \d+ action: %(sig_re)s \[.*\] """ % locals()) @@ -248,73 +248,73 @@ def process(infp, outfp): test.run_sconsign(arguments = f"-t -v sub1/{database_name}", stdout = r"""hello.c: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.exe: - timestamp: \d+ + timestamp: \d+(\.\d*)? hello.obj: - timestamp: \d+ + timestamp: \d+(\.\d*)? """ % locals()) test.run_sconsign(arguments = f"-e hello.obj sub1/{database_name}", - stdout = r"""hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ + stdout = r"""hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals()) test.run_sconsign(arguments = f"-e hello.obj -e hello.exe -e hello.obj sub1/{database_name}", - stdout = r"""hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ + stdout = r"""hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.exe: %(sig_re)s \d+ \d+ - %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals()) test.run_sconsign(arguments = f"sub2/{database_name}", - stdout = r"""hello.c: %(sig_re)s \d+ \d+ -hello.exe: %(sig_re)s \d+ \d+ - %(sub2_hello_obj)s: %(sig_re)s \d+ \d+ - fake_link\.py: %(sig_re)s \d+ \d+ + stdout = r"""hello.c: %(sig_re)s \d+(\.\d*)? \d+ +hello.exe: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_obj)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_link\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -inc1.h: %(sig_re)s \d+ \d+ -inc2.h: %(sig_re)s \d+ \d+ +inc1.h: %(sig_re)s \d+(\.\d*)? \d+ +inc2.h: %(sig_re)s \d+(\.\d*)? \d+ """ % locals()) #test.run_sconsign(arguments = "-i -v sub2/{}".format(database_name), -# stdout = r"""hello.c: %(sig_re)s \d+ \d+ -#hello.exe: %(sig_re)s \d+ \d+ +# stdout = r"""hello.c: %(sig_re)s \d+(\.\d*)? \d+ +#hello.exe: %(sig_re)s \d+(\.\d*)? \d+ # implicit: -# hello.obj: %(sig_re)s \d+ \d+ -#hello.obj: %(sig_re)s \d+ \d+ +# hello.obj: %(sig_re)s \d+(\.\d*)? \d+ +#hello.obj: %(sig_re)s \d+(\.\d*)? \d+ # implicit: -# hello.c: %(sig_re)s \d+ \d+ -# inc1.h: %(sig_re)s \d+ \d+ -# inc2.h: %(sig_re)s \d+ \d+ +# hello.c: %(sig_re)s \d+(\.\d*)? \d+ +# inc1.h: %(sig_re)s \d+(\.\d*)? \d+ +# inc2.h: %(sig_re)s \d+(\.\d*)? \d+ #""" % locals()) test.run_sconsign(arguments = f"-e hello.obj sub2/{database_name} sub1/{database_name}", - stdout = r"""hello.obj: %(sig_re)s \d+ \d+ - %(sub2_hello_c)s: %(sig_re)s \d+ \d+ - %(sub2_inc1_h)s: %(sig_re)s \d+ \d+ - %(sub2_inc2_h)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ + stdout = r"""hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc1_h)s: %(sig_re)s \d+(\.\d*)? \d+ + %(sub2_inc2_h)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] -hello.obj: %(sig_re)s \d+ \d+ - %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - fake_cc\.py: %(sig_re)s \d+ \d+ +hello.obj: %(sig_re)s \d+(\.\d*)? \d+ + %(sub1_hello_c)s: %(sig_re)s \d+(\.\d*)? \d+ + fake_cc\.py: %(sig_re)s \d+(\.\d*)? \d+ %(sig_re)s \[.*\] """ % locals()) diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 56c282c990..4863a13c82 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -811,7 +811,7 @@ def where_is(file, path=None, pathext=None): st = os.stat(f) except OSError: continue - if stat.S_IMODE(st[stat.ST_MODE]) & 0o111: + if stat.S_IMODE(st.st_mode) & stat.S_IXUSR: return f return None @@ -1978,7 +1978,7 @@ def do_chmod(fname) -> None: pass else: os.chmod(fname, stat.S_IMODE( - st[stat.ST_MODE] | stat.S_IREAD)) + st.st_mode | stat.S_IREAD)) else: def do_chmod(fname) -> None: try: @@ -1987,7 +1987,7 @@ def do_chmod(fname) -> None: pass else: os.chmod(fname, stat.S_IMODE( - st[stat.ST_MODE] & ~stat.S_IREAD)) + st.st_mode & ~stat.S_IREAD)) if os.path.isfile(top): # If it's a file, that's easy, just chmod it. @@ -2047,7 +2047,7 @@ def do_chmod(fname) -> None: except OSError: pass else: - os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE] | stat.S_IWRITE)) + os.chmod(fname, stat.S_IMODE(st.st_mode | stat.S_IWRITE)) else: def do_chmod(fname) -> None: try: @@ -2056,7 +2056,7 @@ def do_chmod(fname) -> None: pass else: os.chmod(fname, stat.S_IMODE( - st[stat.ST_MODE] & ~stat.S_IWRITE)) + st.st_mode & ~stat.S_IWRITE)) if os.path.isfile(top): do_chmod(top) @@ -2087,7 +2087,7 @@ def do_chmod(fname) -> None: pass else: os.chmod(fname, stat.S_IMODE( - st[stat.ST_MODE] | stat.S_IEXEC)) + st.st_mode | stat.S_IEXEC)) else: def do_chmod(fname) -> None: try: @@ -2096,7 +2096,7 @@ def do_chmod(fname) -> None: pass else: os.chmod(fname, stat.S_IMODE( - st[stat.ST_MODE] & ~stat.S_IEXEC)) + st.st_mode & ~stat.S_IEXEC)) if os.path.isfile(top): # If it's a file, that's easy, just chmod it. diff --git a/testing/framework/TestCmdTests.py b/testing/framework/TestCmdTests.py index 61c0c5da97..f7a437b106 100644 --- a/testing/framework/TestCmdTests.py +++ b/testing/framework/TestCmdTests.py @@ -47,15 +47,15 @@ def _is_readable(path): # XXX this doesn't take into account UID, it assumes it's our file - return os.stat(path)[stat.ST_MODE] & stat.S_IREAD + return os.stat(path).st_mode & stat.S_IREAD def _is_writable(path): # XXX this doesn't take into account UID, it assumes it's our file - return os.stat(path)[stat.ST_MODE] & stat.S_IWRITE + return os.stat(path).st_mode & stat.S_IWRITE def _is_executable(path): # XXX this doesn't take into account UID, it assumes it's our file - return os.stat(path)[stat.ST_MODE] & stat.S_IEXEC + return os.stat(path).st_mode & stat.S_IEXEC def _clear_dict(dict, *keys) -> None: for key in keys: @@ -268,17 +268,17 @@ def test_chmod(self) -> None: test.chmod(wdir_file1, stat.S_IREAD) test.chmod(['sub', 'file2'], stat.S_IWRITE) - file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) + file1_mode = stat.S_IMODE(os.stat(wdir_file1).st_mode) assert file1_mode == 0o444, f'0{file1_mode:o}' - file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) + file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2).st_mode) assert file2_mode == 0o666, f'0{file2_mode:o}' test.chmod('file1', stat.S_IWRITE) test.chmod(wdir_sub_file2, stat.S_IREAD) - file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) + file1_mode = stat.S_IMODE(os.stat(wdir_file1).st_mode) assert file1_mode == 0o666, f'0{file1_mode:o}' - file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) + file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2).st_mode) assert file2_mode == 0o444, f'0{file2_mode:o}' else: @@ -286,17 +286,17 @@ def test_chmod(self) -> None: test.chmod(wdir_file1, 0o700) test.chmod(['sub', 'file2'], 0o760) - file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) + file1_mode = stat.S_IMODE(os.stat(wdir_file1).st_mode) assert file1_mode == 0o700, f'0{file1_mode:o}' - file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) + file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2).st_mode) assert file2_mode == 0o760, f'0{file2_mode:o}' test.chmod('file1', 0o765) test.chmod(wdir_sub_file2, 0o567) - file1_mode = stat.S_IMODE(os.stat(wdir_file1)[stat.ST_MODE]) + file1_mode = stat.S_IMODE(os.stat(wdir_file1).st_mode) assert file1_mode == 0o765, f'0{file1_mode:o}' - file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2)[stat.ST_MODE]) + file2_mode = stat.S_IMODE(os.stat(wdir_sub_file2).st_mode) assert file2_mode == 0o567, f'0{file2_mode:o}' @@ -3315,11 +3315,11 @@ def test_executable(self) -> None: def make_executable(fname) -> None: st = os.stat(fname) - os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0o100)) + os.chmod(fname, stat.S_IMODE(st.st_mode|0o100)) def make_non_executable(fname) -> None: st = os.stat(fname) - os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0o100)) + os.chmod(fname, stat.S_IMODE(st.st_mode&~0o100)) test.executable(test.workdir, 0) # XXX skip these tests if euid == 0? diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 470dbcb208..5038f1a665 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -215,7 +215,7 @@ def is_Sequence(e): hasattr(e, "__iter__")) def is_writable(f): - mode = os.stat(f)[stat.ST_MODE] + mode = os.stat(f).st_mode return mode & stat.S_IWUSR def separate_files(flist): diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index 3f7d3fd2e4..5ed2779c0a 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -222,7 +222,7 @@ def test_writable_file_exists(self) -> None: tc = TestCommon(workdir='') tc.write('file1', "file1\\n") f1 = tc.workpath('file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode | stat.S_IWUSR) tc.must_be_writable('file1') tc.pass_test() @@ -244,7 +244,7 @@ def test_non_writable_file_exists(self) -> None: tc = TestCommon(workdir='') tc.write('file1', "file1\\n") f1 = tc.workpath('file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode & ~stat.S_IWUSR) tc.must_be_writable('file1') tc.pass_test() @@ -267,7 +267,7 @@ def test_file_specified_as_list(self) -> None: tc.subdir('sub') tc.write(['sub', 'file1'], "sub/file1\\n") f1 = tc.workpath('sub', 'file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode | stat.S_IWUSR) tc.must_be_writable(['sub', 'file1']) tc.pass_test() @@ -1253,7 +1253,7 @@ def test_writable_file_exists(self) -> None: tc = TestCommon(workdir='') tc.write('file1', "file1\\n") f1 = tc.workpath('file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode | stat.S_IWUSR) tc.must_not_be_writable('file1') tc.pass_test() @@ -1275,7 +1275,7 @@ def test_non_writable_file_exists(self) -> None: tc = TestCommon(workdir='') tc.write('file1', "file1\\n") f1 = tc.workpath('file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode & ~stat.S_IWUSR) tc.must_not_be_writable('file1') tc.pass_test() @@ -1298,7 +1298,7 @@ def test_file_specified_as_list(self) -> None: tc.subdir('sub') tc.write(['sub', 'file1'], "sub/file1\\n") f1 = tc.workpath('sub', 'file1') - mode = os.stat(f1)[stat.ST_MODE] + mode = os.stat(f1).st_mode os.chmod(f1, mode & ~stat.S_IWUSR) tc.must_not_be_writable(['sub', 'file1']) tc.pass_test()