You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/07/23 15:04:19 UTC
svn commit: r1506025 - /subversion/trunk/win-tests.py
Author: rhuijben
Date: Tue Jul 23 13:04:19 2013
New Revision: 1506025
URL: http://svn.apache.org/r1506025
Log:
Make the Windows test runner use the project model that it already loads to
locate the modules to copy to the test location. Use this knowledge to
cleanly setup a swig-perl environment for testing.
* win-tests.py
(imports): Import gen_base.
(argument parser): Remove warning for perl and python.
(copy_changed_file): Update arguments to be strict about dir and file
targets. Keep track of files to remove later.
(copy_execs): Remove function.
(locate_libs): Update caller. Fixes that insane problem where sometimes the
test directory became a file that bothered me for years.
(if create_dirs): Copy project output instead of walking everything to
locate *.exe in +- the entire tree.
(if test_swig == 'perl'):
Implement perl test runner.
Modified:
subversion/trunk/win-tests.py
Modified: subversion/trunk/win-tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/win-tests.py?rev=1506025&r1=1506024&r2=1506025&view=diff
==============================================================================
--- subversion/trunk/win-tests.py (original)
+++ subversion/trunk/win-tests.py Tue Jul 23 13:04:19 2013
@@ -111,6 +111,7 @@ sys.path.insert(0, os.path.join('build',
sys.path.insert(1, 'build')
import gen_win_dependencies
+import gen_base
version_header = os.path.join('subversion', 'include', 'svn_version.h')
cp = configparser.ConfigParser()
cp.read('gen-make.opts')
@@ -220,7 +221,7 @@ for opt, val in opts:
elif opt == '--javahl':
test_javahl = 1
elif opt == '--swig':
- if val not in ['ruby']:
+ if val not in ['perl', 'python', 'ruby']:
sys.stderr.write('Running \'%s\' swig tests not supported (yet).\n'
% (val,))
test_swig = val
@@ -297,12 +298,18 @@ def create_target_dir(dirname):
print("mkdir: %s" % tgt_dir)
os.makedirs(tgt_dir)
-def copy_changed_file(src, tgt):
+def copy_changed_file(src, tgt=None, to_dir=None, cleanup=True):
if not os.path.isfile(src):
print('Could not find ' + src)
sys.exit(1)
- if os.path.isdir(tgt):
- tgt = os.path.join(tgt, os.path.basename(src))
+
+ if to_dir and not tgt:
+ tgt = os.path.join(to_dir, os.path.basename(src))
+ elif not tgt or (tgt and to_dir):
+ raise RuntimeError("Using 'tgt' *or* 'to_dir' is required" % (tgt,))
+ elif tgt and os.path.isdir(tgt):
+ raise RuntimeError("'%s' is a directory. Use to_dir=" % (tgt,))
+
if os.path.exists(tgt):
assert os.path.isfile(tgt)
if filecmp.cmp(src, tgt):
@@ -314,24 +321,13 @@ def copy_changed_file(src, tgt):
print("copy: %s" % src)
print(" to: %s" % tgt)
shutil.copy(src, tgt)
- return 1
-def copy_execs(baton, dirname, names):
- copied_execs = baton
- for name in names:
- if not name.endswith('.exe'):
- continue
- src = os.path.join(dirname, name)
- tgt = os.path.join(abs_builddir, dirname, name)
- create_target_dir(dirname)
- if copy_changed_file(src, tgt):
- copied_execs.append(tgt)
+ if cleanup:
+ copied_execs.append(tgt)
def locate_libs():
"Move DLLs to a known location and set env vars"
- dlls = []
-
debug = (objdir == 'Debug')
for lib in gen_obj._libraries.values():
@@ -342,15 +338,16 @@ def locate_libs():
name, dir = lib.dll_name, lib.dll_dir
if name and dir:
- dlls.append(os.path.join(dir, name))
+ src = os.path.join(dir, name)
+ if os.path.exists(src):
+ copy_changed_file(src, to_dir=abs_builddir, cleanup=False)
- for dll in dlls:
- copy_changed_file(dll, abs_builddir)
# Copy the Subversion library DLLs
if not cp.has_option('options', '--disable-shared'):
for svn_dll in svn_dlls:
- copy_changed_file(os.path.join(abs_objdir, svn_dll), abs_builddir)
+ copy_changed_file(os.path.join(abs_objdir, svn_dll), to_dir=abs_builddir,
+ cleanup=False)
# Copy the Apache modules
if run_httpd and cp.has_option('options', '--with-httpd'):
@@ -361,9 +358,9 @@ def locate_libs():
mod_dontdothat_path = os.path.join(abs_objdir, 'tools', 'server-side',
'mod_dontdothat', 'mod_dontdothat.so')
- copy_changed_file(mod_dav_svn_path, abs_builddir)
- copy_changed_file(mod_authz_svn_path, abs_builddir)
- copy_changed_file(mod_dontdothat_path, abs_builddir)
+ copy_changed_file(mod_dav_svn_path, to_dir=abs_builddir, cleanup=False)
+ copy_changed_file(mod_authz_svn_path, to_dir=abs_builddir, cleanup=False)
+ copy_changed_file(mod_dontdothat_path, to_dir=abs_builddir, cleanup=False)
os.environ['PATH'] = abs_builddir + os.pathsep + os.environ['PATH']
@@ -684,19 +681,14 @@ class Httpd:
# Move the binaries to the test directory
locate_libs()
if create_dirs:
- old_cwd = os.getcwd()
- try:
- os.chdir(abs_objdir)
- baton = copied_execs
- for dirpath, dirs, files in os.walk('subversion'):
- copy_execs(baton, dirpath, files)
- for dirpath, dirs, files in os.walk('tools/server-side'):
- copy_execs(baton, dirpath, files)
- except:
- os.chdir(old_cwd)
- raise
- else:
- os.chdir(old_cwd)
+ for i in gen_obj.graph.get_all_sources(gen_base.DT_INSTALL):
+ if isinstance(i, gen_base.TargetExe):
+ src = os.path.join(abs_objdir, i.filename)
+
+ if os.path.isfile(src):
+ dst = os.path.join(abs_builddir, i.filename)
+ create_target_dir(os.path.dirname(dst))
+ copy_changed_file(src, dst)
# Create the base directory for Python tests
create_target_dir(CMDLINE_TEST_SCRIPT_NATIVE_PATH)
@@ -821,32 +813,67 @@ elif test_javahl:
print('[Test runner reported failure]')
failed = True
elif test_swig == 'perl':
- print('Running Swig Perl tests not supported yet')
+ swig_dir = os.path.join(abs_builddir, 'swig')
+ swig_pl_dir = os.path.join(swig_dir, 'p5lib')
+ swig_pl_svn = os.path.join(swig_pl_dir, 'SVN')
+ swig_pl_auto_svn = os.path.join(swig_pl_dir, 'auto', 'SVN')
- # TODO: Implement something like
-
- # mkdir "%TESTDIR%\swig\pl-release\SVN"
- # mkdir "%TESTDIR%\swig\pl-release\auto\SVN"
- # xcopy subversion\bindings\swig\perl\native\*.pm "%TESTDIR%\swig\pl-release\SVN" > nul:
- # pushd release\subversion\bindings\swig\perl\native
- # for %%i in (*.dll) do (
- # set name=%%i
- # mkdir "%TESTDIR%\swig\pl-release\auto\SVN\!name:~0,-4!"
- # xcopy "!name:~0,-4!.*" "%TESTDIR%\swig\pl-release\auto\SVN\!name:~0,-4!" > nul:
- # xcopy /y "_Core.dll" "%TESTDIR%\swig\pl-release\auto\SVN\!name:~0,-4!" > nul:
- # )
- # popd
- #
- # SET PERL5LIB=%PERL5LIB%;%TESTDIR%\swig\pl-release;
- # pushd subversion\bindings\swig\perl\native
- # perl -MExtUtils::Command::MM -e test_harness() t\*.t
- # IF ERRORLEVEL 1 (
- # echo [Perl reported error %ERRORLEVEL%]
- # SET result=1
- # )
- # popd
+ create_target_dir(swig_pl_svn)
+
+ for i in gen_obj.graph.get_all_sources(gen_base.DT_INSTALL):
+ if isinstance(i, gen_base.TargetSWIG) and i.lang == 'perl':
+
+ src = os.path.join(abs_objdir, i.filename)
+
+ # Copy _Core.dll to a location in $PATH
+ if i.name == 'perl_core':
+ copy_changed_file(src, to_dir=abs_builddir)
+
+ mod_dir = os.path.join(swig_pl_auto_svn, '_' + i.name[5:].capitalize())
+ create_target_dir(mod_dir)
+
+ copy_changed_file(src, to_dir=mod_dir)
+
+ pm_src = os.path.join(abs_srcdir, 'subversion', 'bindings', 'swig', 'perl',
+ 'native')
+
+ tests = []
+
+ for root, dirs, files in os.walk(pm_src):
+ for name in files:
+ if name.endswith('.pm'):
+ fn = os.path.join(root, name)
+ print(fn)
+ copy_changed_file(fn, to_dir=swig_pl_svn)
+ elif name.endswith('.t'):
+ tests.append(os.path.relpath(os.path.join(root, name), pm_src))
+
+ perl5lib = swig_pl_dir
+ if 'PERL5LIB' in os.environ:
+ perl5lib += os.pathsep + os.environ['PERL5LIB']
+
+ perl_exe = 'perl.exe'
+
+ print('-- Running Swig Perl tests --')
+ old_cwd = os.getcwd()
+ try:
+ os.chdir(pm_src)
+
+ os.environ['PERL5LIB'] = perl5lib
+
+ r = subprocess.call([
+ perl_exe,
+ '-MExtUtils::Command::MM',
+ '-e', 'test_harness()'
+ ] + tests)
+ finally:
+ os.chdir(old_cwd)
+
+ if (r != 0):
+ print()
+ print('[Test runner reported failure]')
+ failed = True
- failed = False
elif test_swig == 'python':
print('Running Swig Python tests not supported yet')
@@ -876,7 +903,6 @@ elif test_swig == 'ruby':
if 'ruby' not in gen_obj._libraries:
print('Ruby not found. Skipping Ruby tests')
else:
- print('Running Swig Ruby Tests')
ruby_lib = gen_obj._libraries['ruby']
ruby_exe = 'ruby.exe'
@@ -887,6 +913,7 @@ elif test_swig == 'ruby':
'--verbose'
]
+ print('-- Running Swig Ruby tests --')
old_cwd = os.getcwd()
try:
os.chdir(ruby_subdir)