Do not fail "ninja test" when running as subproject
authorAhmed Masud <ahmed.masud@trustifier.com>
Fri, 19 Oct 2018 21:17:48 +0000 (17:17 -0400)
committerNikolaus Rath <Nikolaus@rath.org>
Fri, 19 Oct 2018 21:17:48 +0000 (14:17 -0700)
test/meson.build
test/wrong_command.c

index 69af767c4e3592ad3a98c25c96cd8fe6284acafd..5c5c2e626d959e25459f09d2357a9ef29065849f 100644 (file)
@@ -19,6 +19,12 @@ td += custom_target('test_scripts', input: test_scripts,
                                 '@INPUT@', meson.current_build_dir() ])
 
 # Provide something helpful when running 'ninja test'
-wrong_cmd = executable('wrong_command', 'wrong_command.c',
-                       install: false)
-test('wrong_cmd', wrong_cmd)
+
+if meson.is_subproject()
+       test('libfuse is a subproject, skipping tests', executable('wrong_command',
+                      'wrong_command.c', install: false,
+                       c_args: [ '-DMESON_IS_SUBPROJECT' ]))
+else
+       test('wrong_command', executable('wrong_command', 'wrong_command.c',
+                      install: false))
+endif
index 8366a9855e3ff87f1bc71d507f329851455b6aca..8b563c980837e42b981b323f1d50d3789ae46253 100644 (file)
@@ -1,9 +1,16 @@
 #include <stdio.h>
 
 int main(void) {
+#ifdef MESON_IS_SUBPROJECT
+       fprintf(stderr, "libfuse tests were skipped because it's a meson subproject.\n"
+                       "If you wish to run them try:\n"
+                       "'cd <srcdir>/subprojects/libfuse && meson . build && cd build && python3 -m pytest test/' instead");
+       return 77; /* report as a skipped test */
+#else
        fprintf(stderr, "\x1B[31m\e[1m"
                "This is not the command you are looking for.\n"
                "You probably want to run 'python3 -m pytest test/' instead"
                "\e[0m\n");
        return 1;
+#endif
 }