Skip to content

Commit

Permalink
unit tests: Select test cases inside run_unittests.py
Browse files Browse the repository at this point in the history
This allows people to directly run ./run_unittests.py without having
to worry about selecting the right test cases for the platform they
are on.
  • Loading branch information
nirbheek authored and jpakkane committed Aug 13, 2017
1 parent 7aed29e commit 192d0dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 1 addition & 9 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,6 @@ def print_system_info():
# Run tests
print(mlog.bold('Running unittests.').get_text(mlog.colorize_console))
print()
units = ['InternalTests', 'AllPlatformTests', 'FailureTests']
if mesonlib.is_linux():
units += ['LinuxlikeTests']
if should_run_linux_cross_tests():
units += ['LinuxArmCrossCompileTests']
elif mesonlib.is_windows():
units += ['WindowsTests']
# Can't pass arguments to unit tests, so set the backend to use in the environment
env = os.environ.copy()
env['MESON_UNIT_TEST_BACKEND'] = backend.name
Expand All @@ -208,8 +201,7 @@ def print_system_info():
'coverage.process_startup()\n')
env['COVERAGE_PROCESS_START'] = '.coveragerc'
env['PYTHONPATH'] = os.pathsep.join([td] + env.get('PYTHONPATH', []))

returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env)
returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'], env=env)
# Ubuntu packages do not have a binary without -6 suffix.
if should_run_linux_cross_tests():
print(mlog.bold('Running cross compilation tests.').get_text(mlog.colorize_console))
Expand Down
13 changes: 11 additions & 2 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
import mesonbuild.compilers
import mesonbuild.environment
import mesonbuild.mesonlib
from mesonbuild.mesonlib import is_windows, is_osx, is_cygwin, windows_proof_rmtree
from mesonbuild.mesonlib import is_linux, is_windows, is_osx, is_cygwin, windows_proof_rmtree
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 get_builddir_target_args, get_backend_commands, Backend
from run_tests import ensure_backend_detects_changes, run_configure_inprocess
from run_tests import should_run_linux_cross_tests


def get_dynamic_section_entry(fname, entry):
Expand Down Expand Up @@ -1980,4 +1981,12 @@ def unset_envs():

if __name__ == '__main__':
unset_envs()
unittest.main(buffer=True)
cases = ['InternalTests', 'AllPlatformTests', 'FailureTests']
if is_linux():
cases += ['LinuxlikeTests']
if should_run_linux_cross_tests():
cases += ['LinuxArmCrossCompileTests']
elif is_windows():
cases += ['WindowsTests']

unittest.main(defaultTest=cases, buffer=True)

0 comments on commit 192d0dd

Please sign in to comment.