From 410f3dfc1b76ef42275a769a794503b41ea1ae29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 31 Mar 2023 01:11:19 +0200 Subject: tests: add test to ensure that build dir is preferred to src dir Extend the "common/include order" test to ensure that the build directory is preferred over the source directory. For example, when using `configure_file()`, the resulting file should be preferred over a file with the same name in the source directory. --- test cases/common/130 include order/inc3/meson.build | 2 ++ .../common/130 include order/inc3/prefer-build-dir-over-src-dir.h | 1 + test cases/common/130 include order/meson.build | 4 +++- test cases/common/130 include order/ordertest.c | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test cases/common/130 include order/inc3/meson.build create mode 100644 test cases/common/130 include order/inc3/prefer-build-dir-over-src-dir.h diff --git a/test cases/common/130 include order/inc3/meson.build b/test cases/common/130 include order/inc3/meson.build new file mode 100644 index 0000000..3c100c4 --- /dev/null +++ b/test cases/common/130 include order/inc3/meson.build @@ -0,0 +1,2 @@ +configure_file(output: 'prefer-build-dir-over-src-dir.h', + configuration: configuration_data()) diff --git a/test cases/common/130 include order/inc3/prefer-build-dir-over-src-dir.h b/test cases/common/130 include order/inc3/prefer-build-dir-over-src-dir.h new file mode 100644 index 0000000..0b07943 --- /dev/null +++ b/test cases/common/130 include order/inc3/prefer-build-dir-over-src-dir.h @@ -0,0 +1 @@ +#error "inc3/prefer-build-dir-over-src-dir.h included" diff --git a/test cases/common/130 include order/meson.build b/test cases/common/130 include order/meson.build index 9f275b8..8e05866 100644 --- a/test cases/common/130 include order/meson.build +++ b/test cases/common/130 include order/meson.build @@ -12,6 +12,8 @@ project('include order', 'c') # Custom target dir with a built header subdir('ctsub') +# Configures a header file +subdir('inc3') # Defines an internal dep subdir('sub1') # Defines a per-target include path @@ -32,5 +34,5 @@ test('eh', e) test('oh', f) # Test that the order in include_directories() is maintained -incs = include_directories('inc1', 'inc2') +incs = include_directories('inc1', 'inc2', 'inc3') executable('ordertest', 'ordertest.c', include_directories: incs) diff --git a/test cases/common/130 include order/ordertest.c b/test cases/common/130 include order/ordertest.c index 775e34f..6784af7 100644 --- a/test cases/common/130 include order/ordertest.c +++ b/test cases/common/130 include order/ordertest.c @@ -1,4 +1,5 @@ #include "hdr.h" +#include "prefer-build-dir-over-src-dir.h" #if !defined(SOME_DEFINE) || SOME_DEFINE != 42 #error "Should have picked up hdr.h from inc1/hdr.h" -- cgit v1.1