summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2024-04-14 12:58:30 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2025-02-13 23:57:48 +0200
commitd37d649b08b832d52fa684bc0506829fb40d5261 (patch)
treec66e1461e91d6349457b826978e866fdabb19de1 /test cases
parentea678ed82938ceac00682b2695b57193d36b71b4 (diff)
downloadmeson-d37d649b08b832d52fa684bc0506829fb40d5261.tar.gz
Make all Meson level options overridable per subproject.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/40 options/meson.build8
-rw-r--r--test cases/common/87 default options/meson.build2
-rw-r--r--test cases/common/87 default options/subprojects/sub1/meson.build1
-rw-r--r--test cases/common/87 default options/subprojects/sub1/meson_options.txt1
-rw-r--r--test cases/unit/123 persp options/meson.build24
-rw-r--r--test cases/unit/123 persp options/meson.options1
-rw-r--r--test cases/unit/123 persp options/subprojects/sub1/meson.build22
-rw-r--r--test cases/unit/123 persp options/subprojects/sub1/meson.options1
-rw-r--r--test cases/unit/123 persp options/subprojects/sub1/sub1.c6
-rw-r--r--test cases/unit/123 persp options/subprojects/sub2/meson.build21
-rw-r--r--test cases/unit/123 persp options/subprojects/sub2/meson.options1
-rw-r--r--test cases/unit/123 persp options/subprojects/sub2/sub2.c6
-rw-r--r--test cases/unit/123 persp options/toplevel.c6
13 files changed, 96 insertions, 4 deletions
diff --git a/test cases/common/40 options/meson.build b/test cases/common/40 options/meson.build
index de4a7d50d..ed7668fde 100644
--- a/test cases/common/40 options/meson.build
+++ b/test cases/common/40 options/meson.build
@@ -18,7 +18,7 @@ if get_option('array_opt') != ['one', 'two']
endif
# If the default changes, update test cases/unit/13 reconfigure
-if get_option('b_lto') != false
+if get_option('b_pch') != true
error('Incorrect value in base option.')
endif
@@ -30,8 +30,10 @@ if get_option('integer_opt') != 3
error('Incorrect value in integer option.')
endif
-if get_option('neg_int_opt') != -3
- error('Incorrect value in negative integer option.')
+negint = get_option('neg_int_opt')
+
+if negint != -3 and negint != -10
+ error('Incorrect value @0@ in negative integer option.'.format(negint))
endif
if get_option('CaseSenSiTivE') != 'Some CAPS'
diff --git a/test cases/common/87 default options/meson.build b/test cases/common/87 default options/meson.build
index 51b5cdac9..1b482f1e3 100644
--- a/test cases/common/87 default options/meson.build
+++ b/test cases/common/87 default options/meson.build
@@ -30,4 +30,4 @@ assert(w_level == '3', 'warning level "' + w_level + '" instead of "3"')
# assert(cc.compiles('int foobar;', no_builtin_args : true), 'No_builtin did not disable builtins.')
# endif
-subproject('sub1')
+subproject('sub1', default_options: 'func_test_option=true')
diff --git a/test cases/common/87 default options/subprojects/sub1/meson.build b/test cases/common/87 default options/subprojects/sub1/meson.build
index de0dc216c..d6f796095 100644
--- a/test cases/common/87 default options/subprojects/sub1/meson.build
+++ b/test cases/common/87 default options/subprojects/sub1/meson.build
@@ -1,3 +1,4 @@
project('sub1')
assert(get_option('test_option') == false)
+assert(get_option('func_test_option') == true)
diff --git a/test cases/common/87 default options/subprojects/sub1/meson_options.txt b/test cases/common/87 default options/subprojects/sub1/meson_options.txt
index fc96f5e09..37ce4d4bb 100644
--- a/test cases/common/87 default options/subprojects/sub1/meson_options.txt
+++ b/test cases/common/87 default options/subprojects/sub1/meson_options.txt
@@ -1 +1,2 @@
option('test_option', type : 'boolean', value : true, description : 'Test option. Superproject overrides default to "false"')
+option('func_test_option', type : 'boolean', value : false, description : 'Test option. Superproject overrides default to "true"')
diff --git a/test cases/unit/123 persp options/meson.build b/test cases/unit/123 persp options/meson.build
new file mode 100644
index 000000000..2df4205e4
--- /dev/null
+++ b/test cases/unit/123 persp options/meson.build
@@ -0,0 +1,24 @@
+project('toplevel', 'c')
+
+round = get_option('round')
+opt = get_option('optimization')
+if round == 1
+ assert(opt == '1')
+elif round == 2
+ assert(opt == '1')
+elif round == 3
+ assert(opt == '1')
+elif round == 4
+ assert(opt == '3')
+elif round == 5
+ assert(opt == '3')
+elif round == 6
+ assert(opt == '3', opt)
+else
+ assert(false, 'Invalid round number')
+endif
+
+executable('toplevel', 'toplevel.c')
+
+subproject('sub1')
+subproject('sub2')
diff --git a/test cases/unit/123 persp options/meson.options b/test cases/unit/123 persp options/meson.options
new file mode 100644
index 000000000..2bfd08d36
--- /dev/null
+++ b/test cases/unit/123 persp options/meson.options
@@ -0,0 +1 @@
+option('round', type: 'integer', value: 1, description: 'The test round.')
diff --git a/test cases/unit/123 persp options/subprojects/sub1/meson.build b/test cases/unit/123 persp options/subprojects/sub1/meson.build
new file mode 100644
index 000000000..5b176189c
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub1/meson.build
@@ -0,0 +1,22 @@
+project('sub1', 'c')
+
+round = get_option('round')
+opt = get_option('optimization')
+if round == 1
+ assert(opt == '1')
+elif round == 2
+ assert(opt == '1')
+elif round == 3
+ assert(opt == '1')
+elif round == 4
+ assert(opt == '1')
+elif round == 5
+ assert(opt == '1')
+elif round == 6
+ assert(opt == '2')
+else
+ assert(false, 'Invalid round number')
+endif
+
+
+executable('sub1', 'sub1.c')
diff --git a/test cases/unit/123 persp options/subprojects/sub1/meson.options b/test cases/unit/123 persp options/subprojects/sub1/meson.options
new file mode 100644
index 000000000..ba5661a27
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub1/meson.options
@@ -0,0 +1 @@
+option('round', type: 'integer', value: 1, description: 'The test round.', yield: true)
diff --git a/test cases/unit/123 persp options/subprojects/sub1/sub1.c b/test cases/unit/123 persp options/subprojects/sub1/sub1.c
new file mode 100644
index 000000000..4e4b87372
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub1/sub1.c
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(void) {
+ printf("This is subproject 1.\n");
+ return 0;
+}
diff --git a/test cases/unit/123 persp options/subprojects/sub2/meson.build b/test cases/unit/123 persp options/subprojects/sub2/meson.build
new file mode 100644
index 000000000..e8935bc52
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub2/meson.build
@@ -0,0 +1,21 @@
+project('sub2', 'c')
+
+round = get_option('round')
+opt = get_option('optimization')
+if round == 1
+ assert(opt == '1')
+elif round == 2
+ assert(opt == '3')
+elif round == 3
+ assert(opt == '2')
+elif round == 4
+ assert(opt == '2')
+elif round == 5
+ assert(opt == '1')
+elif round == 6
+ assert(opt == '2')
+else
+ assert(false, 'Invalid round number')
+endif
+
+executable('sub2', 'sub2.c')
diff --git a/test cases/unit/123 persp options/subprojects/sub2/meson.options b/test cases/unit/123 persp options/subprojects/sub2/meson.options
new file mode 100644
index 000000000..ba5661a27
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub2/meson.options
@@ -0,0 +1 @@
+option('round', type: 'integer', value: 1, description: 'The test round.', yield: true)
diff --git a/test cases/unit/123 persp options/subprojects/sub2/sub2.c b/test cases/unit/123 persp options/subprojects/sub2/sub2.c
new file mode 100644
index 000000000..4e4b87372
--- /dev/null
+++ b/test cases/unit/123 persp options/subprojects/sub2/sub2.c
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(void) {
+ printf("This is subproject 1.\n");
+ return 0;
+}
diff --git a/test cases/unit/123 persp options/toplevel.c b/test cases/unit/123 persp options/toplevel.c
new file mode 100644
index 000000000..5748d6b37
--- /dev/null
+++ b/test cases/unit/123 persp options/toplevel.c
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(void) {
+ printf("This is the top level project.\n");
+ return 0;
+}