Make the full test suite runnable with an external command.

pull/2498/head
Jussi Pakkanen 7 years ago
parent 5d51bc79c7
commit 105ea1e597
  1. 86
      mesonbuild/mesonmain.py
  2. 21
      run_project_tests.py
  3. 5
      run_unittests.py

@ -23,12 +23,9 @@ from . import mlog, coredata
from .mesonlib import MesonException
from .wrap import WrapMode, wraptool
parser = argparse.ArgumentParser(prog='meson')
default_warning = '1'
def add_builtin_argument(name, **kwargs):
def add_builtin_argument(p, name, **kwargs):
k = kwargs.get('dest', name.replace('-', '_'))
c = coredata.get_builtin_option_choices(k)
b = True if kwargs.get('action', None) in ['store_true', 'store_false'] else False
@ -42,31 +39,45 @@ def add_builtin_argument(name, **kwargs):
kwargs['default'] = default
else:
kwargs['default'] = argparse.SUPPRESS
parser.add_argument('--' + name, help=h, **kwargs)
p.add_argument('--' + name, help=h, **kwargs)
add_builtin_argument('prefix')
add_builtin_argument('libdir')
add_builtin_argument('libexecdir')
add_builtin_argument('bindir')
add_builtin_argument('sbindir')
add_builtin_argument('includedir')
add_builtin_argument('datadir')
add_builtin_argument('mandir')
add_builtin_argument('infodir')
add_builtin_argument('localedir')
add_builtin_argument('sysconfdir')
add_builtin_argument('localstatedir')
add_builtin_argument('sharedstatedir')
add_builtin_argument('backend')
add_builtin_argument('buildtype')
add_builtin_argument('strip', action='store_true')
add_builtin_argument('unity')
add_builtin_argument('werror', action='store_true')
add_builtin_argument('layout')
add_builtin_argument('default-library')
add_builtin_argument('warnlevel', dest='warning_level')
add_builtin_argument('stdsplit', action='store_false')
add_builtin_argument('errorlogs', action='store_false')
def create_parser():
p = argparse.ArgumentParser(prog='meson')
add_builtin_argument(p, 'prefix')
add_builtin_argument(p, 'libdir')
add_builtin_argument(p, 'libexecdir')
add_builtin_argument(p, 'bindir')
add_builtin_argument(p, 'sbindir')
add_builtin_argument(p, 'includedir')
add_builtin_argument(p, 'datadir')
add_builtin_argument(p, 'mandir')
add_builtin_argument(p, 'infodir')
add_builtin_argument(p, 'localedir')
add_builtin_argument(p, 'sysconfdir')
add_builtin_argument(p, 'localstatedir')
add_builtin_argument(p, 'sharedstatedir')
add_builtin_argument(p, 'backend')
add_builtin_argument(p, 'buildtype')
add_builtin_argument(p, 'strip', action='store_true')
add_builtin_argument(p, 'unity')
add_builtin_argument(p, 'werror', action='store_true')
add_builtin_argument(p, 'layout')
add_builtin_argument(p, 'default-library')
add_builtin_argument(p, 'warnlevel', dest='warning_level')
add_builtin_argument(p, 'stdsplit', action='store_false')
add_builtin_argument(p, 'errorlogs', action='store_false')
p.add_argument('--cross-file', default=None,
help='File describing cross compilation environment.')
p.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option",
help='Set the value of an option, can be used several times to set multiple options.')
p.add_argument('-v', '--version', action='version',
version=coredata.version)
# See the mesonlib.WrapMode enum for documentation
p.add_argument('--wrap-mode', default=WrapMode.default,
type=wrapmodetype, choices=WrapMode,
help='Special wrap mode to use')
p.add_argument('directories', nargs='*')
return p
def wrapmodetype(string):
try:
@ -76,18 +87,6 @@ def wrapmodetype(string):
msg = 'invalid argument {!r}, use one of {}'.format(string, msg)
raise argparse.ArgumentTypeError(msg)
parser.add_argument('--cross-file', default=None,
help='File describing cross compilation environment.')
parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option",
help='Set the value of an option, can be used several times to set multiple options.')
parser.add_argument('-v', '--version', action='version',
version=coredata.version)
# See the mesonlib.WrapMode enum for documentation
parser.add_argument('--wrap-mode', default=WrapMode.default,
type=wrapmodetype, choices=WrapMode,
help='Special wrap mode to use')
parser.add_argument('directories', nargs='*')
class MesonApp:
def __init__(self, dir1, dir2, script_launcher, handshake, options, original_cmd_line_args):
@ -278,12 +277,13 @@ def run_script_command(args):
raise MesonException('Unknown internal command {}.'.format(cmdname))
return cmdfunc(cmdargs)
def run(args, mainfile=None):
def run(original_args, mainfile=None):
if sys.version_info < (3, 4):
print('Meson works correctly only with python 3.4+.')
print('You have python %s.' % sys.version)
print('Please update your environment')
return 1
args = original_args[:]
if len(args) > 0:
# First check if we want to run a subcommand.
cmd_name = args[0]
@ -325,6 +325,8 @@ def run(args, mainfile=None):
else:
handshake = False
parser = create_parser()
args = mesonlib.expand_arguments(args)
options = parser.parse_args(args)
args = options.directories
@ -348,7 +350,7 @@ def run(args, mainfile=None):
try:
if mainfile is None:
raise AssertionError('I iz broken. Sorry.')
app = MesonApp(dir1, dir2, mainfile, handshake, options, sys.argv)
app = MesonApp(dir1, dir2, mainfile, handshake, options, original_args)
except Exception as e:
# Log directory does not exist, so just print
# to stdout.

@ -322,13 +322,30 @@ def run_test(skipped, testdir, extra_args, compiler, backend, flags, commands, s
finally:
mlog.shutdown() # Close the log file because otherwise Windows wets itself.
def pass_prefix_to_test(dirname):
if '40 prefix' in dirname:
return False
return True
def pass_libdir_to_test(dirname):
if '8 install' in dirname:
return False
if '39 libdir' in dirname:
return False
return True
def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backend, flags, commands, should_fail):
compile_commands, clean_commands, install_commands, uninstall_commands = commands
test_args = parse_test_args(testdir)
gen_start = time.time()
# Configure in-process
gen_args = ['--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\
+ flags + test_args + extra_args
if pass_prefix_to_test(testdir):
gen_args = ['--prefix', '/usr']
else:
gen_args = []
if pass_libdir_to_test(testdir):
gen_args += ['--libdir', 'lib']
gen_args += [testdir, test_build_dir] + flags + test_args + extra_args
(returncode, stdo, stde) = run_configure(meson_command, gen_args)
try:
logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt')

@ -41,7 +41,7 @@ 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
from run_tests import ensure_backend_detects_changes, run_configure, meson_exe
from run_tests import should_run_linux_cross_tests
@ -1588,6 +1588,9 @@ class FailureTests(BasePlatformTests):
Assert that running meson configure on the specified @contents raises
a error message matching regex @match.
'''
if meson_exe is not None:
# Because the exception happens in a different process.
raise unittest.SkipTest('Can not test assert raise tests with an external Meson command.')
if langs is None:
langs = []
with open(self.mbuild, 'w') as f:

Loading…
Cancel
Save