summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml9
-rwxr-xr-x.travis/install.sh10
-rw-r--r--SConstruct2
-rwxr-xr-xruntest.py17
-rw-r--r--src/CHANGES.txt37
-rw-r--r--src/engine/SCons/Action.py13
-rw-r--r--src/engine/SCons/Platform/win32.py6
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py17
-rw-r--r--test/AS/nasm.py14
-rw-r--r--test/MSVS/vs-10.0Exp-exec.py8
-rw-r--r--test/MSVS/vs-11.0-exec.py8
-rw-r--r--test/MSVS/vs-11.0Exp-exec.py8
-rw-r--r--test/MSVS/vs-14.0-exec.py8
-rw-r--r--test/MSVS/vs-6.0-clean.py2
-rw-r--r--test/MSVS/vs-6.0-exec.py8
-rw-r--r--test/MSVS/vs-7.0-exec.py8
-rw-r--r--test/MSVS/vs-7.1-exec.py8
-rw-r--r--test/MSVS/vs-8.0-exec.py7
-rw-r--r--test/MSVS/vs-8.0Exp-exec.py8
-rw-r--r--test/MSVS/vs-9.0-exec.py8
-rw-r--r--test/MSVS/vs-9.0Exp-exec.py8
-rw-r--r--test/SWIG/SWIGOUTDIR-python.py6
-rw-r--r--test/SWIG/build-dir.py6
-rw-r--r--test/SWIG/generated_swigfile.py6
-rw-r--r--test/SWIG/live.py11
-rw-r--r--test/SWIG/module-deduced-name.py6
-rw-r--r--test/SWIG/module-parens.py6
-rw-r--r--test/SWIG/module-quoted.py6
-rw-r--r--test/SWIG/module-spaces.py6
-rw-r--r--test/SWIG/noproxy.py6
-rw-r--r--test/SWIG/recursive-includes-cpp.py5
-rw-r--r--test/SWIG/remove-modules.py6
-rw-r--r--test/SWIG/subdir.py6
-rw-r--r--testing/framework/TestSCons.py63
34 files changed, 213 insertions, 140 deletions
diff --git a/.travis.yml b/.travis.yml
index 58ca595..ea63e57 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,9 @@
dist: trusty
language: python
+notifications:
+ irc: "chat.freenode.net#scons"
+
addons:
apt:
update: true
@@ -36,9 +39,11 @@ jobs:
sudo: required
- <<: *test_job
- python: 3.7-dev
- env: PYVER=37
+ python: 3.7
+ env:
+ - PYVER=37
sudo: required
+ dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
- <<: *test_job
python: pypy
diff --git a/.travis/install.sh b/.travis/install.sh
index 24735a8..6f2cfe2 100755
--- a/.travis/install.sh
+++ b/.travis/install.sh
@@ -1,14 +1,16 @@
#!/usr/bin/env bash
set -x
-# dependencies for clang tests
-sudo apt-get -y install clang
+# setup clang for clang tests using local clang installation
+sudo ln -s /usr/local/clang-5.0.0/bin/clang /usr/bin/clang
+sudo ln -s /usr/local/clang-5.0.0/bin/clang++ /usr/bin/clang++
+
# dependencies for gdc tests
sudo apt-get -y install gdc
# dependencies for docbook tests
sudo apt-get -y install docbook-xml xsltproc libxml2-dev libxslt-dev fop docbook-xsl-doc-pdf
# dependencies for latex tests
-sudo apt-get -y install texlive texlive-latex3 biber texmaker
+sudo apt-get -y install texlive texlive-latex3 biber texmaker ghostscript
# need some things for building dependencies for other tests
sudo apt-get -y install python-pip python-dev build-essential libpcre3-dev autoconf automake libtool bison subversion git
# dependencies for docbook tests continued
@@ -30,4 +32,4 @@ if [[ "$PYVER" == 27 ]]; then
wget https://github.com/swig/swig/archive/rel-3.0.12.tar.gz
tar xzf rel-3.0.12.tar.gz
cd swig-rel-3.0.12 && ./autogen.sh && ./configure --prefix=/usr && make && sudo make install && cd ..
-fi
+fi \ No newline at end of file
diff --git a/SConstruct b/SConstruct
index fc94abd..f644d6d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -825,7 +825,7 @@ for p in [ scons ]:
#
Export('build_dir', 'env')
-SConscript('testing/SConscript')
+SConscript('testing/framework/SConscript')
#
#
diff --git a/runtest.py b/runtest.py
index 293e4ca..9ffe374 100755
--- a/runtest.py
+++ b/runtest.py
@@ -99,7 +99,6 @@ except ImportError as e: # python2
from Queue import Queue
import subprocess
-
cwd = os.getcwd()
baseline = 0
@@ -619,6 +618,10 @@ os.environ['SCONS_VERSION'] = version
old_pythonpath = os.environ.get('PYTHONPATH')
+# Clear _JAVA_OPTIONS which java tools output to stderr when run breaking tests
+if '_JAVA_OPTIONS' in os.environ:
+ del os.environ['_JAVA_OPTIONS']
+
# FIXME: the following is necessary to pull in half of the testing
# harness from $srcdir/etc. Those modules should be transfered
# to testing/, in which case this manipulation of PYTHONPATH
@@ -770,10 +773,14 @@ os.environ["python_executable"] = python
# but time.time() does a better job on Linux systems, so let that be
# the non-Windows default.
-if sys.platform == 'win32':
- time_func = time.clock
-else:
- time_func = time.time
+#TODO: clean up when py2 support is dropped
+try:
+ time_func = time.perf_counter
+except AttributeError:
+ if sys.platform == 'win32':
+ time_func = time.clock
+ else:
+ time_func = time.time
if print_times:
print_time_func = lambda fmt, time: sys.stdout.write(fmt % time)
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 8c5b90a..6f7e851 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -9,6 +9,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
From Daniel Moody:
- Updated FS.py to handle removal of splitunc function from python 3.7
+ - Updated the vc.py to ignore MSVS versions where not compiler could be found
From Matthew Marinets:
- Fixed an issue that caused the Java emitter to incorrectly parse arguments to constructors that
@@ -103,9 +104,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
- Recognize new java 9, 10 (as 9.0 and 10.0)
- Updated manpage scons.xml to fix a nested list problem
- Updated doc terminiology: use prepend instead of append as appropriate
- - xml validity fixes from SConstruct.py change
- - update wiki links to new github location
- - update bug links to new github location
+ - XML validity fixes from SConstruct.py change
+ - Update wiki links to new github location
+ - Update bug links to new github location
- Make it easier for SConscript() call to fail on missing script.
It was possible to call SCons.Warnings.warningAsException
(not documented as a user API) to make all warnings fail. Now
@@ -116,17 +117,25 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
behavior (which still defaults to warn, not fail) by calling
SCons.Script.set_missing_sconscript_error, which is also not a
documented interface at the moment.
- - convert TestCmd.read to use with statement on open (quiets 17 py3 warnings)
- - quiet py3 warning in UtilTests.py
- - fix tests specifying octal constants for py3
- - fix must_contain tests for py3
- - rpm package generation: fix supplying a build architecture; disable
- auto debug package generation on certain rpmbuild versions; adjust some
- tests to be resistant to automatic supplying of build-id file on
- certain rpmbuild versions; tests now use a file fixture for the
- repeated (trivial) main.c program. A little doc and comment cleanup.
- A new tag is added, X_RPM_EXTRADEFS, to allow supplying custom settings
- to the specfile without adding specific logic for each one to scons.
+ - Convert TestCmd.read to use with statement on open (quiets 17 py3 warnings)
+ - Quiet py3 warning in UtilTests.py
+ - Fix tests specifying octal constants for py3
+ - Fix must_contain tests for py3
+ - RPM package generation:
+ - Fix supplying a build architecture
+ - Disable auto debug package generation on certain rpmbuild versions
+ - Adjust some tests to only supply build-id file on certain rpmbuild versions
+ - Tests now use a file fixture for the repeated (trivial) main.c program.
+ - Document and comment cleanup.
+ - Added new Environment Value X_RPM_EXTRADEFS to supply custom settings
+ to the specfile without adding specific logic for each one to scons.
+ - One swig test now checks for Python.h instead of failing
+ - If test opens os.devnull, register with atexit so file opens do not leak.
+ - Fix bugs in Win32 process spawn logic to handle OSError exception correctly.
+ - Use time.perf_counter instead of time.clock if it exists.
+ time.clock deprecated since py3.3, due to remove in 3.8. deprecation
+ warnings from py3.7 were failing a bunch of tests on Windows since they
+ mess up expected stderr.
From Hao Wu
- typo in customized decider example in user guide
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index b44088b..44ddacd 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -115,8 +115,7 @@ import SCons.Util
import SCons.Subst
# we use these a lot, so try to optimize them
-is_String = SCons.Util.is_String
-is_List = SCons.Util.is_List
+from SCons.Util import is_String, is_List
class _null(object):
pass
@@ -803,7 +802,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
kw['env'] = new_env
try:
- return subprocess.Popen(cmd, **kw)
+ pobj = subprocess.Popen(cmd, **kw)
except EnvironmentError as e:
if error == 'raise': raise
# return a dummy Popen instance that only returns error
@@ -817,7 +816,13 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
def readline(self): return ''
def __iter__(self): return iter(())
stdout = stderr = f()
- return dummyPopen(e)
+ pobj = dummyPopen(e)
+ finally:
+ # clean up open file handles stored in parent's kw
+ for k, v in kw.items():
+ if hasattr(v, 'close'):
+ v.close()
+ return pobj
class CommandAction(_ActionAction):
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index 5c877b5..ea2fd3f 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -200,11 +200,11 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
except OSError as e:
# catch any error
try:
- ret = exitvalmap[e[0]]
+ ret = exitvalmap[e.errno]
except KeyError:
- sys.stderr.write("scons: unknown OSError exception code %d - %s: %s\n" % (e[0], cmd, e[1]))
+ sys.stderr.write("scons: unknown OSError exception code %d - %s: %s\n" % (e.errno, cmd, e.strerror))
if stderr is not None:
- stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ stderr.write("scons: %s: %s\n" % (cmd, e.strerror))
# copy child output from tempfiles to our streams
# and do clean up stuff
if stdout is not None and stdoutRedirected == 0:
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 53bd397..32ee96f 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -43,6 +43,7 @@ import platform
from string import digits as string_digits
import SCons.Warnings
+from SCons.Tool import find_program_path
from . import common
@@ -357,9 +358,15 @@ def get_installed_vcs():
for ver in _VCVER:
debug('trying to find VC %s' % ver)
try:
- if find_vc_pdir(ver):
+ VC_DIR = find_vc_pdir(ver)
+ if VC_DIR:
debug('found VC %s' % ver)
- installed_versions.append(ver)
+ # check to see if the x86 or 64 bit compiler is in the bin dir
+ if (os.path.exists(os.path.join(VC_DIR, r'bin\cl.exe'))
+ or os.path.exists(os.path.join(VC_DIR, r'bin\amd64\cl.exe'))):
+ installed_versions.append(ver)
+ else:
+ debug('find_vc_pdir no cl.exe found %s' % ver)
else:
debug('find_vc_pdir return None for ver %s' % ver)
except VisualCException as e:
@@ -565,6 +572,12 @@ def msvc_setup_env(env):
for k, v in d.items():
debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v))
env.PrependENVPath(k, v, delete_existing=True)
+
+ # final check to issue a warning if the compiler is not present
+ msvc_cl = find_program_path(env, 'cl')
+ if not msvc_cl:
+ SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning,
+ "Could not find MSVC compiler 'cl.exe', it may need to be installed separately with Visual Studio")
def msvc_exists(version=None):
vcs = cached_get_installed_vcs()
diff --git a/test/AS/nasm.py b/test/AS/nasm.py
index 1733789..4d93c7f 100644
--- a/test/AS/nasm.py
+++ b/test/AS/nasm.py
@@ -47,17 +47,18 @@ if sys.platform.find('linux') == -1:
test.skip_test("skipping test on non-Linux platform '%s'\n" % sys.platform)
try:
- import popen2
- stdout = popen2.popen2('nasm -v')[0]
+ import subprocess
+ stdout = subprocess.check_output(['nasm','-v'])
except OSError:
test.skip_test('could not determine nasm version; skipping test\n')
else:
- version = stdout.read().split()[2]
- if version[:4] != '0.98':
+ stdout = stdout.decode()
+ version = stdout.split()[2].split('.')
+ if int(version[0]) ==0 and int(version[1]) < 98:
test.skip_test("skipping test of nasm version %s\n" % version)
machine = os.uname()[4]
- if not machine in ('i386', 'i486', 'i586', 'i686'):
+ if not machine in ('i386', 'i486', 'i586', 'i686', 'x86_64'):
fmt = "skipping test of nasm %s on non-x86 machine '%s'\n"
test.skip_test(fmt % (version, machine))
@@ -78,6 +79,8 @@ test.file_fixture('wrapper.py')
test.write('SConstruct', """
eee = Environment(tools = ['gcc', 'gnulink', 'nasm'],
+ CFLAGS = ['-m32'],
+ LINKFLAGS = '-m32',
ASFLAGS = '-f %(nasm_format)s')
fff = eee.Clone(AS = r'%(_python_)s wrapper.py ' + WhereIs('nasm'))
eee.Program(target = 'eee', source = ['eee.asm', 'eee_main.c'])
@@ -99,6 +102,7 @@ name:
""")
test.write('eee_main.c', r"""
+#include <stdio.h>
extern char name[];
int
diff --git a/test/MSVS/vs-10.0Exp-exec.py b/test/MSVS/vs-10.0Exp-exec.py
index a63f6c4..d6114bd 100644
--- a/test/MSVS/vs-10.0Exp-exec.py
+++ b/test/MSVS/vs-10.0Exp-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-11.0-exec.py b/test/MSVS/vs-11.0-exec.py
index 21645f5..48acd1c 100644
--- a/test/MSVS/vs-11.0-exec.py
+++ b/test/MSVS/vs-11.0-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-11.0Exp-exec.py b/test/MSVS/vs-11.0Exp-exec.py
index be48971..6a288a5 100644
--- a/test/MSVS/vs-11.0Exp-exec.py
+++ b/test/MSVS/vs-11.0Exp-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-14.0-exec.py b/test/MSVS/vs-14.0-exec.py
index f2a826c..d2b7112 100644
--- a/test/MSVS/vs-14.0-exec.py
+++ b/test/MSVS/vs-14.0-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-6.0-clean.py b/test/MSVS/vs-6.0-clean.py
index 6b9bd98..0cbadba 100644
--- a/test/MSVS/vs-6.0-clean.py
+++ b/test/MSVS/vs-6.0-clean.py
@@ -72,7 +72,7 @@ env.MSVSSolution(target = 'Test.dsw',
variant = 'Release')
"""%{'HOST_ARCH':host_arch})
-test.run(arguments=".")
+test.run()
test.must_exist(test.workpath('Test.dsp'))
dsp = test.read('Test.dsp', 'r')
diff --git a/test/MSVS/vs-6.0-exec.py b/test/MSVS/vs-6.0-exec.py
index d017790..0864f76 100644
--- a/test/MSVS/vs-6.0-exec.py
+++ b/test/MSVS/vs-6.0-exec.py
@@ -54,10 +54,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-7.0-exec.py b/test/MSVS/vs-7.0-exec.py
index e62ee77..e95ca83 100644
--- a/test/MSVS/vs-7.0-exec.py
+++ b/test/MSVS/vs-7.0-exec.py
@@ -54,10 +54,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-7.1-exec.py b/test/MSVS/vs-7.1-exec.py
index 42f6ae8..11ea617 100644
--- a/test/MSVS/vs-7.1-exec.py
+++ b/test/MSVS/vs-7.1-exec.py
@@ -54,10 +54,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-8.0-exec.py b/test/MSVS/vs-8.0-exec.py
index 96c4c29..4b0a6dd 100644
--- a/test/MSVS/vs-8.0-exec.py
+++ b/test/MSVS/vs-8.0-exec.py
@@ -55,9 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-print("os.environ.update(%%s)" %% repr(env['ENV']))
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-8.0Exp-exec.py b/test/MSVS/vs-8.0Exp-exec.py
index 66196f1..0e4396d 100644
--- a/test/MSVS/vs-8.0Exp-exec.py
+++ b/test/MSVS/vs-8.0Exp-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-9.0-exec.py b/test/MSVS/vs-9.0-exec.py
index 7b544aa..3f823fa 100644
--- a/test/MSVS/vs-9.0-exec.py
+++ b/test/MSVS/vs-9.0-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/MSVS/vs-9.0Exp-exec.py b/test/MSVS/vs-9.0Exp-exec.py
index caa763e..5a65faf 100644
--- a/test/MSVS/vs-9.0Exp-exec.py
+++ b/test/MSVS/vs-9.0Exp-exec.py
@@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions():
test.run(arguments = '-n -q -Q -f -', stdin = """\
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
-sconsEnv = repr(env['ENV'])
-print("os.environ.update(" + sconsEnv + ")")
+if env.WhereIs('cl'):
+ print("os.environ.update(%%s)" %% repr(env['ENV']))
""" % locals())
+if(test.stdout() == ""):
+ msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
+ test.skip_test(msg)
+
exec(test.stdout())
diff --git a/test/SWIG/SWIGOUTDIR-python.py b/test/SWIG/SWIGOUTDIR-python.py
index db0cc95..8d6703f 100644
--- a/test/SWIG/SWIGOUTDIR-python.py
+++ b/test/SWIG/SWIGOUTDIR-python.py
@@ -30,7 +30,6 @@ that Python files are created in the specified output directory.
"""
import TestSCons
-import os
import sys
test = TestSCons.TestSCons()
@@ -40,10 +39,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# On Windows, build a 32-bit exe if on 32-bit python.
if sys.platform == 'win32' and sys.maxsize <= 2**32:
diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py
index eba3fea..d268c87 100644
--- a/test/SWIG/build-dir.py
+++ b/test/SWIG/build-dir.py
@@ -29,7 +29,6 @@ Make sure SWIG works when a VariantDir (or variant_dir) is used.
Test case courtesy Joe Maruszewski.
"""
-import os.path
import sys
import TestSCons
@@ -50,10 +49,7 @@ else:
test.subdir(['source'])
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
if sys.platform == 'win32' and sys.maxsize <= 2**32:
swig_arch_var="TARGET_ARCH='x86',"
diff --git a/test/SWIG/generated_swigfile.py b/test/SWIG/generated_swigfile.py
index d09b473..145349b 100644
--- a/test/SWIG/generated_swigfile.py
+++ b/test/SWIG/generated_swigfile.py
@@ -29,7 +29,6 @@ Verify that SCons realizes the -noproxy option means no .py file will
be created.
"""
-import os
import sys
import TestSCons
@@ -55,10 +54,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# handle testing on other platforms:
ldmodule_prefix = '_'
diff --git a/test/SWIG/live.py b/test/SWIG/live.py
index 7c4bdce..a64defe 100644
--- a/test/SWIG/live.py
+++ b/test/SWIG/live.py
@@ -28,7 +28,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
Test SWIG behavior with a live, installed SWIG.
"""
-import os.path
+import os
import sys
import TestSCons
@@ -46,12 +46,9 @@ swig = test.where_is('swig')
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = python_include + '/Python.h'
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
+
swig = swig.replace('\\','/')
python = python.replace('\\','/')
python_include = python_include.replace('\\','/')
@@ -170,4 +167,4 @@ test.pass_test()
# tab-width:4
# indent-tabs-mode:nil
# End:
-# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/SWIG/module-deduced-name.py b/test/SWIG/module-deduced-name.py
index bdaef4f..14d23a2 100644
--- a/test/SWIG/module-deduced-name.py
+++ b/test/SWIG/module-deduced-name.py
@@ -31,7 +31,6 @@ emitter should return the basename of the module only.
"""
import TestSCons
-import os
import sys
test = TestSCons.TestSCons()
@@ -41,10 +40,7 @@ if not swig:
test.skip_test('Cannot find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Cannot find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# On Windows, build a 32-bit exe if on 32-bit python.
if sys.platform == 'win32' and sys.maxsize <= 2**32:
diff --git a/test/SWIG/module-parens.py b/test/SWIG/module-parens.py
index d8c1744..4ce7511 100644
--- a/test/SWIG/module-parens.py
+++ b/test/SWIG/module-parens.py
@@ -29,7 +29,6 @@ Verify that we handle %module(directors="1") statements, both with and
without white space before the opening parenthesis.
"""
-import os.path
import sys
import TestSCons
@@ -40,10 +39,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/module-quoted.py b/test/SWIG/module-quoted.py
index 6f4b891..60bc0b0 100644
--- a/test/SWIG/module-quoted.py
+++ b/test/SWIG/module-quoted.py
@@ -29,7 +29,6 @@ Verify that we correctly parse quoted module names; e.g. %module "test"
(SWIG permits double-quoted names but not single-quoted ones.)
"""
-import os.path
import sys
import TestSCons
@@ -40,10 +39,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/module-spaces.py b/test/SWIG/module-spaces.py
index 2833dff..6a3f270 100644
--- a/test/SWIG/module-spaces.py
+++ b/test/SWIG/module-spaces.py
@@ -29,7 +29,6 @@ Verify that we correctly parse module names with spaces on the line after
the module name ; e.g. "%module test "
"""
-import os.path
import sys
import TestSCons
@@ -40,10 +39,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/noproxy.py b/test/SWIG/noproxy.py
index 1aaeb08..f94f553 100644
--- a/test/SWIG/noproxy.py
+++ b/test/SWIG/noproxy.py
@@ -29,7 +29,6 @@ Verify that SCons realizes the -noproxy option means no .py file will
be created.
"""
-import os
import sys
import TestSCons
@@ -48,10 +47,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# handle testing on other platforms:
ldmodule_prefix = '_'
diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py
index b943406..3999cc3 100644
--- a/test/SWIG/recursive-includes-cpp.py
+++ b/test/SWIG/recursive-includes-cpp.py
@@ -44,6 +44,9 @@ for pre_req in ['swig', 'python']:
if not test.where_is(pre_req):
test.skip_test('Can not find installed "' + pre_req + '", skipping test.%s' % os.linesep)
+python, python_include, python_libpath, python_lib = \
+ test.get_platform_python_info(python_h_required=True)
+
if sys.platform == 'win32':
python_lib = os.path.dirname(sys.executable) + "/libs/" + ('python%d%d'%(sys.version_info[0],sys.version_info[1])) + '.lib'
if( not os.path.isfile(python_lib)):
@@ -150,4 +153,4 @@ test.pass_test()
# tab-width:4
# indent-tabs-mode:nil
# End:
-# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py
index f5ce60d..a4d7b16 100644
--- a/test/SWIG/remove-modules.py
+++ b/test/SWIG/remove-modules.py
@@ -29,7 +29,6 @@ Verify that swig-generated modules are removed.
The %module directive specifies the module name.
"""
-import os.path
import sys
import TestSCons
@@ -48,10 +47,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# handle testing on other platforms:
ldmodule_prefix = '_'
diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py
index e23b858..6951753 100644
--- a/test/SWIG/subdir.py
+++ b/test/SWIG/subdir.py
@@ -29,7 +29,6 @@ Verify that we expect the .py file created by the -python flag to be in
the same subdirectory as the taget.
"""
-import os
import sys
import TestSCons
@@ -50,10 +49,7 @@ if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
python, python_include, python_libpath, python_lib = \
- test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+ test.get_platform_python_info(python_h_required=True)
# handle testing on other platforms:
ldmodule_prefix = '_'
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py
index 50942ab..bf6aabb 100644
--- a/testing/framework/TestSCons.py
+++ b/testing/framework/TestSCons.py
@@ -564,7 +564,7 @@ class TestSCons(TestCommon):
Returns a Python error line for output comparisons.
The exec of the traceback line gives us the correct format for
- this version of Python.
+ this version of Python.
File "<string>", line 1, <module>
@@ -607,7 +607,7 @@ class TestSCons(TestCommon):
pattern = to_bytes(pattern)
repl = to_bytes(repl)
return re.sub(pattern, repl, str, count, flags)
-
+
def normalize_pdf(self, s):
s = self.to_bytes_re_sub(r'/(Creation|Mod)Date \(D:[^)]*\)',
r'/\1Date (D:XXXX)', s)
@@ -811,7 +811,7 @@ class TestSCons(TestCommon):
where_jar = self.where_is('jar', ENV['PATH'])
if not where_jar:
self.skip_test("Could not find Java jar, skipping test(s).\n")
- elif sys.platform == "darwin":
+ elif sys.platform == "darwin":
self.java_mac_check(where_jar, 'jar')
return where_jar
@@ -885,7 +885,7 @@ class TestSCons(TestCommon):
self.skip_test("Could not find Java rmic, skipping non-simulated test(s).\n")
return where_rmic
-
+
def java_get_class_files(self, dir):
result = []
for dirpath, dirnames, filenames in os.walk(dir):
@@ -1078,7 +1078,7 @@ SConscript( sconscript )
doCheckLog=True, doCheckStdout=True):
"""
Used to verify the expected output from using Configure()
- via the contents of one or both of stdout or config.log file.
+ via the contents of one or both of stdout or config.log file.
The checks, results, cached parameters all are zipped together
for use in comparing results.
@@ -1160,19 +1160,19 @@ SConscript( sconscript )
sconstruct = sconstruct
log = r'file\ \S*%s\,line \d+:' % re.escape(sconstruct) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = "\t" + re.escape("Configure(confdir = %s)" % sconf_dir) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
-
+
rdstr = ""
cnt = 0
for check,result,cache_desc in zip(checks, results, cached):
log = re.escape("scons: Configure: " + check) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = ""
@@ -1217,7 +1217,7 @@ SConscript( sconscript )
rdstr = rdstr + re.escape(check) + re.escape(result) + "\n"
log=log + re.escape("scons: Configure: " + result) + ls + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = ""
@@ -1256,18 +1256,25 @@ SConscript( sconscript )
# see also sys.prefix documentation
return python_minor_version_string()
- def get_platform_python_info(self):
+ def get_platform_python_info(self, python_h_required=False):
"""
Returns a path to a Python executable suitable for testing on
- this platform and its associated include path, library path,
- and library name.
- Returns:
+ this platform and its associated include path, library path and
+ library name.
+
+ If the Python executable or Python header (if required)
+ is not found, the test is skipped.
+
+ Returns a tuple:
(path to python, include path, library path, library name)
"""
python = os.environ.get('python_executable', self.where_is('python'))
if not python:
self.skip_test('Can not find installed "python", skipping test.\n')
+ # construct a program to run in the intended environment
+ # in order to fetch the characteristics of that Python.
+ # Windows Python doesn't store all the info in config vars.
if sys.platform == 'win32':
self.run(program=python, stdin="""\
import sysconfig, sys, os.path
@@ -1279,28 +1286,44 @@ except AttributeError:
try:
import distutils.sysconfig
exec_prefix = distutils.sysconfig.EXEC_PREFIX
- print(distutils.sysconfig.get_python_inc())
+ include = distutils.sysconfig.get_python_inc()
+ print(include)
lib_path = os.path.join(exec_prefix, 'libs')
if not os.path.exists(lib_path):
lib_path = os.path.join(exec_prefix, 'lib')
print(lib_path)
except:
- print(os.path.join(sys.prefix, 'include', py_ver))
+ include = os.path.join(sys.prefix, 'include', py_ver)
+ print(include)
print(os.path.join(sys.prefix, 'lib', py_ver, 'config'))
print(py_ver)
- """)
+Python_h = os.path.join(include, "Python.h")
+if os.path.exists(Python_h):
+ print(Python_h)
+else:
+ print("False")
+""")
else:
self.run(program=python, stdin="""\
-import sys, sysconfig
-print(sysconfig.get_config_var("INCLUDEPY"))
+import sys, sysconfig, os.path
+include = sysconfig.get_config_var("INCLUDEPY")
+print(include)
print(sysconfig.get_config_var("LIBDIR"))
py_library_ver = sysconfig.get_config_var("LDVERSION")
if not py_library_ver:
py_library_ver = '%d.%d' % sys.version_info[:2]
print("python"+py_library_ver)
+Python_h = os.path.join(include, "Python.h")
+if os.path.exists(Python_h):
+ print(Python_h)
+else:
+ print("False")
""")
+ incpath, libpath, libname, python_h = self.stdout().strip().split('\n')
+ if python_h == "False" and python_h_required:
+ self.skip_test('Can not find required "Python.h", skipping test.\n')
- return [python] + self.stdout().strip().split('\n')
+ return (python, incpath, libpath, libname)
def start(self, *args, **kw):
"""