Add test cases for compile-checks-in-files.

pull/833/head
Elliott Sales de Andrade 8 years ago
parent f2fed5052d
commit acdb17ffa2
  1. 2
      test cases/common/33 try compile/invalid.c
  2. 8
      test cases/common/33 try compile/meson.build
  3. 2
      test cases/common/33 try compile/valid.c
  4. 3
      test cases/common/39 tryrun/error.c
  5. 74
      test cases/common/39 tryrun/meson.build
  6. 1
      test cases/common/39 tryrun/no_compile.c
  7. 6
      test cases/common/39 tryrun/ok.c

@ -0,0 +1,2 @@
#include<nonexisting.h>
void func() { printf("This won't work.\n"); }

@ -13,6 +13,14 @@ if compiler.compiles(code, name : 'should succeed') == false
error('Compiler is fail.') error('Compiler is fail.')
endif endif
if compiler.compiles(files('valid.c'), name : 'should succeed') == false
error('Compiler is fail.')
endif
if compiler.compiles(breakcode, name : 'should fail') if compiler.compiles(breakcode, name : 'should fail')
error('Compiler returned true on broken code.') error('Compiler returned true on broken code.')
endif endif
if compiler.compiles(files('invalid.c'), name : 'should fail')
error('Compiler returned true on broken code.')
endif

@ -0,0 +1,2 @@
#include<stdio.h>
void func() { printf("Something.\n"); }

@ -0,0 +1,3 @@
int main(int argc, char **argv) {
return 1;
}

@ -27,42 +27,50 @@ error_code = '''int main(int argc, char **argv) {
no_compile_code = '''int main(int argc, char **argv) { no_compile_code = '''int main(int argc, char **argv) {
''' '''
ok = cc.run(ok_code, name : 'should succeed') INPUTS = [
err = cc.run(error_code, name : 'should fail') ['String', ok_code, error_code, no_compile_code],
noc = cc.run(no_compile_code, name : 'does not compile') ['File', files('ok.c'), files('error.c'), files('no_compile.c')],
]
if noc.compiled() foreach input : INPUTS
error('Compilation fail test failed.') type = input[0]
else ok = cc.run(input[1], name : type + ' should succeed')
message('Fail detected properly.') err = cc.run(input[2], name : type + ' should fail')
endif noc = cc.run(input[3], name : type + ' does not compile')
if ok.compiled() if noc.compiled()
message('Compilation worked.') error(type + ' compilation fail test failed.')
else else
error('Compilation did not work.') message(type + ' fail detected properly.')
endif endif
if ok.returncode() == 0 if ok.compiled()
message('Return code ok.') message(type + ' compilation worked.')
else else
error('Return code fail') error(type + ' compilation did not work.')
endif endif
if err.returncode() == 1 if ok.returncode() == 0
message('Bad return code ok.') message(type + ' return code ok.')
else else
error('Bad return code fail.') error(type + ' return code fail')
endif endif
if ok.stdout().strip() == 'stdout' if err.returncode() == 1
message('Stdout ok.') message(type + ' bad return code ok.')
else else
message('Bad stdout.') error(type + ' bad return code fail.')
endif endif
if ok.stderr().strip() == 'stderr' if ok.stdout().strip() == 'stdout'
message('Stderr ok.') message(type + ' stdout ok.')
else else
message('Bad stderr.') message(type + ' bad stdout.')
endif endif
if ok.stderr().strip() == 'stderr'
message(type + ' stderr ok.')
else
message(type + ' bad stderr.')
endif
endforeach

@ -0,0 +1 @@
int main(int argc, char **argv) {

@ -0,0 +1,6 @@
#include<stdio.h>
int main(int argc, char **argv) {
printf("%s\n", "stdout");
fprintf(stderr, "%s\n", "stderr");
return 0;
}
Loading…
Cancel
Save