aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-12-03 22:48:56 +0200
committerGitHub <noreply@github.com>2017-12-03 22:48:56 +0200
commitcf76ffad145eb83a0bbfce89e05b7610637ff293 (patch)
tree9d76dd2d2f2398fbca00bdfad434297246338213 /run_unittests.py
parent2cf1e8da15b954725fa9c9467bfb35a516814c89 (diff)
parentbccb7a8eb8f13fc747f5198ee0d77ecaf1b77be7 (diff)
downloadmeson-cf76ffad145eb83a0bbfce89e05b7610637ff293.zip
meson-cf76ffad145eb83a0bbfce89e05b7610637ff293.tar.gz
meson-cf76ffad145eb83a0bbfce89e05b7610637ff293.tar.bz2
Merge pull request #2703 from mesonbuild/msvc-library-search-fixes
Various MSVC library search fixes
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/run_unittests.py b/run_unittests.py
index f378d70..8c61111 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -40,7 +40,7 @@ from mesonbuild.environment import Environment
from mesonbuild.dependencies import DependencyException
from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
-from run_tests import exe_suffix, get_fake_options, FakeEnvironment
+from run_tests import exe_suffix, get_fake_options
from run_tests import get_builddir_target_args, get_backend_commands, Backend
from run_tests import ensure_backend_detects_changes, run_configure, meson_exe
from run_tests import should_run_linux_cross_tests
@@ -1061,16 +1061,17 @@ class AllPlatformTests(BasePlatformTests):
evalue = os.environ.pop(evar)
# Very rough/strict heuristics. Would never work for actual
# compiler detection, but should be ok for the tests.
- if os.path.basename(evalue).startswith('g'):
+ ebase = os.path.basename(evalue)
+ if ebase.startswith('g') or ebase.endswith(('-gcc', '-g++')):
self.assertIsInstance(ecc, gnu)
self.assertIsInstance(elinker, ar)
- elif 'clang' in os.path.basename(evalue):
+ elif 'clang' in ebase:
self.assertIsInstance(ecc, clang)
self.assertIsInstance(elinker, ar)
- elif os.path.basename(evalue).startswith('ic'):
+ elif ebase.startswith('ic'):
self.assertIsInstance(ecc, intel)
self.assertIsInstance(elinker, ar)
- elif os.path.basename(evalue).startswith('cl'):
+ elif ebase.startswith('cl'):
self.assertIsInstance(ecc, msvc)
self.assertIsInstance(elinker, lib)
else:
@@ -1398,6 +1399,7 @@ int main(int argc, char **argv) {
env = Environment('', self.builddir, self.meson_command,
get_fake_options(self.prefix), [])
cc = env.detect_c_compiler(False)
+ stlinker = env.detect_static_linker(cc)
if mesonbuild.mesonlib.is_windows():
object_suffix = 'obj'
shared_suffix = 'dll'
@@ -1410,7 +1412,7 @@ int main(int argc, char **argv) {
else:
object_suffix = 'o'
shared_suffix = 'so'
- return (cc, object_suffix, shared_suffix)
+ return (cc, stlinker, object_suffix, shared_suffix)
def pbcompile(self, compiler, source, objectfile, extra_args=[]):
cmd = compiler.get_exelist()
@@ -1422,7 +1424,7 @@ int main(int argc, char **argv) {
def test_prebuilt_object(self):
- (compiler, object_suffix, _) = self.detect_prebuild_env()
+ (compiler, _, object_suffix, _) = self.detect_prebuild_env()
tdir = os.path.join(self.unit_test_dir, '14 prebuilt object')
source = os.path.join(tdir, 'source.c')
objectfile = os.path.join(tdir, 'prebuilt.' + object_suffix)
@@ -1434,13 +1436,18 @@ int main(int argc, char **argv) {
finally:
os.unlink(objectfile)
- def build_static_lib(self, compiler, source, objectfile, outfile, extra_args=None):
+ def build_static_lib(self, compiler, linker, source, objectfile, outfile, extra_args=None):
if extra_args is None:
extra_args = []
if compiler.id == 'msvc':
link_cmd = ['lib', '/NOLOGO', '/OUT:' + outfile, objectfile]
else:
link_cmd = ['ar', 'csr', outfile, objectfile]
+ link_cmd = linker.get_exelist()
+ link_cmd += linker.get_always_args()
+ link_cmd += linker.get_std_link_args()
+ link_cmd += linker.get_output_args(outfile)
+ link_cmd += [objectfile]
self.pbcompile(compiler, source, objectfile, extra_args=extra_args)
try:
subprocess.check_call(link_cmd)
@@ -1448,12 +1455,12 @@ int main(int argc, char **argv) {
os.unlink(objectfile)
def test_prebuilt_static_lib(self):
- (cc, object_suffix, _) = self.detect_prebuild_env()
+ (cc, stlinker, object_suffix, _) = self.detect_prebuild_env()
tdir = os.path.join(self.unit_test_dir, '15 prebuilt static')
source = os.path.join(tdir, 'libdir/best.c')
objectfile = os.path.join(tdir, 'libdir/best.' + object_suffix)
stlibfile = os.path.join(tdir, 'libdir/libbest.a')
- self.build_static_lib(cc, source, objectfile, stlibfile)
+ self.build_static_lib(cc, stlinker, source, objectfile, stlibfile)
# Run the test
try:
self.init(tdir)
@@ -1480,7 +1487,7 @@ int main(int argc, char **argv) {
os.unlink(objectfile)
def test_prebuilt_shared_lib(self):
- (cc, object_suffix, shared_suffix) = self.detect_prebuild_env()
+ (cc, _, object_suffix, shared_suffix) = self.detect_prebuild_env()
tdir = os.path.join(self.unit_test_dir, '16 prebuilt shared')
source = os.path.join(tdir, 'alexandria.c')
objectfile = os.path.join(tdir, 'alexandria.' + object_suffix)
@@ -1514,7 +1521,7 @@ int main(int argc, char **argv) {
'''
if not shutil.which('pkg-config'):
raise unittest.SkipTest('pkg-config not found')
- (cc, objext, shext) = self.detect_prebuild_env()
+ (cc, stlinker, objext, shext) = self.detect_prebuild_env()
testdir = os.path.join(self.unit_test_dir, '17 pkgconfig static')
source = os.path.join(testdir, 'foo.c')
objectfile = os.path.join(testdir, 'foo.' + objext)
@@ -1527,7 +1534,7 @@ int main(int argc, char **argv) {
else:
shlibfile = os.path.join(testdir, 'libfoo.' + shext)
# Build libs
- self.build_static_lib(cc, source, objectfile, stlibfile, extra_args=['-DFOO_STATIC'])
+ self.build_static_lib(cc, stlinker, source, objectfile, stlibfile, extra_args=['-DFOO_STATIC'])
self.build_shared_lib(cc, source, objectfile, shlibfile, impfile)
# Run test
os.environ['PKG_CONFIG_LIBDIR'] = self.builddir
@@ -1555,7 +1562,8 @@ int main(int argc, char **argv) {
'--libdir=' + libdir])
# Find foo dependency
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
- env = FakeEnvironment()
+ env = Environment(testdir, self.builddir, self.meson_command,
+ get_fake_options(self.prefix), [])
kwargs = {'required': True, 'silent': True}
foo_dep = PkgConfigDependency('libfoo', env, kwargs)
# Ensure link_args are properly quoted
@@ -1875,7 +1883,8 @@ class LinuxlikeTests(BasePlatformTests):
'''
testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen')
self.init(testdir)
- env = FakeEnvironment()
+ env = Environment(testdir, self.builddir, self.meson_command,
+ get_fake_options(self.prefix), [])
kwargs = {'required': True, 'silent': True}
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
foo_dep = PkgConfigDependency('libfoo', env, kwargs)
@@ -2259,8 +2268,9 @@ class LinuxlikeTests(BasePlatformTests):
raise unittest.SkipTest('gcovr not found')
if not shutil.which('genhtml'):
raise unittest.SkipTest('genhtml not found')
- if 'clang' in os.environ.get('CC', '') and os.environ.get('TRAVIS_OS_NAME', '') == 'linux':
- raise unittest.SkipTest('Gcovr has a bug and does not work with Clang in the CI environment.')
+ if 'clang' in os.environ.get('CC', ''):
+ # We need to use llvm-cov instead of gcovr with clang
+ raise unittest.SkipTest('Coverage does not work with clang right now, help wanted!')
testdir = os.path.join(self.common_test_dir, '1 trivial')
self.init(testdir, ['-Db_coverage=true'])
self.build()