aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-02-23 15:11:18 -0500
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-02-26 15:42:17 +0000
commit9cf0f31ec0c637374d00b9a97e9c8dcdf1ad78a2 (patch)
treee1689e700832614f19b5dfc2e9ac10fd80802ce6
parent92f95b3326579944ebfe6b49ee7ffd1e57400601 (diff)
downloadmeson-9cf0f31ec0c637374d00b9a97e9c8dcdf1ad78a2.zip
meson-9cf0f31ec0c637374d00b9a97e9c8dcdf1ad78a2.tar.gz
meson-9cf0f31ec0c637374d00b9a97e9c8dcdf1ad78a2.tar.bz2
unit tests: Use unittest.skipUnless to simplify main()
This makes the testsuite work better with other test runners, like pytest. This is important because better test runners are very useful to development (e.g. avoiding running succeeding tests again and again), even if we want to still support 0 dependency testing of Meson though keeping the default test runnner working.
-rwxr-xr-xrun_unittests.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/run_unittests.py b/run_unittests.py
index fbd51df..fee8077 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3747,6 +3747,7 @@ class FailureTests(BasePlatformTests):
"""Subproject "subprojects/not-found-subproject" disabled can't get_variable on it.""")
+@unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)")
class WindowsTests(BasePlatformTests):
'''
Tests that should run on Cygwin, MinGW, and MSVC
@@ -3857,6 +3858,7 @@ class WindowsTests(BasePlatformTests):
return
self.build()
+@unittest.skipUnless(is_osx(), "requires Darwin")
class DarwinTests(BasePlatformTests):
'''
Tests that should run on macOS
@@ -3953,6 +3955,7 @@ class DarwinTests(BasePlatformTests):
del os.environ["LDFLAGS"]
+@unittest.skipUnless(not is_windows(), "requires something Unix-like")
class LinuxlikeTests(BasePlatformTests):
'''
Tests that should run on Linux, macOS, and *BSD
@@ -4931,6 +4934,10 @@ endian = 'little'
self.assertEqual(max_count, 1, 'Export dynamic incorrectly deduplicated.')
+def should_run_cross_arm_tests():
+ return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm')
+
+@unittest.skipUnless(not is_windows() and should_run_cross_arm_tests(), "requires ability to cross compile to ARM")
class LinuxCrossArmTests(BasePlatformTests):
'''
Tests that cross-compilation to Linux/ARM works
@@ -4979,6 +4986,10 @@ class LinuxCrossArmTests(BasePlatformTests):
self.assertTrue(False, 'Option libdir not in introspect data.')
+def should_run_cross_mingw_tests():
+ return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin())
+
+@unittest.skipUnless(not is_windows() and should_run_cross_mingw_tests(), "requires ability to cross compile with MinGW")
class LinuxCrossMingwTests(BasePlatformTests):
'''
Tests that cross-compilation to Windows/MinGW works
@@ -5655,26 +5666,12 @@ def unset_envs():
if v in os.environ:
del os.environ[v]
-def should_run_cross_arm_tests():
- return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm')
-
-def should_run_cross_mingw_tests():
- return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin())
-
def main():
unset_envs()
cases = ['InternalTests', 'DataTests', 'AllPlatformTests', 'FailureTests',
- 'PythonTests', 'NativeFileTests', 'RewriterTests', 'CrossFileTests']
- if not is_windows():
- cases += ['LinuxlikeTests']
- if should_run_cross_arm_tests():
- cases += ['LinuxCrossArmTests']
- if should_run_cross_mingw_tests():
- cases += ['LinuxCrossMingwTests']
- if is_windows() or is_cygwin():
- cases += ['WindowsTests']
- if is_osx():
- cases += ['DarwinTests']
+ 'PythonTests', 'NativeFileTests', 'RewriterTests', 'CrossFileTests',
+ 'LinuxlikeTests', 'LinuxCrossArmTests', 'LinuxCrossMingwTests',
+ 'WindowsTests', 'DarwinTests']
return unittest.main(defaultTest=cases, buffer=True)