diff options
author | Mats Wichmann <mats@linux.com> | 2021-04-18 15:24:03 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-04-18 17:18:25 (GMT) |
commit | 85f75affc4b92bdf0db3dd1c35cd875320ba5f26 (patch) | |
tree | 56346748d90dec1d6389d18073922cd30a3eaa21 | |
parent | 59c4c2ca4fce8392852e5e907bbb9e89b1daae15 (diff) | |
download | SCons-85f75affc4b92bdf0db3dd1c35cd875320ba5f26.zip SCons-85f75affc4b92bdf0db3dd1c35cd875320ba5f26.tar.gz SCons-85f75affc4b92bdf0db3dd1c35cd875320ba5f26.tar.bz2 |
[PR 3931] add a testcase
Undo the doc change which describes what happens -
seems better not to promise about permissions of
installed files.
Did the header change on Install tests.
Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r-- | SCons/Tool/install.xml | 6 | ||||
-rw-r--r-- | test/Install/Clone.py | 7 | ||||
-rw-r--r-- | test/Install/INSTALLSTR.py | 7 | ||||
-rw-r--r-- | test/Install/Install-ro.py | 46 | ||||
-rw-r--r-- | test/Install/Install.py | 7 | ||||
-rw-r--r-- | test/Install/InstallAs.py | 8 | ||||
-rw-r--r-- | test/Install/dir-exists.py | 9 | ||||
-rw-r--r-- | test/Install/directories.py | 31 | ||||
-rw-r--r-- | test/Install/fixture/SConstruct-multi | 24 | ||||
-rw-r--r-- | test/Install/multi-dir.py | 7 | ||||
-rw-r--r-- | test/Install/multi.py | 10 | ||||
-rw-r--r-- | test/Install/no-top-relative.py | 7 | ||||
-rw-r--r-- | test/Install/non-ascii-name.py | 8 | ||||
-rw-r--r-- | test/Install/option--install-sandbox.py | 12 | ||||
-rw-r--r-- | test/Install/tool.py | 11 | ||||
-rw-r--r-- | test/Install/wrap-by-attribute.py | 24 |
16 files changed, 139 insertions, 85 deletions
diff --git a/SCons/Tool/install.xml b/SCons/Tool/install.xml index 81e486f..f4295a0 100644 --- a/SCons/Tool/install.xml +++ b/SCons/Tool/install.xml @@ -46,9 +46,7 @@ which must be a directory. The names of the specified source files or directories remain the same within the destination directory. The sources may be given as a string or as a node returned by -a builder. Basic metadata from the source files is -preserved, except that the target files will be marked -as writable. +a builder. </para> <example_commands> @@ -120,8 +118,6 @@ See the note under &Install;. <para> Installs a versioned shared library. The symlinks appropriate to the architecture will be generated based on symlinks of the source library. -Basic metadata from the source library is preserved, -except that the target file will be marked as writable. </para> <example_commands> diff --git a/test/Install/Clone.py b/test/Install/Clone.py index 14e0688..c88a078 100644 --- a/test/Install/Clone.py +++ b/test/Install/Clone.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 we can Install() and InstallAs() from a construction diff --git a/test/Install/INSTALLSTR.py b/test/Install/INSTALLSTR.py index ace04f4..3ce71be 100644 --- a/test/Install/INSTALLSTR.py +++ b/test/Install/INSTALLSTR.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 the $INSTALLSTR variable is displayed when we install a file. diff --git a/test/Install/Install-ro.py b/test/Install/Install-ro.py new file mode 100644 index 0000000..4a929dc --- /dev/null +++ b/test/Install/Install-ro.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# MIT Licenxe +# +# 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 +# "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. + +""" +Test that SCons allows Install on top of an existing read-only file. +""" + +import sys +import os +import os.path +import TestSCons + +test = TestSCons.TestSCons() + +test.file_fixture('fixture/SConstruct-multi', 'SConstruct') +test.run(arguments=["-Q"]) +test.run(arguments=["-Q"]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: diff --git a/test/Install/Install.py b/test/Install/Install.py index 0647002..2857c72 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 the Install() Builder works diff --git a/test/Install/InstallAs.py b/test/Install/InstallAs.py index 47ee9f6..24a9ddc 100644 --- a/test/Install/InstallAs.py +++ b/test/Install/InstallAs.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 the InstallAs() Environment method. @@ -83,7 +82,6 @@ test.must_match(install_file1a_out, "file1.in\n", mode='r') test.up_to_date(arguments = '.') -# test.pass_test() # Local Variables: diff --git a/test/Install/dir-exists.py b/test/Install/dir-exists.py index 9882d22..9e9a9b0 100644 --- a/test/Install/dir-exists.py +++ b/test/Install/dir-exists.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 using Install() on directories that exist. @@ -49,7 +48,7 @@ Mkdir("b") echo hi > a%sf Install directory: "a" as "b%sa" """%(os.sep, os.sep) -test.run(arguments = ["-Q"], stdout = expect) +test.run(arguments=["-Q"], stdout=expect) test.must_exist(test.workpath('a', 'f')) test.must_exist(test.workpath('b', 'a', 'f')) diff --git a/test/Install/directories.py b/test/Install/directories.py index e980936..66182b7 100644 --- a/test/Install/directories.py +++ b/test/Install/directories.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 using Install() on directories. @@ -33,16 +32,18 @@ import TestSCons test = TestSCons.TestSCons() -test.subdir('outside', - 'work', - ['work', 'dir1'], - ['work', 'dir1', 'sub'], - ['work', 'dir2'], - ['work', 'dir2', 'sub'], - ['work', 'dir3'], - ['work', 'dir3', 'sub'], - ['work', 'dir4'], - ['work', 'dir4', 'sub']) +test.subdir( + 'outside', + 'work', + ['work', 'dir1'], + ['work', 'dir1', 'sub'], + ['work', 'dir2'], + ['work', 'dir2', 'sub'], + ['work', 'dir3'], + ['work', 'dir3', 'sub'], + ['work', 'dir4'], + ['work', 'dir4', 'sub'], +) test.write(['work', 'SConstruct'], """\ DefaultEnvironment(tools=[]) @@ -80,7 +81,7 @@ Install directory: "dir3" as "%s" Install directory: "dir4" as "%s" """ % tuple(arguments)) -test.run(chdir = 'work', arguments = arguments, stdout = expect) +test.run(chdir='work', arguments=arguments, stdout=expect) test.must_match(test.workpath('outside', 'dir1', 'f2'), "work/dir1/f2\n") test.must_match(test.workpath('outside', 'dir1', 'sub', 'f3'), "work/dir1/sub/f3\n") diff --git a/test/Install/fixture/SConstruct-multi b/test/Install/fixture/SConstruct-multi new file mode 100644 index 0000000..94de1df --- /dev/null +++ b/test/Install/fixture/SConstruct-multi @@ -0,0 +1,24 @@ +# first run creates a src file, makes it read-only, and installs. +# second run updates src, Install should successfully replace +# the previous install (read-only attr on Windows might fail it) + +import os +import pathlib +import stat + +destdir = pathlib.Path("bin") +destdir.mkdir(exist_ok=True) + +srcfile = pathlib.Path("hello") +try: + srcfile.chmod(stat.S_IREAD | stat.S_IWRITE) +except OSError: + pass + +with srcfile.open(mode="w") as f: + print("Hello from ", os.getpid(), file=f) +srcfile.chmod(stat.S_IREAD) + +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +env.Install('bin', 'hello') diff --git a/test/Install/multi-dir.py b/test/Install/multi-dir.py index ddb6d0a..648f46f 100644 --- a/test/Install/multi-dir.py +++ b/test/Install/multi-dir.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 using Install to create multiple dir hierarchies outside diff --git a/test/Install/multi.py b/test/Install/multi.py index 1716d17..2d83981 100644 --- a/test/Install/multi.py +++ b/test/Install/multi.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 multiple calls to test.Install() with the same file @@ -42,8 +41,7 @@ env.Install('install', 'file1') test.write('file1', "file1\n") -test.run(arguments = '.') - +test.run(arguments='.') test.must_match(['install', 'file1'], "file1\n") test.pass_test() diff --git a/test/Install/no-top-relative.py b/test/Install/no-top-relative.py index 31c7130..efba365 100644 --- a/test/Install/no-top-relative.py +++ b/test/Install/no-top-relative.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 we can install a file if its file name portion begins diff --git a/test/Install/non-ascii-name.py b/test/Install/non-ascii-name.py index 7e25743..59a7406 100644 --- a/test/Install/non-ascii-name.py +++ b/test/Install/non-ascii-name.py @@ -1,7 +1,8 @@ -# -*- coding: utf-8 -*- #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 @@ -21,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 the Install() Builder works diff --git a/test/Install/option--install-sandbox.py b/test/Install/option--install-sandbox.py index 45366c1..bb64c34 100644 --- a/test/Install/option--install-sandbox.py +++ b/test/Install/option--install-sandbox.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 the --install-sandbox commandline option for Install() and InstallAs(). @@ -43,11 +42,8 @@ _SUBDIR_file3_in = os.path.join('$SUBDIR', 'file3.in') target_file2_out = os.path.join(target, 'file2.out') subdir_file3_in = os.path.join('subdir', 'file3.in') target_subdir_file3_out = os.path.join(target, 'subdir', 'file3.out') -file1_out = target+os.path.join( target, - os.path.splitdrive(destdir)[1], - 'file1.out' ) +file1_out = target + os.path.join(target, os.path.splitdrive(destdir)[1], 'file1.out') -# test.write('SConstruct', r""" DefaultEnvironment(tools=[]) env = Environment(tools=[], SUBDIR='subdir') diff --git a/test/Install/tool.py b/test/Install/tool.py index ba92d0a..0730e37 100644 --- a/test/Install/tool.py +++ b/test/Install/tool.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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 we can still call Install() and InstallAs() even when @@ -37,14 +36,14 @@ test.subdir('iii') test.write('SConstruct', """ DefaultEnvironment(tools=[]) -env = Environment(tools = []) +env = Environment(tools=[]) env.Install('iii', 'foo.in') env.InstallAs('foo.out', 'foo.in') """) test.write('foo.in', "foo.in\n") -test.run(arguments = '.') +test.run(arguments='.') test.must_match(['iii', 'foo.in'], "foo.in\n") test.must_match('foo.out', "foo.in\n") diff --git a/test/Install/wrap-by-attribute.py b/test/Install/wrap-by-attribute.py index 014b7a5..c18ea77 100644 --- a/test/Install/wrap-by-attribute.py +++ b/test/Install/wrap-by-attribute.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT Licenxe +# +# 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__" """ @@ -45,6 +44,7 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) import os.path + def cat(env, source, target): target = str(target[0]) with open(target, 'wb') as ofp: @@ -52,18 +52,23 @@ def cat(env, source, target): with open(str(src), 'rb') as ifp: ofp.write(ifp.read()) + env = Environment(tools=[], DESTDIR='dest') -env.Append(BUILDERS={'Cat':Builder(action=cat)}) +env.Append(BUILDERS={'Cat': Builder(action=cat)}) env.SconsInternalInstallFunc = env.Install env.SconsInternalInstallAsFunc = env.InstallAs + def InstallWithDestDir(dir, source): abspath = os.path.splitdrive(env.Dir(dir).get_abspath())[1] - return env.SconsInternalInstallFunc('$DESTDIR'+abspath, source) + return env.SconsInternalInstallFunc('$DESTDIR' + abspath, source) + + def InstallAsWithDestDir(target, source): abspath = os.path.splitdrive(env.File(target).get_abspath())[1] - return env.SconsInternalInstallAsFunc('$DESTDIR'+abspath, source) + return env.SconsInternalInstallAsFunc('$DESTDIR' + abspath, source) + # Add the wrappers directly as attributes. env.Install = InstallWithDestDir @@ -82,7 +87,6 @@ t = e2.Cat(target='f3.out', source='f3.in') e2.Install('export', source=t) t = e2.Cat(target='f4.out', source='f4.in') e2.InstallAs('export/f4-new.out', source=t) - """) test.write('f1.in', "f1.in\n") @@ -90,7 +94,7 @@ test.write('f2.in', "f2.in\n") test.write('f3.in', "f3.in\n") test.write('f4.in', "f4.in\n") -test.run(arguments = '.') +test.run(arguments='.') export = os.path.splitdrive(test.workpath('export'))[1] @@ -104,7 +108,7 @@ test.must_match(f2_new_out, "f2.in\n") test.must_match(f3_out, "f3.in\n") test.must_match(f4_new_out, "f4.in\n") -test.up_to_date(arguments = '.') +test.up_to_date(arguments='.') test.pass_test() |