From d292a3c5d016908d53587675bbe02c032a5a7a28 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 30 Jul 2004 22:32:56 +0000 Subject: Change the copyright statement to reflect ownership by the foundation. Add and fix statements where needed. Update scripts accordingly. --- HOWTO/README | 19 +++++ HOWTO/change.txt | 2 + HOWTO/new-platform.txt | 2 + HOWTO/new-script.txt | 2 + HOWTO/new-tool.txt | 2 + HOWTO/release.txt | 5 ++ SConstruct | 2 +- bin/linecount | 30 +++++--- bootstrap.py | 2 +- doc/SConscript | 2 +- doc/man/scons.1 | 2 +- doc/man/sconsign.1 | 6 +- rpm/scons.spec.in | 2 +- runtest.py | 17 ++++- src/engine/SCons/Tool/aixc++.py | 26 ++++++- src/engine/SCons/Tool/sunc++.py | 26 ++++++- src/script/scons.bat | 2 + src/setupTests.py | 150 --------------------------------------- src/test_copyrights.py | 122 ++++++++++++++++++++++++++++++++ src/test_setup.py | 153 ++++++++++++++++++++++++++++++++++++++++ 20 files changed, 404 insertions(+), 170 deletions(-) delete mode 100644 src/setupTests.py create mode 100644 src/test_copyrights.py create mode 100644 src/test_setup.py diff --git a/HOWTO/README b/HOWTO/README index cda7606..951c019 100644 --- a/HOWTO/README +++ b/HOWTO/README @@ -1,3 +1,5 @@ +__COPYRIGHT__ + Here you'll find plain text documentation of how to handle various SCons project procedures. Files contained herein: @@ -6,5 +8,22 @@ change.txt distributing aedist change sets, and updating the CVS repository on SourceForge. +new-platform.txt + Steps to add a new Platform/*.py file. This is probably out + of date. + +new-script.txt + Steps to add a new script or utility (like scons and sconsign) + to what we ship. + +new-tool.txt + Steps to add a new Tool/*.py file. This is probably out of date. + release.txt Steps to go through when releasing a new version of SCons. + +subrelease.txt + Steps to go through when releasing a new subsidiary version + of SCons--for example, 0.95.1 after we've released 0.95. + So far, we've only done this to get some early testing on major + refactorings. diff --git a/HOWTO/change.txt b/HOWTO/change.txt index 049e8eb..86e854d 100644 --- a/HOWTO/change.txt +++ b/HOWTO/change.txt @@ -1,3 +1,5 @@ +__COPYRIGHT__ + Handling a change set: -- Start the change: diff --git a/HOWTO/new-platform.txt b/HOWTO/new-platform.txt index 7e2fce8..8aa11ec 100644 --- a/HOWTO/new-platform.txt +++ b/HOWTO/new-platform.txt @@ -1,3 +1,5 @@ +__COPYRIGHT__ + Adding a new Platform to the SCons distribution: -- Add the following files (aenf): diff --git a/HOWTO/new-script.txt b/HOWTO/new-script.txt index 8bb5222..f859c48 100644 --- a/HOWTO/new-script.txt +++ b/HOWTO/new-script.txt @@ -1,3 +1,5 @@ +__COPYRIGHT__ + Steps for adding a new script/utility to the SCons packages. Assume that you're creating a new man page, too. In the template steps below, "newscript" is the name of the new script/utility being added. diff --git a/HOWTO/new-tool.txt b/HOWTO/new-tool.txt index c906b7f..4297fe6 100644 --- a/HOWTO/new-tool.txt +++ b/HOWTO/new-tool.txt @@ -1,3 +1,5 @@ +__COPYRIGHT__ + Adding a new Tool to the SCons distribution: -- Add the following files (aenf): diff --git a/HOWTO/release.txt b/HOWTO/release.txt index 5b77b63..51dfb70 100644 --- a/HOWTO/release.txt +++ b/HOWTO/release.txt @@ -1,3 +1,5 @@ +__COPYRIGHT__ + This document covers how to prepare major releases of SCons--that is, releases numbered with X.Y format, such as 0.93, 1.0, etc. @@ -91,6 +93,9 @@ Things to do to release a new X.Y version of SCons: aecp rpm/scons.spec.in vi rpm/scons.spec.in + aecp src/copyrightTests.py + vi src/copyrightTests.py + aecp src/setupTests.py vi src/setupTests.py diff --git a/SConstruct b/SConstruct index 0822095..a3e0903 100644 --- a/SConstruct +++ b/SConstruct @@ -40,7 +40,7 @@ import time project = 'scons' default_version = '0.95' -copyright = "Copyright (c) %s Steven Knight" % copyright_years +copyright = "Copyright (c) %s The SCons Foundation" % copyright_years Default('.') diff --git a/bin/linecount b/bin/linecount index e344e2a..765309e 100644 --- a/bin/linecount +++ b/bin/linecount @@ -1,16 +1,23 @@ #!/usr/bin/env python # +# __COPYRIGHT__ +# # Count statistics about SCons test and source files. This must be run # against a fully-populated tree (for example, one that's been freshly # checked out). # -# A test file is anything under the src/ directory that ends in -# 'Tests.py', or anything under the test/ directory that ends in '.py'. +# A test file is anything under the src/ directory that begins with +# 'test_' or ends in 'Tests.py', or anything under the test/ directory +# that ends in '.py'. Note that runtest.py script does *not*, by default, +# consider the files that begin with 'test_' to be tests, because they're +# tests of SCons packaging and installation, not functional tests of +# SCons code. # # A source file is anything under the src/engine/ or src/script/ -# directories that ends in '.py' but does NOT end in 'Tests.py'. (We -# should probably ignore the stuff in src/engine/SCons/Optik, since it -# doesn't originate with SCons, but what the hell.) +# directories that ends in '.py' but does NOT begin with 'test_' +# or end in 'Tests.py'. (We should probably ignore the stuff in +# src/engine/SCons/Optik, since it doesn't originate with SCons, but +# what the hell.) # # We report the number of tests and sources, the total number of lines # in each category, the number of non-blank lines, and the number of @@ -18,24 +25,31 @@ # interesting one for most purposes. # +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os.path import string tests = [] sources = [] +def is_test(x): + return x[:5] == 'test_' or x[-8:] == 'Tests.py' +def is_python(x): + return x[-3:] == '.py' + def t(arg, dirname, names): - names = filter(lambda n: n[-8:] == 'Tests.py', names) + names = filter(is_test, names) arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names)) os.path.walk('src', t, tests) def p(arg, dirname, names): - names = filter(lambda n: n[-3:] == '.py', names) + names = filter(is_python, names) arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names)) os.path.walk('test', p, tests) def s(arg, dirname, names): - names = filter(lambda n: n[-3:] == '.py' and n[-8:] != 'Tests.py', names) + names = filter(lambda n: is_python(n) and not is_test(n), names) arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names)) os.path.walk('src/engine', s, sources) os.path.walk('src/script', s, sources) diff --git a/bootstrap.py b/bootstrap.py index 96d92aa..c6a7db3 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -16,7 +16,7 @@ local SConstruct file. """ # -# Copyright (c) 2001, 2002, 2003 Steven Knight +# __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/doc/SConscript b/doc/SConscript index 976e0a6..d33712b 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -3,7 +3,7 @@ # # -# Copyright (c) 2001, 2002, 2003 Steven Knight +# __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 9dff843..135e5f7 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -31,7 +31,7 @@ .fi .RE .. -.TH SCONS 1 "November 2003" +.TH SCONS 1 "August 2004" .SH NAME scons \- a software construction tool .SH SYNOPSIS diff --git a/doc/man/sconsign.1 b/doc/man/sconsign.1 index 079e7ff..dc6d0cb 100644 --- a/doc/man/sconsign.1 +++ b/doc/man/sconsign.1 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2001, 2002, 2003 Steven Knight +.\" __COPYRIGHT__ .\" .\" Permission is hereby granted, free of charge, to any person obtaining .\" a copy of this software and associated documentation files (the @@ -19,7 +19,7 @@ .\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION .\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .\" -.\" doc/man/scons.1 0.90.D006 2003/07/02 09:02:19 knight +.\" __FILE__ __REVISION__ __DATE__ __DEVELOPER__ .\" .\" ES - Example Start - indents and turns off line fill .de ES @@ -31,7 +31,7 @@ .RE .fi .. -.TH SCONSIGN 1 "September 2003" +.TH SCONSIGN 1 "August 2004" .SH NAME sconsign \- print SCons .sconsign file information .SH SYNOPSIS diff --git a/rpm/scons.spec.in b/rpm/scons.spec.in index aedc268..96e9b8e 100644 --- a/rpm/scons.spec.in +++ b/rpm/scons.spec.in @@ -7,7 +7,7 @@ Name: %{name} Version: %{version} Release: %{release} Source0: %{name}-%{version}.tar.gz -#Copyright: Steven Knight +#Copyright: The SCons Foundation License: MIT, freely distributable Group: Development/Tools BuildRoot: %{_tmppath}/%{name}-buildroot diff --git a/runtest.py b/runtest.py index a93789d..df97eea 100644 --- a/runtest.py +++ b/runtest.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # +# __COPYRIGHT__ +# # runtest.py - wrapper script for running SCons tests # # This script mainly exists to set PYTHONPATH to the right list of @@ -296,14 +298,25 @@ if args: for g in glob.glob(a): tests.append(Test(g)) elif all: + # Find all of the SCons functional tests in the local directory + # tree. This is anything under the 'src' subdirectory that ends + # with 'Tests.py', or any Python script (*.py) under the 'test' + # subdirectory. + # + # Note that there are some tests under 'src' that *begin* with + # 'test_', but they're packaging and installation tests, not + # functional tests, so we don't execute them by default. (They can + # still be executed by hand, though, and are routinely executed + # by the Aegis packaging build to make sure that we're building + # things correctly.) tdict = {} - def find_Test_py(arg, dirname, names, tdict=tdict): + def find_Tests_py(arg, dirname, names, tdict=tdict): for n in filter(lambda n: n[-8:] == "Tests.py", names): t = os.path.join(dirname, n) if not tdict.has_key(t): tdict[t] = Test(t) - os.path.walk('src', find_Test_py, 0) + os.path.walk('src', find_Tests_py, 0) def find_py(arg, dirname, names, tdict=tdict): for n in filter(lambda n: n[-3:] == ".py", names): diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py index 5cb6639..dcc444a 100644 --- a/src/engine/SCons/Tool/aixc++.py +++ b/src/engine/SCons/Tool/aixc++.py @@ -7,7 +7,31 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ -__revision__ = "" + +# +# __COPYRIGHT__ +# +# 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.path diff --git a/src/engine/SCons/Tool/sunc++.py b/src/engine/SCons/Tool/sunc++.py index 673949b..22d01db 100644 --- a/src/engine/SCons/Tool/sunc++.py +++ b/src/engine/SCons/Tool/sunc++.py @@ -7,7 +7,31 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ -__revision__ = "" + +# +# __COPYRIGHT__ +# +# 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.path diff --git a/src/script/scons.bat b/src/script/scons.bat index 782d8c4..5cbfc2c 100644 --- a/src/script/scons.bat +++ b/src/script/scons.bat @@ -1,3 +1,5 @@ +REM __COPYRIGHT__ +REM __FILE__ __REVISION__ __DATE__ __DEVELOPER__ @echo off if "%OS%" == "Windows_NT" goto WinNT REM for 9x/Me you better not have more than 9 args diff --git a/src/setupTests.py b/src/setupTests.py deleted file mode 100644 index 06688af..0000000 --- a/src/setupTests.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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__" - -""" -Test how the setup.py script installs SCons (specifically, its libraries). -""" - -import os -import os.path -import shutil -import string -import sys - -import TestSCons - -python = TestSCons.python - -class MyTestSCons(TestSCons.TestSCons): - def installed(self, lib): - lines = string.split(self.stdout(), '\n') - return ('Installed SCons library modules into %s' % lib) in lines - -try: - cwd = os.environ['SCONS_CWD'] -except KeyError: - cwd = os.getcwd() - -#try: -# version = os.environ['SCONS_VERSION'] -#except KeyError: -# version = '__VERSION__' -version = '0.95' - -scons_version = 'scons-%s' % version - -tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version) - -test = MyTestSCons() - -if not os.path.isfile(tar_gz): - print "Did not find an SCons package `%s'." % tar_gz - print "Cannot test package installation." - test.no_result(1) - -test.subdir('root', 'prefix') - -root = test.workpath('root') -prefix = test.workpath('prefix') - -lib_dir = os.path.join(root + sys.prefix, 'lib') -standard_lib = os.path.join(lib_dir, - 'python%s' % sys.version[:3], - 'site-packages/') -standalone_lib = os.path.join(lib_dir, 'scons') -version_lib = os.path.join(lib_dir, scons_version) - -os.system("gunzip -c %s | tar xf -" % tar_gz) - -# Verify that a virgin installation installs the standalone library. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s' % root, - stderr = None) -test.fail_test(not test.installed(standalone_lib)) - -# Verify that --standard-lib installs into the Python standard library. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s --standard-lib' % root, - stderr = None) -lines = string.split(test.stdout(), '\n') -test.fail_test(not test.installed(standard_lib)) - -# Verify that --standalone-lib installs the standalone library. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s --standalone-lib' % root, - stderr = None) -test.fail_test(not test.installed(standalone_lib)) - -# Verify that --version-lib installs into a version-specific library directory. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s --version-lib' % root, - stderr = None) -test.fail_test(not test.installed(version_lib)) - -# Now that all of the libraries are in place, -# verify that a default installation finds the version-specific library first. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s' % root, - stderr = None) -test.fail_test(not test.installed(version_lib)) - -shutil.rmtree(version_lib) - -# Now with only the standard and standalone libraries in place, -# verify that a default installation finds the standalone library first. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s' % root, - stderr = None) -test.fail_test(not test.installed(standalone_lib)) - -shutil.rmtree(standalone_lib) - -# Now with only the standard libraries in place, -# verify that a default installation installs the standard library. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --root=%s' % root, - stderr = None) -test.fail_test(not test.installed(standard_lib)) - -# Verify that we're not warning about the directory in which -# we've installed the modules when using a non-standard prefix. -test.run(chdir = scons_version, - program = python, - arguments = 'setup.py install --prefix=%s' % prefix, - stderr = None) -test.fail_test(string.find(test.stderr(), - "you'll have to change the search path yourself") - != -1) - -# All done. -test.pass_test() diff --git a/src/test_copyrights.py b/src/test_copyrights.py new file mode 100644 index 0000000..f239f4d --- /dev/null +++ b/src/test_copyrights.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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__" + +""" +Verify that we have proper Copyright notices on all the right files +in our distributions. + +Note that this is a packaging test, not a functional test, so the +name of this script doesn't end in *Tests.py. +""" + +import os +import os.path +import re +import string + +import TestSCons + +test = TestSCons.TestSCons() + +try: + cwd = os.environ['SCONS_CWD'] +except KeyError: + cwd = os.getcwd() + +class Collect: + expression = re.compile('Copyright.*The SCons Foundation') + def __init__(self, remove_list): + self.copyright = [] + self.no_copyright = [] + self.remove_list = remove_list + +def visit(collect, dirname, names): + for r in collect.remove_list: + try: + names.remove(r) + except ValueError: + pass + for name in map(lambda n, d=dirname: os.path.join(d, n), names): + if not os.path.isfile(name): + continue + if collect.expression.search(open(name, 'r').read()): + collect.copyright.append(name) + else: + collect.no_copyright.append(name) + +remove_list = [ + 'build', + 'debian', + 'dist', + 'Optik', + 'dblite.py', + 'Conftest.py', + 'os_spawnv_fix.diff', + 'setup.cfg', +] + +# XXX Remove '*-stamp' when we get rid of those. +scons = Collect(remove_list + ['MANIFEST', 'build-stamp', 'configure-stamp']) +# XXX Remove '.sconsign' when we start using SConsignFile() for SCons builds. +local = Collect(remove_list + ['.sconsign']) +# XXX Remove 'doc' when we take care of those Copyright statements. +src = Collect(remove_list + ['bin', 'doc', 'etc', 'gentoo', 'config', 'MANIFEST.in']) + +build_scons = os.path.join(cwd, 'build', 'scons') +build_local = os.path.join(cwd, 'build', 'scons-local') +build_src = os.path.join(cwd, 'build', 'scons-src') + +no_result = [] + +if os.path.exists(build_scons): + os.path.walk(build_scons, visit, scons) +else: + no_result.append(build_scons) + +if os.path.exists(build_local): + os.path.walk(build_local, visit, local) +else: + no_result.append(build_local) + +if os.path.exists(build_src): + os.path.walk(build_src, visit, src) +else: + no_result.append(build_src) + +no_copyright = scons.no_copyright + local.no_copyright + src.no_copyright + +if no_copyright: + print "Found the following files with no copyrights:" + print "\t" + string.join(no_copyright, "\n\t") + test.fail_test(1) + +if no_result: + print "Cannot check copyrights, the following have apparently not been built:" + print "\t" + string.join(no_result, "\n\t") + test.no_result(1) + +# All done. +test.pass_test() diff --git a/src/test_setup.py b/src/test_setup.py new file mode 100644 index 0000000..799be78 --- /dev/null +++ b/src/test_setup.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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__" + +""" +Test how the setup.py script installs SCons (specifically, its libraries). + +Note that this is an installation test, not a functional test, so the +name of this script doesn't end in *Tests.py. +""" + +import os +import os.path +import shutil +import string +import sys + +import TestSCons + +python = TestSCons.python + +class MyTestSCons(TestSCons.TestSCons): + def installed(self, lib): + lines = string.split(self.stdout(), '\n') + return ('Installed SCons library modules into %s' % lib) in lines + +try: + cwd = os.environ['SCONS_CWD'] +except KeyError: + cwd = os.getcwd() + +#try: +# version = os.environ['SCONS_VERSION'] +#except KeyError: +# version = '__VERSION__' +version = '0.95' + +scons_version = 'scons-%s' % version + +tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version) + +test = MyTestSCons() + +if not os.path.isfile(tar_gz): + print "Did not find an SCons package `%s'." % tar_gz + print "Cannot test package installation." + test.no_result(1) + +test.subdir('root', 'prefix') + +root = test.workpath('root') +prefix = test.workpath('prefix') + +lib_dir = os.path.join(root + sys.prefix, 'lib') +standard_lib = os.path.join(lib_dir, + 'python%s' % sys.version[:3], + 'site-packages/') +standalone_lib = os.path.join(lib_dir, 'scons') +version_lib = os.path.join(lib_dir, scons_version) + +os.system("gunzip -c %s | tar xf -" % tar_gz) + +# Verify that a virgin installation installs the standalone library. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s' % root, + stderr = None) +test.fail_test(not test.installed(standalone_lib)) + +# Verify that --standard-lib installs into the Python standard library. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s --standard-lib' % root, + stderr = None) +lines = string.split(test.stdout(), '\n') +test.fail_test(not test.installed(standard_lib)) + +# Verify that --standalone-lib installs the standalone library. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s --standalone-lib' % root, + stderr = None) +test.fail_test(not test.installed(standalone_lib)) + +# Verify that --version-lib installs into a version-specific library directory. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s --version-lib' % root, + stderr = None) +test.fail_test(not test.installed(version_lib)) + +# Now that all of the libraries are in place, +# verify that a default installation finds the version-specific library first. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s' % root, + stderr = None) +test.fail_test(not test.installed(version_lib)) + +shutil.rmtree(version_lib) + +# Now with only the standard and standalone libraries in place, +# verify that a default installation finds the standalone library first. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s' % root, + stderr = None) +test.fail_test(not test.installed(standalone_lib)) + +shutil.rmtree(standalone_lib) + +# Now with only the standard libraries in place, +# verify that a default installation installs the standard library. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --root=%s' % root, + stderr = None) +test.fail_test(not test.installed(standard_lib)) + +# Verify that we're not warning about the directory in which +# we've installed the modules when using a non-standard prefix. +test.run(chdir = scons_version, + program = python, + arguments = 'setup.py install --prefix=%s' % prefix, + stderr = None) +test.fail_test(string.find(test.stderr(), + "you'll have to change the search path yourself") + != -1) + +# All done. +test.pass_test() -- cgit v0.12