aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-05-12 08:58:46 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-08-07 08:21:05 -0400
commit9df16279971b48787c1db232c274054f173531df (patch)
tree186a5a8ebc4c30c18a28e061c0b6f41e109826ed /test cases
parent2a731cc021f4699f73fb0fd23bb0b8ce11c4c510 (diff)
downloadmeson-9df16279971b48787c1db232c274054f173531df.zip
meson-9df16279971b48787c1db232c274054f173531df.tar.gz
meson-9df16279971b48787c1db232c274054f173531df.tar.bz2
Compiler: Add werror kwarg to compiles(), links() and run() methods
Fixes: #5399
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/28 try compile/meson.build23
1 files changed, 23 insertions, 0 deletions
diff --git a/test cases/common/28 try compile/meson.build b/test cases/common/28 try compile/meson.build
index 3480d1d..83cd29e 100644
--- a/test cases/common/28 try compile/meson.build
+++ b/test cases/common/28 try compile/meson.build
@@ -8,6 +8,10 @@ breakcode = '''#include<nonexisting.h>
void func(void) { printf("This won't work.\n"); }
'''
+warncode = '''#warning This is a warning
+int main(void) { return 0; }
+'''
+
foreach lang : ['c', 'cpp']
compiler = meson.get_compiler(lang)
@@ -31,4 +35,23 @@ foreach lang : ['c', 'cpp']
if compiler.compiles(files('invalid.c'), name : 'file should fail')
error('Compiler ' + compiler.get_id() + ' returned true on broken code.')
endif
+
+ # MSVC does not support #warning instruction
+ if compiler.get_id() != 'msvc'
+ # First check that all tests pass without werror, then check they fail with it.
+ foreach with_werror : [false, true]
+ expect_success = not with_werror
+ assert(compiler.compiles(warncode,
+ name: f'code with warning compiles with werror=@with_werror@',
+ werror: with_werror) == expect_success)
+ assert(compiler.links(warncode,
+ name: f'code with warning links with werror=@with_werror@',
+ werror: with_werror) == expect_success)
+ if meson.can_run_host_binaries()
+ assert((compiler.run(warncode,
+ name: f'code with warning runs with werror=@with_werror@',
+ werror: with_werror).returncode() == 0) == expect_success)
+ endif
+ endforeach
+ endif
endforeach