From: stevenknight Date: Tue, 19 Feb 2002 15:56:11 +0000 (+0000) Subject: Revamp package testing. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f48bec8787346b1554db6d327df73916ae1b86a8;p=scons.git Revamp package testing. git-svn-id: http://scons.tigris.org/svn/scons/trunk@267 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/README b/README index a6aa607c..3e62860c 100644 --- a/README +++ b/README @@ -117,10 +117,8 @@ unsuccessful tests. The above invocations all test directly the files underneath the src/ subdirectory, and do not require that a build be performed first. The runtest.py script supports supports additional options to run tests -against unpacked packages in the build/test*/ subdirectories. This is -in the process of being reworked for the next release, however, so for -now, see the comments in the runtest.py script itself if you want to run -tests against a package. +against unpacked packages in the build/test-*/ subdirectories. See +the "TESTING PACKAGES" section below. BUILDING PACKAGES @@ -162,6 +160,25 @@ Note that in addition to creating the above packages, the default build will also unpack one or more of the packages for testing. +TESTING PACKAGES +================ + +A full build will unpack and/or install any .deb, .rpm., .src.tar.gz, +and .tar.gz packages into separate build/test-*/ subdirectories. (Of +course, if a package was not built on your system, it should not try to +install it.) The runtest.py script supports a -p option that will run +the specified tests (individually or collectively via the -a option) +against the unpacked build/test-/* subdirectory: + + $ python runtest.py -p tar-gz + + $ python runtest.py -p src-tar-gz + + $ python runtest.py -p rpm + + $ python runtest.py -p deb + + CONTENTS OF THIS PACKAGE ======================== diff --git a/SConstruct b/SConstruct index 3ba2fdee..7b73560f 100644 --- a/SConstruct +++ b/SConstruct @@ -145,27 +145,23 @@ ENV = { 'PATH' : os.environ['PATH'] } if os.environ.has_key('AEGIS_PROJECT'): ENV['AEGIS_PROJECT'] = os.environ['AEGIS_PROJECT'] -test1_dir = os.path.join(os.getcwd(), "build", "test1") -test2_dir = os.path.join(os.getcwd(), "build", "test2") - lib_project = os.path.join("lib", project) -# Originally, we were going to package the build engine in a -# private SCons library that contained the version number, so -# we could easily have multiple side-by-side versions of SCons -# installed. Keep this around in case we ever want to go back -# to that scheme. Note that this also requires changes to -# runtest.py and src/setup.py. -#lib_project = os.path.join("lib", project + '-' + version) +unpack_dir = os.path.join(os.getcwd(), "build", "unpack") + +test_arch_dir = os.path.join(os.getcwd(), + "build", + "test-%s" % string.replace(archsuffix, '.', '-')) -test1_lib_dir = os.path.join(test1_dir, lib_project) +test_src_arch_dir = os.path.join(os.getcwd(), + "build", + "test-src-%s" % string.replace(archsuffix, + '.', + '-')) -test2_lib_dir = os.path.join(test2_dir, - "lib", - "python" + python_ver, - "site-packages") +test_rpm_dir = os.path.join(os.getcwd(), "build", "test-rpm") -unpack_dir = os.path.join(os.getcwd(), "build", "unpack") +test_deb_dir = os.path.join(os.getcwd(), "build", "test-deb") def SCons_revision(target, source, env): """Interpolate specific values from the environment into a file. @@ -194,9 +190,6 @@ revbuilder = Builder(name = 'SCons_revision', action = SCons_revision) env = Environment( ENV = ENV, - - TEST1_LIB_DIR = test1_lib_dir, - TEST2_LIB_DIR = test2_lib_dir, DATE = date, DEVELOPER = developer, @@ -227,7 +220,6 @@ python_scons = { 'pkg' : 'python-' + project, 'src_subdir' : 'engine', 'inst_subdir' : os.path.join('lib', 'python1.5', 'site-packages'), - 'prefix' : test2_dir, 'debian_deps' : [ 'debian/rules', @@ -261,7 +253,6 @@ python_scons = { # 'pkg' : 'python2-' + project, # 'src_subdir' : 'engine', # 'inst_subdir' : os.path.join('lib', 'python2.1', 'site-packages'), -# 'prefix' : test2_dir, # # 'debian_deps' : [ # 'debian/rules', @@ -288,7 +279,6 @@ scons_script = { 'pkg' : project + '-script', 'src_subdir' : 'script', 'inst_subdir' : 'bin', - 'prefix' : test2_dir, 'debian_deps' : [ 'debian/rules', @@ -314,8 +304,6 @@ scons_script = { scons = { 'pkg' : project, - #'inst_subdir' : None, - 'prefix' : test1_dir, 'debian_deps' : [ 'debian/rules', @@ -366,11 +354,6 @@ for p in [ scons ]: build = os.path.join('build', pkg) - prefix = p['prefix'] - install = prefix - if p.has_key('inst_subdir'): - install = os.path.join(install, p['inst_subdir']) - # # Read up the list of source files from our MANIFEST.in. # This list should *not* include LICENSE.txt, MANIFEST, @@ -495,6 +478,12 @@ for p in [ scons ]: install_targets.extend(targets) + dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x), + dst_files) + env.Command(dfiles, + rpm, + "rpm2cpio $SOURCES | (cd %s && cpio -id)" % test_rpm_dir) + build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files) if dh_builddeb and fakeroot: @@ -507,6 +496,11 @@ for p in [ scons ]: ]) env.Depends(deb, p['debian_deps']) + dfiles = map(lambda x, d=test_deb_dir: os.path.join(d, 'usr', x), + dst_files) + env.Command(dfiles, + deb, + "dpkg --fsys-tarfile $SOURCES | (cd %s && tar -xf -)" % test_deb_dir) # # Now set up creation and installation of the packages. @@ -515,11 +509,14 @@ for p in [ scons ]: env.Install(os.path.join('build', 'dist'), install_targets) # - # Unpack the archive created by the distutils into build/unpack. + # Unpack the archive created by the distutils into + # build/unpack/scons-{version}. # - d = os.path.join(unpack_dir, pkg_version) - unpack_files = map(lambda x, d=d: os.path.join(d, x), src_files) + unpack_files = map(lambda x, u=unpack_dir, pv=pkg_version: + os.path.join(u, pv, x), + src_files) + # # We'd like to replace the last three lines with the following: # # tar zxf %< -C $unpack_dir @@ -535,40 +532,35 @@ for p in [ scons ]: # # Run setup.py in the unpacked subdirectory to "install" everything - # into our build/test subdirectory. Auxiliary modules that we need - # (TestCmd.py, TestSCons.py, unittest.py) will be copied in by - # etc/Conscript. The runtest.py script will set PYTHONPATH so that - # the tests only look under build/test. This makes sure that our - # tests pass with what we really packaged, not because of something - # hanging around in the development directory. + # into our build/test subdirectory. The runtest.py script will set + # PYTHONPATH so that the tests only look under build/test-{package}, + # and under etc (for the testing modules TestCmd.py, TestSCons.py, + # and unittest.py). This makes sure that our tests pass with what + # we really packaged, not because of something hanging around in + # the development directory. # # We can get away with calling setup.py using a directory path # like this because we put a preamble in it that will chdir() # to the directory in which setup.py exists. - dst_files = map(lambda x, i=install: os.path.join(i, x), dst_files) - env.Command(dst_files, unpack_files, [ - "rm -rf %s" % install, + dfiles = map(lambda x, d=test_arch_dir: os.path.join(d, x), dst_files) + env.Command(dfiles, unpack_files, [ + "rm -rf %s" % os.path.join(unpack_dir, pkg_version, 'build'), + "rm -rf %s" % test_arch_dir, "python %s install --prefix=%s" % (os.path.join(unpack_dir, pkg_version, 'setup.py'), - prefix + test_arch_dir ), ]) -# -# Arrange for supporting packages to be installed in the test directories. -# -Export('env', 'whereis') - -SConscript('etc/SConscript') - # # Documentation. # BuildDir('build/doc', 'doc') -SConscript('build/doc/SConscript'); +Export('env', 'whereis') +SConscript('build/doc/SConscript'); # # If we're running in the actual Aegis project, pack up a complete @@ -582,7 +574,10 @@ if change: for line in map(lambda x: x[:-1], os.popen(cmd, "r").readlines()): a = string.split(line) if a[1] == "remove": - df.append(a[3]) + if a[3][0] == '(': + df.append(a[4]) + else: + df.append(a[3]) cmd = "aegis -list -terse pf 2>/dev/null" pf = map(lambda x: x[:-1], os.popen(cmd, "r").readlines()) @@ -604,6 +599,8 @@ if change: b_ps = os.path.join('build', ps) b_psv = os.path.join('build', psv) + src_archive = os.path.join('build', 'dist', '%s.tar.gz' % psv) + for file in sfiles: env.SCons_revision(os.path.join(b_ps, file), file) @@ -615,7 +612,64 @@ if change: "find %s -name .sconsign -exec rm {} \\;" % b_psv, "tar czh -f $TARGET -C build %s" % psv, ] - env.Command(os.path.join('build', - 'dist', - '%s-src-%s.tar.gz' % (project, version)), - src_deps + b_ps_files, cmds) + + env.Command(src_archive, src_deps + b_ps_files, cmds) + + # + # Unpack the archive created by the distutils into + # build/unpack/scons-{version}. + # + unpack_files = map(lambda x, u=unpack_dir, psv=psv: + os.path.join(u, psv, x), + sfiles) + + # + # We'd like to replace the last three lines with the following: + # + # tar zxf %< -C $unpack_dir + # + # but that gives heartburn to Cygwin's tar, so work around it + # with separate zcat-tar-rm commands. + env.Command(unpack_files, src_archive, [ + "rm -rf %s" % os.path.join(unpack_dir, psv), + "zcat $SOURCES > .temp", + "tar xf .temp -C %s" % unpack_dir, + "rm -f .temp", + ]) + + # + # Run setup.py in the unpacked subdirectory to "install" everything + # into our build/test subdirectory. The runtest.py script will set + # PYTHONPATH so that the tests only look under build/test-{package}, + # and under etc (for the testing modules TestCmd.py, TestSCons.py, + # and unittest.py). This makes sure that our tests pass with what + # we really packaged, not because of something hanging around in + # the development directory. + # + # We can get away with calling setup.py using a directory path + # like this because we put a preamble in it that will chdir() + # to the directory in which setup.py exists. + dfiles = map(lambda x, d=test_src_arch_dir: os.path.join(d, x), + dst_files) + ENV = env.Dictionary('ENV') + ENV['SCONS_LIB_DIR'] = os.path.join(unpack_dir, psv, 'src', 'engine') + ENV['USERNAME'] = developer + env.Copy(ENV = ENV).Command(dfiles, unpack_files, [ + "rm -rf %s" % os.path.join(unpack_dir, + psv, + 'build', + 'scons', + 'build'), + "rm -rf %s" % test_src_arch_dir, + "cd %s && python %s %s" % \ + (os.path.join(unpack_dir, psv), + os.path.join('src', 'script', 'scons.py'), + os.path.join('build', 'scons')), + "python %s install --prefix=%s" % (os.path.join(unpack_dir, + psv, + 'build', + 'scons', + 'setup.py'), + test_src_arch_dir + ), + ]) diff --git a/config b/config index 53873e34..1bac491f 100644 --- a/config +++ b/config @@ -242,7 +242,7 @@ diff_command = * written to conform to Perl conventions) and Aegis' expectations. * See the comments in the test.pl script itself for details. */ -test_command = "python ${Source runtest.py Absolute} -b aegis -q -v ${VERsion} ${File_Name}"; +test_command = "python ${Source runtest.py Absolute} -p tar-gz -q ${File_Name}"; new_test_filename = "test/CHANGETHIS.py"; diff --git a/etc/SConscript b/etc/SConscript deleted file mode 100644 index d5736656..00000000 --- a/etc/SConscript +++ /dev/null @@ -1,45 +0,0 @@ -# -# SConscript for installing auxiliary modules, external stuff that -# we keep checked in so everyone doesn't have to install a bunch -# of stuff to work on SCons. -# -# THIS IS NOT READY YET. DO NOT TRY TO BUILD SCons WITH ITSELF YET. -# - -# -# 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. -# - -import os.path - -Import('env') - -modules = [ 'TestCmd.py', 'TestSCons.py', 'unittest.py' ] - -directories = [ - env.Dictionary('TEST1_LIB_DIR'), - env.Dictionary('TEST2_LIB_DIR') -] - -for module in modules: - for dir in directories: - env.SCons_revision(os.path.join(dir, module), module) diff --git a/runtest.py b/runtest.py index 4e4ed0c2..2344b98b 100644 --- a/runtest.py +++ b/runtest.py @@ -16,19 +16,9 @@ # # Options: # -# -1 Use the test configuration in build/test1 -# (installed from the scons package) -# -# -2 Use the test configuration in build/test2 -# (installed from the python-scons and scons-script -# packages) -# # -a Run all tests; does a virtual 'find' for # all SCons tests under the current directory. # -# -b system Assume you're in the specified built system. -# 'aegis' is the only one currently defined. -# # -d Debug. Runs the script under the Python # debugger (pdb.py) so you don't have to # muck with PYTHONPATH yourself. @@ -37,8 +27,13 @@ # command line it will execute before # executing it. This suppresses that print. # -# -v Version. Specifies the version number to -# be used for Aegis interaction. +# -p package Test against the specified package. +# +# (Note: There used to be a -v option that specified the SCons +# version to be tested, when we were installing in a version-specific +# library directory. If we ever resurrect that as the default, then +# you can find the appropriate code in the 0.04 version of this script, +# rather than reinventing that wheel.) # import getopt @@ -49,29 +44,24 @@ import string import sys all = 0 -build = None debug = '' tests = [] printcmd = 1 -version = None -testver = 1 +package = None if sys.platform == 'win32': lib_dir = os.path.join(sys.exec_prefix, "lib") else: lib_dir = os.path.join(sys.exec_prefix, "lib", "python" + sys.version[0:3]) -opts, tests = getopt.getopt(sys.argv[1:], "12ab:dqv:", +opts, tests = getopt.getopt(sys.argv[1:], "adqp:", ['all','build=','debug','quiet','version=']) for o, a in opts: - if o == '-1': testver = 1 - elif o == '-2': testver = 2 - elif o == '-a' or o == '--all': all = 1 - elif o == '-b' or o == '--build': build = a + if o == '-a' or o == '--all': all = 1 elif o == '-d' or o == '--debug': debug = os.path.join(lib_dir, "pdb.py") elif o == '-q' or o == '--quiet': printcmd = 0 - elif o == '-v' or o == '--version': version = a + elif o == '-p' or o == '--package': package = a cwd = os.getcwd() @@ -81,60 +71,43 @@ elif all: def find_Test_py(arg, dirname, names): global tests n = filter(lambda n: n[-8:] == "Tests.py", names) - n = map(lambda x,d=dirname: os.path.join(d, x), n) - tests = tests + n + tests.extend(map(lambda x,d=dirname: os.path.join(d, x), n)) os.path.walk('src', find_Test_py, 0) def find_py(arg, dirname, names): global tests n = filter(lambda n: n[-3:] == ".py", names) - n = map(lambda x,d=dirname: os.path.join(d, x), n) - tests = tests + n + tests.extend(map(lambda x,d=dirname: os.path.join(d, x), n)) os.path.walk('test', find_py, 0) -if build == 'aegis': - if not version: - version = os.popen("aesub '$version'").read()[:-1] - - match = re.compile(r'^[CD]0*') - - def aegis_to_version(aever): - arr = string.split(aever, '.') - end = max(len(arr) - 1, 2) - arr = map(lambda e: match.sub('', e), arr[:end]) - def rep(e): - if len(e) == 1: - e = '0' + e - return e - arr[1:] = map(rep, arr[1:]) - return string.join(arr, '.') - - version = aegis_to_version(version) - - scons_dir = os.path.join(cwd, 'build', 'test' + str(testver), 'bin') - - if testver == 1: - test_dir = os.path.join('test1', 'lib', 'scons') - # Our original packaging scheme placed the build engine - # in a private library directory that contained the SCons - # version number in the directory name. Here's how this - # was supported here. See the Construct file for details - # on other files that would need to be changed to support - # this as well. - #test_dir = os.path.join('test1', 'lib', 'scons-' + str(version)) - elif testver == 2: - test_dir = os.path.join('test2', 'lib', 'python' + sys.version[0:3], - 'site-packages') - - os.environ['PYTHONPATH'] = os.path.join(cwd, 'build', test_dir) + tests.sort() + +if package: + + dir = { + 'deb' : 'usr', + 'rpm' : 'usr', + 'src-tar-gz' : '', + 'tar-gz' : '', + } + + if not dir.has_key(package): + sys.stderr.write("Unknown package '%s'\n" % package) + sys.exit(2) + + test_dir = os.path.join(cwd, 'build', 'test-%s' % package) + + scons_dir = os.path.join(test_dir, dir[package], 'bin') + + lib_dir = os.path.join(test_dir, dir[package], 'lib', 'scons') else: scons_dir = os.path.join(cwd, 'src', 'script') - os.environ['PYTHONPATH'] = string.join([os.path.join(cwd, 'src', 'engine'), - os.path.join(cwd, 'etc')], - os.pathsep) + lib_dir = os.path.join(cwd, 'src', 'engine') + +os.environ['PYTHONPATH'] = lib_dir + os.pathsep + os.path.join(cwd, 'etc') os.chdir(scons_dir)