From 2ea0998e830a3b1047f20033601f4167c26b2839 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 5 Aug 2002 03:11:59 +0000 Subject: [PATCH] Fix incorrect time stamp for linked files (Bug 589288) (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@426 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Node/FS.py | 2 +- test/BuildDir.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index dfea21b6..8bdfeb65 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -49,7 +49,7 @@ except AttributeError: import shutil import stat def file_link(src, dest): - shutil.copyfile(src, dest) + shutil.copy2(src, dest) st=os.stat(src) os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) diff --git a/test/BuildDir.py b/test/BuildDir.py index a283ac73..79f0eb02 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -195,6 +195,22 @@ if f77: test.run(program = bar51, stdout = " b1.for\n") test.run(program = bar52, stdout = " b2.for\n") + +import os +import stat +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_ATIME] == y[stat.ST_ATIME] and + x[stat.ST_MTIME] == y[stat.ST_MTIME]) + +# Make sure we did duplicate the source files in build/var2, and that their stats are the same: +test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var2', 'f1.c'))) +test.fail_test(not os.path.exists(test.workpath('test', 'build', 'var2', 'f2.in'))) +test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', 'f1.c'), test.workpath('test', 'src', 'f1.c'))) +test.fail_test(not equal_stats(test.workpath('test', 'build', 'var2', 'f2.in'), test.workpath('test', 'src', 'f2.in'))) + # Make sure we didn't duplicate the source files in build/var3. test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'f1.c'))) test.fail_test(os.path.exists(test.workpath('test', 'build', 'var3', 'f2.in'))) -- 2.26.2