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.

69 lines
1.3 KiB

project('tryrun', 'c')
# Complex to exercise all code paths.
if meson.is_cross_build()
if meson.has_exe_wrapper()
cc = meson.get_compiler('c', native : false)
else
cc = meson.get_compiler('c', native : true)
endif
else
cc = meson.get_compiler('c')
endif
ok_code = '''#include<stdio.h>
int main(int argc, char **argv) {
printf("%s\n", "stdout");
fprintf(stderr, "%s\n", "stderr");
return 0;
}
'''
error_code = '''int main(int argc, char **argv) {
return 1;
}
'''
no_compile_code = '''int main(int argc, char **argv) {
'''
ok = cc.run(ok_code, name : 'should succeed')
err = cc.run(error_code, name : 'should fail')
noc = cc.run(no_compile_code, name : 'does not compile')
if noc.compiled()
error('Compilation fail test failed.')
else
message('Fail detected properly.')
endif
if ok.compiled()
message('Compilation worked.')
else
error('Compilation did not work.')
endif
if ok.returncode() == 0
message('Return code ok.')
else
error('Return code fail')
endif
if err.returncode() == 1
message('Bad return code ok.')
else
error('Bad return code fail.')
endif
if ok.stdout().strip() == 'stdout'
message('Stdout ok.')
else
message('Bad stdout.')
endif
if ok.stderr().strip() == 'stderr'
message('Stderr ok.')
else
message('Bad stderr.')
endif