Split tests out from 'common' which require a native compiler

Split out tests (and parts of tests) which require a native compiler
from the 'common' suite to a new suite called 'native', so we can
selectively avoid running those tests when only a cross-compiler is
available.

Also move test '211 cmake module' to 'cmake' suite, since it appears
that the way we use cmake requires a native compiler.
This commit is contained in:
Jon Turney 2020-01-23 15:23:13 +00:00 committed by Nirbheek Chauhan
parent 79b2eeb1ba
commit 88e13c5f7c
56 changed files with 131 additions and 34 deletions

View File

@ -26,7 +26,7 @@ from mesonbuild.coredata import version as meson_version
def runtests(cross_file, failfast):
tests = ['--only', 'common']
tests = ['--only', 'common', 'native']
cmd = mesonlib.python_command + ['run_project_tests.py', '--backend', 'ninja'] + (['--failfast'] if failfast else []) + tests + ['--cross-file', cross_file]
return subprocess.call(cmd)

View File

@ -50,7 +50,7 @@ from run_tests import get_backend_commands, get_backend_args_for_dir, Backend
from run_tests import ensure_backend_detects_changes
from run_tests import guess_backend
ALL_TESTS = ['cmake', 'common', 'warning-meson', 'failing-meson', 'failing-build', 'failing-test',
ALL_TESTS = ['cmake', 'common', 'native', 'warning-meson', 'failing-meson', 'failing-build', 'failing-test',
'keyval', 'platform-osx', 'platform-windows', 'platform-linux',
'java', 'C#', 'vala', 'rust', 'd', 'objective c', 'objective c++',
'fortran', 'swift', 'cuda', 'python3', 'python', 'fpga', 'frameworks', 'nasm', 'wasm'
@ -961,6 +961,7 @@ def detect_tests_to_run(only: T.List[str], use_tmp: bool) -> T.List[T.Tuple[str,
all_tests = [
TestCategory('cmake', 'cmake', not shutil.which('cmake') or (os.environ.get('compiler') == 'msvc2015' and under_ci)),
TestCategory('common', 'common'),
TestCategory('native', 'native'),
TestCategory('warning-meson', 'warning', stdout_mandatory=True),
TestCategory('failing-meson', 'failing', stdout_mandatory=True),
TestCategory('failing-build', 'failing build'),

View File

@ -6928,7 +6928,7 @@ class LinuxlikeTests(BasePlatformTests):
'''
Test that we produce the correct dependencies when a program is overridden with an executable.
'''
testdir = os.path.join(self.common_test_dir, '201 override with exe')
testdir = os.path.join(self.src_root, 'test cases', 'native', '201 override with exe')
self.init(testdir)
with open(os.path.join(self.builddir, 'build.ninja')) as bfile:
for line in bfile:

View File

@ -14,11 +14,6 @@ elif cc.get_id() == 'intel-cl'
add_project_arguments('/Qdiag-error:10159', language : 'c')
endif
if meson.is_cross_build()
native_exe = executable('native-trivialprog', sources : sources, native : true)
test('native exe in cross build', native_exe)
endif
exe = executable('trivialprog', sources : sources)
assert(exe.name() == 'trivialprog')
test('runtest', exe) # This is a comment

View File

@ -1,23 +1,16 @@
project('global arg test', 'cpp', 'c')
add_global_arguments('-DMYTHING', language : 'c', native : true)
add_global_arguments('-DMYTHING', language : 'c', native : false)
add_global_arguments('-DMYCPPTHING', language : 'cpp', native : true)
add_global_arguments('-DMYCPPTHING', language : 'cpp', native : false)
add_global_arguments('-DGLOBAL_BUILD', language : 'c', native : true)
add_global_arguments('-DGLOBAL_HOST', language : 'c', native : false)
add_global_arguments('-DMYTHING', language : 'c')
add_global_arguments('-DMYCPPTHING', language : 'cpp')
add_global_arguments('-DGLOBAL_HOST', language : 'c')
build_c_args = ['-DARG_BUILD']
c_args = ['-DARG_HOST']
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'], native: true)
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'], native: false)
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'])
exe1 = executable('prog1', 'prog.c', c_args : build_c_args, native : true)
exe2 = executable('prog2', 'prog.c', c_args : c_args, native : false)
exe2 = executable('prog2', 'prog.c', c_args : c_args)
exe3 = executable('prog3', 'prog.cc')
test('prog1', exe1)
test('prog2', exe2)
test('prog3', exe3)

View File

@ -25,9 +25,3 @@ t = custom_target(
meson.add_install_script('myinstall.py', 'customtarget', t, '--mode=copy')
meson.add_install_script('myinstall.py', 'customtargetindex', t[0], '--mode=copy')
meson.add_install_script(exe, 'generated.txt')
wrap = find_program('wrap.py')
# Yes, these are getting silly
meson.add_install_script(wrap, exe, 'wrapped.txt')
meson.add_install_script(wrap, wrap, exe, 'wrapped2.txt')

View File

@ -1,5 +1,3 @@
meson.add_install_script('myinstall.py', 'this/does', 'something-different.dat')
afile = files('a file.txt')
exe = executable('exe', 'exe.c', install : false, native : true)

View File

@ -9,9 +9,6 @@
{"type": "file", "file": "usr/dir/conf.txt"},
{"type": "file", "file": "usr/customtarget/1.txt"},
{"type": "file", "file": "usr/customtarget/2.txt"},
{"type": "file", "file": "usr/customtargetindex/1.txt"},
{"type": "file", "file": "usr/generated.txt"},
{"type": "file", "file": "usr/wrapped.txt"},
{"type": "file", "file": "usr/wrapped2.txt"}
{"type": "file", "file": "usr/customtargetindex/1.txt"}
]
}

View File

@ -2,10 +2,9 @@ project('add language', 'c')
test('C', executable('cprog', 'prog.c'))
assert(add_languages('cpp'), 'Add_languages returned false on success')
assert(add_languages('cpp', native: false), 'Add_languages returned false on success')
assert(not add_languages('klingon', required : false), 'Add_languages returned true on failure.')
test('C++', executable('cppprog', 'prog.cc'))
add_languages('c', native: true)
add_languages('c', native: false)

View File

@ -0,0 +1,9 @@
project('trivial native test', 'c')
sources = 'trivial.c'
cc = meson.get_compiler('c', native: true)
if meson.is_cross_build()
native_exe = executable('native-trivialprog', sources : sources, native : true)
test('native exe in cross build', native_exe)
endif

View File

@ -0,0 +1,6 @@
#include<stdio.h>
int main(void) {
printf("Trivial test is working.\n");
return 0;
}

View File

@ -0,0 +1,14 @@
project('global arg test', 'cpp', 'c')
add_global_arguments('-DMYTHING', language : 'c', native : true)
add_global_arguments('-DMYCPPTHING', language : 'cpp', native : true)
add_global_arguments('-DGLOBAL_BUILD', language : 'c', native : true)
build_c_args = ['-DARG_BUILD']
c_args = ['-DARG_HOST']
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'], native: true)
exe1 = executable('prog1', 'prog.c', c_args : build_c_args, native : true)
test('prog1', exe1)

View File

@ -0,0 +1,43 @@
#ifndef MYTHING
#error "Global argument not set"
#endif
#ifdef MYCPPTHING
#error "Wrong global argument set"
#endif
#ifndef MYCANDCPPTHING
#error "Global argument not set"
#endif
#if !defined(GLOBAL_HOST) && !defined(GLOBAL_BUILD)
#error "Neither global_host nor glogal_build is set."
#endif
#if defined(GLOBAL_HOST) && defined(GLOBAL_BUILD)
#error "Both global build and global host set."
#endif
#ifdef GLOBAL_BUILD
#ifndef ARG_BUILD
#error "Global is build but arg_build is not set."
#endif
#ifdef ARG_HOST
#error "Global is build but arg host is set."
#endif
#endif
#ifdef GLOBAL_HOST
#ifndef ARG_HOST
#error "Global is host but arg_host is not set."
#endif
#ifdef ARG_BUILD
#error "Global is host but arg_build is set."
#endif
#endif
int main(void) {
return 0;
}

View File

@ -0,0 +1,15 @@
#ifdef MYTHING
#error "Wrong global argument set"
#endif
#ifndef MYCPPTHING
#error "Global argument not set"
#endif
#ifndef MYCANDCPPTHING
#error "Global argument not set"
#endif
int main(void) {
return 0;
}

View File

@ -0,0 +1,12 @@
project('custom install script', 'c')
# this is just to ensure that the install directory exists before exe is run
install_data('file.txt', install_dir: '.')
subdir('src')
meson.add_install_script(exe, 'generated.txt')
wrap = find_program('wrap.py')
# Yes, these are getting silly
meson.add_install_script(wrap, exe, 'wrapped.txt')
meson.add_install_script(wrap, wrap, exe, 'wrapped2.txt')

View File

@ -15,6 +15,9 @@ int main(int argc, char * argv[]) {
strcat(fullname, argv[1]);
FILE * fp = fopen(fullname, "w");
if (!fp)
return 1;
fputs("Some text\n", fp);
fclose(fp);

View File

@ -0,0 +1 @@
exe = executable('exe', 'exe.c', install : false, native : true)

View File

@ -0,0 +1,8 @@
{
"installed": [
{"type": "file", "file": "usr/file.txt"},
{"type": "file", "file": "usr/generated.txt"},
{"type": "file", "file": "usr/wrapped.txt"},
{"type": "file", "file": "usr/wrapped2.txt"}
]
}

View File

@ -0,0 +1,3 @@
project('add language', 'c')
assert(add_languages('cpp', native: true), 'Add_languages returned false on success')
test('C++', executable('cppprog', 'prog.cc', native: true))

View File

@ -0,0 +1,6 @@
#include<iostream>
int main(int, char**) {
std::cout << "I am C++.\n";
return 0;
}