Commits

Anonymous committed 4650077

Revamp package testing.

  • Participants
  • Parent commits 15f2afd

Comments (0)

Files changed (5)

 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
 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
 ========================
 
 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")
 
-test1_lib_dir = os.path.join(test1_dir, lib_project)
+test_arch_dir = os.path.join(os.getcwd(),
+                             "build",
+                             "test-%s" % string.replace(archsuffix, '.', '-'))
 
-test2_lib_dir = os.path.join(test2_dir,
-                             "lib",
-                             "python" + python_ver,
-                             "site-packages")
+test_src_arch_dir = os.path.join(os.getcwd(),
+                                 "build",
+                                 "test-src-%s" % string.replace(archsuffix,
+                                                                '.',
+                                                                '-'))
 
-unpack_dir = os.path.join(os.getcwd(), "build", "unpack")
+test_rpm_dir = os.path.join(os.getcwd(), "build", "test-rpm")
+
+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.
 
 env = Environment(
                    ENV           = ENV,
-
-                   TEST1_LIB_DIR = test1_lib_dir,
-                   TEST2_LIB_DIR = test2_lib_dir,
  
                    DATE          = date,
                    DEVELOPER     = developer,
         'pkg'           : 'python-' + project,
         'src_subdir'    : 'engine',
         'inst_subdir'   : os.path.join('lib', 'python1.5', 'site-packages'),
-        'prefix'        : test2_dir,
 
         'debian_deps'   : [
                             'debian/rules',
 #        'pkg'          : 'python2-' + project,
 #        'src_subdir'   : 'engine',
 #        'inst_subdir'  : os.path.join('lib', 'python2.1', 'site-packages'),
-#        'prefix'       : test2_dir,
 #
 #        'debian_deps'  : [
 #                           'debian/rules',
         'pkg'           : project + '-script',
         'src_subdir'    : 'script',
         'inst_subdir'   : 'bin',
-        'prefix'        : test2_dir,
 
         'debian_deps'   : [
                             'debian/rules',
 
 scons = {
         'pkg'           : project,
-        #'inst_subdir'   : None,
-        'prefix'        : test1_dir,
 
         'debian_deps'   : [ 
                             'debian/rules',
 
     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,
 
         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:
                     ])
         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.
     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
 
     #
     # 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')
 
+Export('env', 'whereis')
+
 SConscript('build/doc/SConscript');
 
-
 #
 # If we're running in the actual Aegis project, pack up a complete
 # source archive from the project files and files in the 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())
         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)
 
             "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
+                                              ),
+        ])
  * 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";
 

File etc/SConscript

-#
-# 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)
 #
 # 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.
 #			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
 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()
 
     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]
+    tests.sort()
 
-    match = re.compile(r'^[CD]0*')
+if package:
 
-    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, '.')
+    dir = {
+        'deb'        : 'usr',
+        'rpm'        : 'usr',
+        'src-tar-gz' : '',
+        'tar-gz'     : '',
+    }
 
-    version = aegis_to_version(version)
+    if not dir.has_key(package):
+        sys.stderr.write("Unknown package '%s'\n" % package)
+        sys.exit(2)
 
-    scons_dir = os.path.join(cwd, 'build', 'test' + str(testver), 'bin')
+    test_dir = os.path.join(cwd, 'build', 'test-%s' % package)
 
-    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')
+    scons_dir = os.path.join(test_dir, dir[package], 'bin')
 
-    os.environ['PYTHONPATH'] = os.path.join(cwd, 'build', test_dir)
+    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)