summaryrefslogtreecommitdiffstats
path: root/test cases/keyval
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/keyval')
-rw-r--r--test cases/keyval/1 basic/.config3
-rw-r--r--test cases/keyval/1 basic/meson.build18
-rw-r--r--test cases/keyval/1 basic/test.json7
-rw-r--r--test cases/keyval/2 subdir/.config2
-rw-r--r--test cases/keyval/2 subdir/dir/meson.build12
-rw-r--r--test cases/keyval/2 subdir/meson.build4
-rw-r--r--test cases/keyval/3 load_config files/dir/config2
-rw-r--r--test cases/keyval/3 load_config files/dir/meson.build12
-rw-r--r--test cases/keyval/3 load_config files/meson.build4
-rw-r--r--test cases/keyval/4 load_config builddir/config2
-rw-r--r--test cases/keyval/4 load_config builddir/meson.build14
11 files changed, 80 insertions, 0 deletions
diff --git a/test cases/keyval/1 basic/.config b/test cases/keyval/1 basic/.config
new file mode 100644
index 0000000..071d185
--- /dev/null
+++ b/test cases/keyval/1 basic/.config
@@ -0,0 +1,3 @@
+CONFIG_VAL1=y
+# CONFIG_VAL2 is not set
+CONFIG_VAL_VAL=4
diff --git a/test cases/keyval/1 basic/meson.build b/test cases/keyval/1 basic/meson.build
new file mode 100644
index 0000000..a6e023e
--- /dev/null
+++ b/test cases/keyval/1 basic/meson.build
@@ -0,0 +1,18 @@
+project('keyval basic test', meson_version : '>= 0.55')
+
+k = import('keyval')
+conf = k.load('.config')
+
+if not conf.has_key('CONFIG_VAL1')
+ error('Expected CONFIG_VAL1 to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_VAL2')
+ error('Expected CONFIG_VAL2 not be set, but it was')
+endif
+
+if conf.get('CONFIG_VAL_VAL').to_int() != 4
+ error('Expected CONFIG_VAL_VAL to be 4')
+endif
+
+k = import('unstable-keyval')
diff --git a/test cases/keyval/1 basic/test.json b/test cases/keyval/1 basic/test.json
new file mode 100644
index 0000000..1f8fd9b
--- /dev/null
+++ b/test cases/keyval/1 basic/test.json
@@ -0,0 +1,7 @@
+{
+ "stdout": [
+ {
+ "line": "test cases/keyval/1 basic/meson.build:3: WARNING: Project targets '>= 0.55' but uses feature introduced in '0.56.0': module keyval as stable module. Consider either adding \"unstable-\" to the module name, or updating the meson required version to \">= 0.56.0\""
+ }
+ ]
+}
diff --git a/test cases/keyval/2 subdir/.config b/test cases/keyval/2 subdir/.config
new file mode 100644
index 0000000..0599d46
--- /dev/null
+++ b/test cases/keyval/2 subdir/.config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/2 subdir/dir/meson.build b/test cases/keyval/2 subdir/dir/meson.build
new file mode 100644
index 0000000..3db80ad
--- /dev/null
+++ b/test cases/keyval/2 subdir/dir/meson.build
@@ -0,0 +1,12 @@
+
+k = import('keyval')
+
+conf = k.load(meson.source_root() / '.config')
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif
diff --git a/test cases/keyval/2 subdir/meson.build b/test cases/keyval/2 subdir/meson.build
new file mode 100644
index 0000000..0651acf
--- /dev/null
+++ b/test cases/keyval/2 subdir/meson.build
@@ -0,0 +1,4 @@
+project('keyval subdir test')
+
+# Test into sub directory
+subdir('dir')
diff --git a/test cases/keyval/3 load_config files/dir/config b/test cases/keyval/3 load_config files/dir/config
new file mode 100644
index 0000000..0599d46
--- /dev/null
+++ b/test cases/keyval/3 load_config files/dir/config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/3 load_config files/dir/meson.build b/test cases/keyval/3 load_config files/dir/meson.build
new file mode 100644
index 0000000..d8826ec
--- /dev/null
+++ b/test cases/keyval/3 load_config files/dir/meson.build
@@ -0,0 +1,12 @@
+
+k = import('keyval')
+
+conf = k.load(files('config'))
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif
diff --git a/test cases/keyval/3 load_config files/meson.build b/test cases/keyval/3 load_config files/meson.build
new file mode 100644
index 0000000..0651acf
--- /dev/null
+++ b/test cases/keyval/3 load_config files/meson.build
@@ -0,0 +1,4 @@
+project('keyval subdir test')
+
+# Test into sub directory
+subdir('dir')
diff --git a/test cases/keyval/4 load_config builddir/config b/test cases/keyval/4 load_config builddir/config
new file mode 100644
index 0000000..0599d46
--- /dev/null
+++ b/test cases/keyval/4 load_config builddir/config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/4 load_config builddir/meson.build b/test cases/keyval/4 load_config builddir/meson.build
new file mode 100644
index 0000000..6bd83db
--- /dev/null
+++ b/test cases/keyval/4 load_config builddir/meson.build
@@ -0,0 +1,14 @@
+project('keyval builddir test')
+
+k = import('keyval')
+
+out_conf = configure_file(input: 'config', output: 'out-config', copy: true)
+conf = k.load(out_conf)
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif