diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-04-06 06:56:55 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-04-09 23:08:42 +0530 |
commit | d755228afe40aff1a2550b161f34cab888d5b995 (patch) | |
tree | 99cf22135ef57890688648b9b7d57b88184a4849 /run_tests.py | |
parent | 4646958917c0a0924c989698c178f849c5c94635 (diff) | |
download | meson-d755228afe40aff1a2550b161f34cab888d5b995.zip meson-d755228afe40aff1a2550b161f34cab888d5b995.tar.gz meson-d755228afe40aff1a2550b161f34cab888d5b995.tar.bz2 |
tests: Factor out common code to run_tests
And use generic build/clean/test/install commands in the unit tests,
just like project tests. This sets the groundwork for running the unit
tests with all backends.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/run_tests.py b/run_tests.py index b444b9a..f86c890 100755 --- a/run_tests.py +++ b/run_tests.py @@ -20,10 +20,64 @@ import shutil import subprocess import platform from mesonbuild import mesonlib +from mesonbuild.environment import detect_ninja from enum import Enum Backend = Enum('Backend', 'ninja vs xcode') +if mesonlib.is_windows(): + exe_suffix = '.exe' +else: + exe_suffix = '' + +def get_build_target_args(backend, target): + if target is None: + return [] + if backend.startswith('vs'): + return ['/target:' + target] + if backend == 'xcode': + return ['-target', target] + return [target] + +def get_backend_commands(backend, debug=False): + install_cmd = [] + uninstall_cmd = [] + if backend.startswith('vs'): + cmd = ['msbuild'] + clean_cmd = [] + test_cmd = cmd + ['RUN_TESTS.vcxproj'] + elif backend == 'xcode': + cmd = ['xcodebuild'] + clean_cmd = cmd + ['-alltargets', 'clean'] + test_cmd = cmd + ['-target', 'RUN_TESTS'] + else: + # We need at least 1.6 because of -w dupbuild=err + cmd = [detect_ninja('1.6'), '-w', 'dupbuild=err'] + if cmd[0] is None: + raise RuntimeError('Could not find Ninja v1.6 or newer') + if debug: + cmd += ['-v'] + clean_cmd = cmd + ['clean'] + test_cmd = cmd + ['test', 'benchmark'] + install_cmd = cmd + ['install'] + uninstall_cmd = cmd + ['uninstall'] + return cmd, clean_cmd, test_cmd, install_cmd, uninstall_cmd + +def get_fake_options(prefix): + import argparse + opts = argparse.Namespace() + opts.cross_file = None + opts.wrap_mode = None + opts.prefix = prefix + return opts + +class FakeEnvironment(object): + def __init__(self): + self.cross_info = None + + def is_cross_build(self): + return False + if __name__ == '__main__': returncode = 0 # Iterate over list in reverse order to find the last --backend arg |