The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
79 lines
1.9 KiB
8 years ago
|
project('tryrun', 'c', 'cpp')
|
||
12 years ago
|
|
||
11 years ago
|
# Complex to exercise all code paths.
|
||
|
if meson.is_cross_build()
|
||
|
if meson.has_exe_wrapper()
|
||
8 years ago
|
compilers = [meson.get_compiler('c', native : false), meson.get_compiler('cpp', native : false)]
|
||
11 years ago
|
else
|
||
8 years ago
|
compilers = [meson.get_compiler('c', native : true), meson.get_compiler('cpp', native : true)]
|
||
11 years ago
|
endif
|
||
|
else
|
||
8 years ago
|
compilers = [meson.get_compiler('c'), meson.get_compiler('cpp')]
|
||
11 years ago
|
endif
|
||
12 years ago
|
|
||
|
ok_code = '''#include<stdio.h>
|
||
|
int main(int argc, char **argv) {
|
||
7 years ago
|
printf("%s\n", "stdout");
|
||
|
fprintf(stderr, "%s\n", "stderr");
|
||
12 years ago
|
return 0;
|
||
|
}
|
||
|
'''
|
||
|
|
||
|
error_code = '''int main(int argc, char **argv) {
|
||
|
return 1;
|
||
|
}
|
||
|
'''
|
||
|
|
||
|
no_compile_code = '''int main(int argc, char **argv) {
|
||
|
'''
|
||
|
|
||
8 years ago
|
INPUTS = [
|
||
|
['String', ok_code, error_code, no_compile_code],
|
||
|
['File', files('ok.c'), files('error.c'), files('no_compile.c')],
|
||
|
]
|
||
12 years ago
|
|
||
8 years ago
|
foreach cc : compilers
|
||
|
foreach input : INPUTS
|
||
|
type = input[0]
|
||
|
ok = cc.run(input[1], name : type + ' should succeed')
|
||
|
err = cc.run(input[2], name : type + ' should fail')
|
||
|
noc = cc.run(input[3], name : type + ' does not compile')
|
||
12 years ago
|
|
||
8 years ago
|
if noc.compiled()
|
||
|
error(type + ' compilation fail test failed.')
|
||
|
else
|
||
|
message(type + ' fail detected properly.')
|
||
|
endif
|
||
12 years ago
|
|
||
8 years ago
|
if ok.compiled()
|
||
|
message(type + ' compilation worked.')
|
||
|
else
|
||
|
error(type + ' compilation did not work.')
|
||
|
endif
|
||
12 years ago
|
|
||
8 years ago
|
if ok.returncode() == 0
|
||
|
message(type + ' return code ok.')
|
||
|
else
|
||
|
error(type + ' return code fail')
|
||
|
endif
|
||
12 years ago
|
|
||
8 years ago
|
if err.returncode() == 1
|
||
|
message(type + ' bad return code ok.')
|
||
|
else
|
||
|
error(type + ' bad return code fail.')
|
||
|
endif
|
||
12 years ago
|
|
||
8 years ago
|
if ok.stdout().strip() == 'stdout'
|
||
|
message(type + ' stdout ok.')
|
||
|
else
|
||
|
message(type + ' bad stdout.')
|
||
|
endif
|
||
8 years ago
|
|
||
8 years ago
|
if ok.stderr().strip() == 'stderr'
|
||
|
message(type + ' stderr ok.')
|
||
|
else
|
||
|
message(type + ' bad stderr.')
|
||
|
endif
|
||
|
endforeach
|
||
8 years ago
|
endforeach
|