summaryrefslogtreecommitdiff
path: root/src/test_setup.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-03-16 17:15:19 +0000
committerSteven Knight <knight@baldmt.com>2005-03-16 17:15:19 +0000
commita911d49dc68205cebbd6b7e728f2cd1ad49b9aca (patch)
tree72ca7f06b3a63046d0b0f72d93f888c3d4f4f469 /src/test_setup.py
parentf38e126005e06aa1a42a21f7f26d137a65ba0883 (diff)
downloadscons-a911d49dc68205cebbd6b7e728f2cd1ad49b9aca.tar.gz
Version installation of scripts.
Diffstat (limited to 'src/test_setup.py')
-rw-r--r--src/test_setup.py269
1 files changed, 214 insertions, 55 deletions
diff --git a/src/test_setup.py b/src/test_setup.py
index 73b6588d..7d220e2a 100644
--- a/src/test_setup.py
+++ b/src/test_setup.py
@@ -37,6 +37,9 @@ import shutil
import string
import sys
+try: WindowsError
+except NameError: WindowsError = OSError
+
#try:
# version = os.environ['SCONS_VERSION']
#except KeyError:
@@ -51,12 +54,34 @@ python = TestSCons.python
class MyTestSCons(TestSCons.TestSCons):
- scripts = [
+ _lib_modules = [
+ # A representative smattering of build engine modules.
+ '__init__.py',
+ 'Action.py',
+ 'Builder.py',
+ 'Environment.py',
+ 'Util.py',
+ ]
+
+ _base_scripts = [
'scons',
'sconsign',
]
- man_pages = [
+ _version_scripts = [
+ 'scons-%s' % version,
+ 'sconsign-%s' % version,
+ ]
+
+ _bat_scripts = [
+ 'scons.bat',
+ ]
+
+ _bat_version_scripts = [
+ 'scons-%s.bat' % version,
+ ]
+
+ _man_pages = [
'scons.1',
'sconsign.1',
]
@@ -64,18 +89,33 @@ class MyTestSCons(TestSCons.TestSCons):
def __init__(self):
TestSCons.TestSCons.__init__(self)
self.root = self.workpath('root')
- self.prefix = self.root + sys.prefix
-
- self.lib_dir = os.path.join(self.prefix, 'lib')
- self.standard_lib = os.path.join(self.lib_dir,
- 'python%s' % sys.version[:3],
- 'site-packages/')
- self.standalone_lib = os.path.join(self.lib_dir, 'scons')
- self.version_lib = os.path.join(self.lib_dir, scons_version)
-
- self.bin_dir = os.path.join(self.prefix, 'bin')
-
- self.man_dir = os.path.join(self.prefix, 'man', 'man1')
+ self.prefix = self.root + os.path.splitdrive(sys.prefix)[1]
+
+ if sys.platform == 'win32':
+ self.bin_dir = os.path.join(self.prefix, 'Scripts')
+ self.bat_dir = self.prefix
+ self.standalone_lib = os.path.join(self.prefix, 'scons')
+ self.standard_lib = os.path.join(self.prefix,
+ 'Lib',
+ 'site-packages',
+ '')
+ self.version_lib = os.path.join(self.prefix, scons_version)
+ self.man_dir = os.path.join(self.prefix, 'Doc')
+ else:
+ self.bin_dir = os.path.join(self.prefix, 'bin')
+ self.bat_dir = self.bin_dir
+ self.lib_dir = os.path.join(self.prefix, 'lib')
+ self.standalone_lib = os.path.join(self.lib_dir, 'scons')
+ self.standard_lib = os.path.join(self.lib_dir,
+ 'python%s' % sys.version[:3],
+ 'site-packages',
+ '')
+ self.version_lib = os.path.join(self.lib_dir, scons_version)
+ self.man_dir = os.path.join(self.prefix, 'man', 'man1')
+
+ self.prepend_bin_dir = lambda p, d=self.bin_dir: os.path.join(d, p)
+ self.prepend_bat_dir = lambda p, d=self.bat_dir: os.path.join(d, p)
+ self.prepend_man_dir = lambda p, d=self.man_dir: os.path.join(d, p)
def run(self, *args, **kw):
kw['chdir'] = scons_version
@@ -83,24 +123,50 @@ class MyTestSCons(TestSCons.TestSCons):
kw['stderr'] = None
return apply(TestSCons.TestSCons.run, (self,)+args, kw)
- def must_have_installed_lib(self, lib):
- lines = string.split(self.stdout(), '\n')
- line = 'Installed SCons library modules into %s' % lib
- self.fail_test(not line in lines)
-
- def must_have_installed_scripts(self):
- lines = string.split(self.stdout(), '\n')
- line = 'Installed SCons scripts into %s' % self.bin_dir
- self.fail_test(not line in lines)
- for script in self.scripts:
- self.must_exist([self.bin_dir, script])
-
- def must_have_installed_man_pages(self):
- lines = string.split(self.stdout(), '\n')
- line = 'Installed SCons man pages into %s' % self.man_dir
- self.fail_test(not line in lines)
- for mp in self.man_pages:
- self.must_exist([self.man_dir, mp])
+ def remove(self, dir):
+ try: shutil.rmtree(dir)
+ except (OSError, WindowsError): pass
+
+ def stdout_lines(self):
+ return string.split(self.stdout(), '\n')
+
+
+ def lib_line(self, lib):
+ return 'Installed SCons library modules into %s' % lib
+
+ def lib_paths(self, lib_dir):
+ prepend_lib_dir = lambda p, d=lib_dir: os.path.join(d, 'SCons', p)
+ return map(prepend_lib_dir, self._lib_modules)
+
+ def scripts_line(self):
+ return 'Installed SCons scripts into %s' % self.bin_dir
+
+ def base_script_paths(self):
+ scripts = self._base_scripts
+ return map(self.prepend_bin_dir, scripts)
+
+ def version_script_paths(self):
+ scripts = self._version_scripts
+ return map(self.prepend_bin_dir, scripts)
+
+ def bat_script_paths(self):
+ scripts = self._bat_scripts + self._bat_version_scripts
+ return map(self.prepend_bat_dir, scripts)
+
+ def man_page_line(self):
+ return 'Installed SCons man pages into %s' % self.man_dir
+
+ def man_page_paths(self):
+ return map(self.prepend_man_dir, self._man_pages)
+
+
+ def must_have_installed(self, paths):
+ for p in paths:
+ self.must_exist(p)
+
+ def must_not_have_installed(self, paths):
+ for p in paths:
+ self.must_not_exist(p)
try:
cwd = os.environ['SCONS_CWD']
@@ -112,53 +178,146 @@ test = MyTestSCons()
test.subdir(test.root)
tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version)
-
-if not os.path.isfile(tar_gz):
- print "Did not find an SCons package `%s'." % tar_gz
+zip = os.path.join(cwd, 'build', 'dist', '%s.zip' % scons_version)
+
+if os.path.isfile(zip):
+ try: import zipfile
+ except ImportError: pass
+ else:
+ zf = zipfile.ZipFile(zip, 'r')
+
+ for name in zf.namelist():
+ dir = os.path.dirname(name)
+ try: os.makedirs(dir)
+ except: pass
+ # if the file exists, then delete it before writing
+ # to it so that we don't end up trying to write to a symlink:
+ if os.path.isfile(name) or os.path.islink(name):
+ os.unlink(name)
+ if not os.path.isdir(name):
+ open(name, 'w').write(zf.read(name))
+
+if not os.path.isdir(scons_version) and os.path.isfile(tar_gz):
+ # Unpack the .tar.gz file. This should create the scons_version/
+ # subdirectory from which we execute the setup.py script therein.
+ os.system("gunzip -c %s | tar xf -" % tar_gz)
+
+if not os.path.isdir(scons_version):
+ print "Found neither SCons package `%s' nor `%s'." % (tar_gz, zip)
print "Cannot test package installation."
test.no_result(1)
-# Unpack the .tar.gz file. This should create the scons_version/
-# subdirectory from which we execute the setup.py script therein.
-os.system("gunzip -c %s | tar xf -" % tar_gz)
-
-# Verify that a virgin installation installs the standalone library,
-# the scripts and the man pages.
+# Verify that a virgin installation installs the version library,
+# the scripts and (on UNIX/Linux systems) the man pages.
test.run(arguments = 'setup.py install --root=%s' % test.root)
-test.must_have_installed_lib(test.standalone_lib)
-test.must_have_installed_scripts()
-test.must_have_installed_man_pages()
+test.fail_test(not test.lib_line(test.version_lib) in test.stdout_lines())
+test.must_have_installed(test.lib_paths(test.version_lib))
# Verify that --standard-lib installs into the Python standard library.
test.run(arguments = 'setup.py install --root=%s --standard-lib' % test.root)
-test.must_have_installed_lib(test.standard_lib)
+test.fail_test(not test.lib_line(test.standard_lib) in test.stdout_lines())
+test.must_have_installed(test.lib_paths(test.standard_lib))
# Verify that --standalone-lib installs the standalone library.
test.run(arguments = 'setup.py install --root=%s --standalone-lib' % test.root)
-test.must_have_installed_lib(test.standalone_lib)
+test.fail_test(not test.lib_line(test.standalone_lib) in test.stdout_lines())
+test.must_have_installed(test.lib_paths(test.standalone_lib))
# Verify that --version-lib installs into a version-specific library directory.
test.run(arguments = 'setup.py install --root=%s --version-lib' % test.root)
-test.must_have_installed_lib(test.version_lib)
+test.fail_test(not test.lib_line(test.version_lib) in test.stdout_lines())
# Now that all of the libraries are in place,
-# verify that a default installation finds the version-specific library first.
+# verify that a default installation still installs the version library.
test.run(arguments = 'setup.py install --root=%s' % test.root)
-test.must_have_installed_lib(test.version_lib)
+test.fail_test(not test.lib_line(test.version_lib) in test.stdout_lines())
-shutil.rmtree(test.version_lib)
+test.remove(test.version_lib)
# Now with only the standard and standalone libraries in place,
-# verify that a default installation finds the standalone library first.
+# verify that a default installation still installs the version library.
test.run(arguments = 'setup.py install --root=%s' % test.root)
-test.must_have_installed_lib(test.standalone_lib)
+test.fail_test(not test.lib_line(test.version_lib) in test.stdout_lines())
-shutil.rmtree(test.standalone_lib)
+test.remove(test.version_lib)
+test.remove(test.standalone_lib)
# Now with only the standard libraries in place,
-# verify that a default installation installs the standard library.
+# verify that a default installation still installs the version library.
test.run(arguments = 'setup.py install --root=%s' % test.root)
-test.must_have_installed_lib(test.standard_lib)
+test.fail_test(not test.lib_line(test.version_lib) in test.stdout_lines())
+
+
+
+#
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+test.fail_test(not test.scripts_line() in test.stdout_lines())
+if sys.platform == 'win32':
+ test.must_have_installed(test.base_script_paths())
+ test.must_have_installed(test.version_script_paths())
+ test.must_have_installed(test.bat_script_paths())
+else:
+ test.must_have_installed(test.base_script_paths())
+ test.must_have_installed(test.version_script_paths())
+ test.must_not_have_installed(test.bat_script_paths())
+
+test.remove(test.prefix)
+
+test.run(arguments = 'setup.py install --root=%s --no-install-bat' % test.root)
+test.fail_test(not test.scripts_line() in test.stdout_lines())
+test.must_have_installed(test.base_script_paths())
+test.must_have_installed(test.version_script_paths())
+test.must_not_have_installed(test.bat_script_paths())
+
+test.remove(test.prefix)
+
+test.run(arguments = 'setup.py install --root=%s --install-bat' % test.root)
+test.fail_test(not test.scripts_line() in test.stdout_lines())
+test.must_have_installed(test.base_script_paths())
+test.must_have_installed(test.version_script_paths())
+test.must_have_installed(test.bat_script_paths())
+
+test.remove(test.prefix)
+
+test.run(arguments = 'setup.py install --root=%s --no-scons-script' % test.root)
+test.fail_test(not test.scripts_line() in test.stdout_lines())
+test.must_not_have_installed(test.base_script_paths())
+test.must_have_installed(test.version_script_paths())
+# Doesn't matter whether we installed the .bat scripts or not.
+
+test.remove(test.prefix)
+
+test.run(arguments = 'setup.py install --root=%s --no-version-script' % test.root)
+test.fail_test(not test.scripts_line() in test.stdout_lines())
+test.must_have_installed(test.base_script_paths())
+test.must_not_have_installed(test.version_script_paths())
+# Doesn't matter whether we installed the .bat scripts or not.
+
+
+
+test.remove(test.man_dir)
+
+test.run(arguments = 'setup.py install --root=%s' % test.root)
+if sys.platform == 'win32':
+ test.fail_test(test.man_page_line() in test.stdout_lines())
+ test.must_not_have_installed(test.man_page_paths())
+else:
+ test.fail_test(not test.man_page_line() in test.stdout_lines())
+ test.must_have_installed(test.man_page_paths())
+
+test.remove(test.man_dir)
+
+test.run(arguments = 'setup.py install --root=%s --no-install-man' % test.root)
+test.fail_test(test.man_page_line() in test.stdout_lines())
+test.must_not_have_installed(test.man_page_paths())
+
+test.remove(test.man_dir)
+
+test.run(arguments = 'setup.py install --root=%s --install-man' % test.root)
+test.fail_test(not test.man_page_line() in test.stdout_lines())
+test.must_have_installed(test.man_page_paths())
+
+
# Verify that we don't warn about the directory in which we've
# installed the modules when using a non-standard prefix.