diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-10-12 23:26:30 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-10-12 23:26:30 +0300 |
commit | 95a99682b0c00c6a207b580a93a764aa507d1f46 (patch) | |
tree | 6e6d196fae767d9977ab8d13a7a143edb61f7c09 /test cases | |
parent | f194914b9fe0042cce83ee4371ca3ccc2efc7120 (diff) | |
parent | acdb17ffa2df2046cee320789b7ba5c81f0bbab5 (diff) | |
download | meson-95a99682b0c00c6a207b580a93a764aa507d1f46.zip meson-95a99682b0c00c6a207b580a93a764aa507d1f46.tar.gz meson-95a99682b0c00c6a207b580a93a764aa507d1f46.tar.bz2 |
Merge branch 'QuLogic-compiler-file-checks'
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/33 try compile/invalid.c | 2 | ||||
-rw-r--r-- | test cases/common/33 try compile/meson.build | 8 | ||||
-rw-r--r-- | test cases/common/33 try compile/valid.c | 2 | ||||
-rw-r--r-- | test cases/common/39 tryrun/error.c | 3 | ||||
-rw-r--r-- | test cases/common/39 tryrun/meson.build | 74 | ||||
-rw-r--r-- | test cases/common/39 tryrun/no_compile.c | 1 | ||||
-rw-r--r-- | test cases/common/39 tryrun/ok.c | 6 |
7 files changed, 63 insertions, 33 deletions
diff --git a/test cases/common/33 try compile/invalid.c b/test cases/common/33 try compile/invalid.c new file mode 100644 index 0000000..b623bf8 --- /dev/null +++ b/test cases/common/33 try compile/invalid.c @@ -0,0 +1,2 @@ +#include<nonexisting.h> +void func() { printf("This won't work.\n"); } diff --git a/test cases/common/33 try compile/meson.build b/test cases/common/33 try compile/meson.build index beafb93..bca82ce 100644 --- a/test cases/common/33 try compile/meson.build +++ b/test cases/common/33 try compile/meson.build @@ -13,6 +13,14 @@ if compiler.compiles(code, name : 'should succeed') == false error('Compiler is fail.') endif +if compiler.compiles(files('valid.c'), name : 'should succeed') == false + error('Compiler is fail.') +endif + if compiler.compiles(breakcode, name : 'should fail') error('Compiler returned true on broken code.') endif + +if compiler.compiles(files('invalid.c'), name : 'should fail') + error('Compiler returned true on broken code.') +endif diff --git a/test cases/common/33 try compile/valid.c b/test cases/common/33 try compile/valid.c new file mode 100644 index 0000000..3757f5a --- /dev/null +++ b/test cases/common/33 try compile/valid.c @@ -0,0 +1,2 @@ +#include<stdio.h> +void func() { printf("Something.\n"); } diff --git a/test cases/common/39 tryrun/error.c b/test cases/common/39 tryrun/error.c new file mode 100644 index 0000000..80eeb5d --- /dev/null +++ b/test cases/common/39 tryrun/error.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 1; +} diff --git a/test cases/common/39 tryrun/meson.build b/test cases/common/39 tryrun/meson.build index 78847c5..f5d07ab 100644 --- a/test cases/common/39 tryrun/meson.build +++ b/test cases/common/39 tryrun/meson.build @@ -27,42 +27,50 @@ error_code = '''int main(int argc, char **argv) { 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') +INPUTS = [ + ['String', ok_code, error_code, no_compile_code], + ['File', files('ok.c'), files('error.c'), files('no_compile.c')], +] -if noc.compiled() - error('Compilation fail test failed.') -else - message('Fail detected properly.') -endif +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') -if ok.compiled() - message('Compilation worked.') -else - error('Compilation did not work.') -endif + if noc.compiled() + error(type + ' compilation fail test failed.') + else + message(type + ' fail detected properly.') + endif -if ok.returncode() == 0 - message('Return code ok.') -else - error('Return code fail') -endif + if ok.compiled() + message(type + ' compilation worked.') + else + error(type + ' compilation did not work.') + endif -if err.returncode() == 1 - message('Bad return code ok.') -else - error('Bad return code fail.') -endif + if ok.returncode() == 0 + message(type + ' return code ok.') + else + error(type + ' return code fail') + endif -if ok.stdout().strip() == 'stdout' - message('Stdout ok.') -else - message('Bad stdout.') -endif + if err.returncode() == 1 + message(type + ' bad return code ok.') + else + error(type + ' bad return code fail.') + endif -if ok.stderr().strip() == 'stderr' - message('Stderr ok.') -else - message('Bad stderr.') -endif + if ok.stdout().strip() == 'stdout' + message(type + ' stdout ok.') + else + message(type + ' bad stdout.') + endif + + if ok.stderr().strip() == 'stderr' + message(type + ' stderr ok.') + else + message(type + ' bad stderr.') + endif +endforeach diff --git a/test cases/common/39 tryrun/no_compile.c b/test cases/common/39 tryrun/no_compile.c new file mode 100644 index 0000000..86b67ac --- /dev/null +++ b/test cases/common/39 tryrun/no_compile.c @@ -0,0 +1 @@ +int main(int argc, char **argv) { diff --git a/test cases/common/39 tryrun/ok.c b/test cases/common/39 tryrun/ok.c new file mode 100644 index 0000000..4111c74 --- /dev/null +++ b/test cases/common/39 tryrun/ok.c @@ -0,0 +1,6 @@ +#include<stdio.h> +int main(int argc, char **argv) { + printf("%s\n", "stdout"); + fprintf(stderr, "%s\n", "stderr"); + return 0; +} |