diff options
author | Steven Knight <knight@baldmt.com> | 2002-02-09 22:26:59 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-02-09 22:26:59 (GMT) |
commit | aeefea2d7f66b819bbaf6dff8a8afef63b05722e (patch) | |
tree | 2aa7a54a83057a80ae70daf235f2aefe8477ec0d /test/sconsign.py | |
parent | 490f796a5ca21af009f406e51e751823fef8ee5c (diff) | |
download | SCons-aeefea2d7f66b819bbaf6dff8a8afef63b05722e.zip SCons-aeefea2d7f66b819bbaf6dff8a8afef63b05722e.tar.gz SCons-aeefea2d7f66b819bbaf6dff8a8afef63b05722e.tar.bz2 |
Make writing a .sconsign more robust by writing to a temporary file first and renaming it.
Diffstat (limited to 'test/sconsign.py')
-rw-r--r-- | test/sconsign.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/sconsign.py b/test/sconsign.py new file mode 100644 index 0000000..ac6bf2f --- /dev/null +++ b/test/sconsign.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001, 2002 Steven Knight +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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__" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2') + +test.write('SConstruct', """ +def build1(target, source, env): + open(str(target), 'wb').write(open(str(source[0]), 'rb').read()) + return None + +def build2(target, source, env): + import os + import os.path + open(str(target), 'wb').write(open(str(source[0]), 'rb').read()) + dir, file = os.path.split(target) + os.chmod(dir, 0555) + return None + +B1 = Builder(name = "B1", action = build1) +B2 = Builder(name = "B2", action = build2) +env = Environment(BUILDERS = [B1, B2]) +env.B1(target = 'sub1/foo.out', source = 'foo.in') +env.B2(target = 'sub2/foo.out', source = 'foo.in') +""") + +test.write('foo.in', "foo.in\n") + +sub1__sconsign = test.workpath('sub1', '.sconsign') +sub2__sconsign = test.workpath('sub2', '.sconsign') + +test.write(sub1__sconsign, "") +test.write(sub2__sconsign, "") + +# For *NIX systems, make .sconsign not writable. +# For Win32 systems, open it to lock it. +os.chmod(sub1__sconsign, 0444) +f = open(sub1__sconsign, 'r') + +test.run(arguments = '.') + +test.fail_test(test.read(sub1__sconsign) == "") +test.fail_test(test.read(sub2__sconsign) == "") + +os.chmod(sub1__sconsign, 0666) +f.close() + +test.pass_test() |