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.
pull/7021/head
Jon Turney 5 years ago committed by Nirbheek Chauhan
parent 79b2eeb1ba
commit 88e13c5f7c
  1. 2
      run_cross_test.py
  2. 3
      run_project_tests.py
  3. 2
      run_unittests.py
  4. 0
      test cases/cmake/211 cmake module/cmake_project/CMakeLists.txt
  5. 0
      test cases/cmake/211 cmake module/meson.build
  6. 0
      test cases/cmake/211 cmake module/projectConfig.cmake.in
  7. 0
      test cases/cmake/211 cmake module/test.json
  8. 5
      test cases/common/1 trivial/meson.build
  9. 17
      test cases/common/21 global arg/meson.build
  10. 6
      test cases/common/56 install script/meson.build
  11. 2
      test cases/common/56 install script/src/meson.build
  12. 5
      test cases/common/56 install script/test.json
  13. 3
      test cases/common/85 add language/meson.build
  14. 9
      test cases/native/1 trivial/meson.build
  15. 6
      test cases/native/1 trivial/trivial.c
  16. 0
      test cases/native/162 external program shebang parsing/input.txt
  17. 0
      test cases/native/162 external program shebang parsing/main.c
  18. 0
      test cases/native/162 external program shebang parsing/meson.build
  19. 0
      test cases/native/162 external program shebang parsing/script.int.in
  20. 0
      test cases/native/201 override with exe/main2.input
  21. 0
      test cases/native/201 override with exe/meson.build
  22. 0
      test cases/native/201 override with exe/subprojects/sub/foobar.c
  23. 0
      test cases/native/201 override with exe/subprojects/sub/meson.build
  24. 14
      test cases/native/21 global arg/meson.build
  25. 43
      test cases/native/21 global arg/prog.c
  26. 15
      test cases/native/21 global arg/prog.cc
  27. 0
      test cases/native/27 pipeline/depends/copyrunner.py
  28. 0
      test cases/native/27 pipeline/depends/filecopier.c
  29. 0
      test cases/native/27 pipeline/depends/libsrc.c.in
  30. 0
      test cases/native/27 pipeline/depends/meson.build
  31. 0
      test cases/native/27 pipeline/depends/prog.c
  32. 0
      test cases/native/27 pipeline/input_src.dat
  33. 0
      test cases/native/27 pipeline/meson.build
  34. 0
      test cases/native/27 pipeline/prog.c
  35. 0
      test cases/native/27 pipeline/src/input_src.dat
  36. 0
      test cases/native/27 pipeline/src/meson.build
  37. 0
      test cases/native/27 pipeline/src/prog.c
  38. 0
      test cases/native/27 pipeline/src/srcgen.c
  39. 0
      test cases/native/27 pipeline/srcgen.c
  40. 0
      test cases/native/36 tryrun/error.c
  41. 0
      test cases/native/36 tryrun/meson.build
  42. 0
      test cases/native/36 tryrun/no_compile.c
  43. 0
      test cases/native/36 tryrun/ok.c
  44. 0
      test cases/native/56 install script/file.txt
  45. 12
      test cases/native/56 install script/meson.build
  46. 3
      test cases/native/56 install script/src/exe.c
  47. 1
      test cases/native/56 install script/src/meson.build
  48. 8
      test cases/native/56 install script/test.json
  49. 0
      test cases/native/56 install script/wrap.py
  50. 3
      test cases/native/85 add language/meson.build
  51. 6
      test cases/native/85 add language/prog.cc
  52. 0
      test cases/native/93 selfbuilt custom/checkarg.cpp
  53. 0
      test cases/native/93 selfbuilt custom/data.dat
  54. 0
      test cases/native/93 selfbuilt custom/mainprog.cpp
  55. 0
      test cases/native/93 selfbuilt custom/meson.build
  56. 0
      test cases/native/93 selfbuilt custom/tool.cpp

@ -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)

@ -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'),

@ -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:

@ -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

@ -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)

@ -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')

@ -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)

@ -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"}
]
}

@ -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)

@ -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

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

@ -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)

@ -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;
}

@ -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;
}

@ -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')

@ -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);

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

@ -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"}
]
}

@ -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))

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