diff options
author | Niklas Claesson <nicke.claesson@gmail.com> | 2018-10-10 21:17:24 +0200 |
---|---|---|
committer | Niklas Claesson <nicke.claesson@gmail.com> | 2018-10-10 21:19:06 +0200 |
commit | 4ef4edee2f460a354cca0c381d08604f6837c496 (patch) | |
tree | 1eb5308b3beb94e1e2d4e7416fe9ce9a6f1acc8d /run_meson_command_tests.py | |
parent | a0a0c244e2a062ceba357f05d4852cd063f0b0cd (diff) | |
download | meson-4ef4edee2f460a354cca0c381d08604f6837c496.zip meson-4ef4edee2f460a354cca0c381d08604f6837c496.tar.gz meson-4ef4edee2f460a354cca0c381d08604f6837c496.tar.bz2 |
tests runners: Refactor out global variables and add argparse
Diffstat (limited to 'run_meson_command_tests.py')
-rwxr-xr-x | run_meson_command_tests.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py index fd33856..390868a 100755 --- a/run_meson_command_tests.py +++ b/run_meson_command_tests.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys import os import tempfile import unittest @@ -23,11 +24,6 @@ from pathlib import Path from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows -# Find the meson.py adjacent to us -meson_py = Path(__file__).resolve().parent / 'meson.py' -if not meson_py.is_file(): - raise RuntimeError("meson.py not found: test must only run from git") - def get_pypath(): import sysconfig pypath = sysconfig.get_path('purelib', vars={'base': ''}) @@ -176,8 +172,7 @@ class CommandTests(unittest.TestCase): builddir = str(self.tmpdir / 'build4') (bindir / 'meson').rename(bindir / 'meson.real') wrapper = (bindir / 'meson') - with open(str(wrapper), 'w') as f: - f.write('#!/bin/sh\n\nmeson.real "$@"') + wrapper.open('w').write('#!/bin/sh\n\nmeson.real "$@"') wrapper.chmod(0o755) meson_setup = [str(wrapper), 'setup'] meson_command = meson_setup + self.meson_args @@ -195,5 +190,6 @@ class CommandTests(unittest.TestCase): zipapp.create_archive(source=source, target=target, interpreter=python_command[0], main=None) self._run([target.as_posix(), '--help']) + if __name__ == '__main__': - unittest.main(buffer=True) + sys.exit(unittest.main(buffer=True)) |