aboutsummaryrefslogtreecommitdiff
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.build13
-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.build13
-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, 82 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..4207b8e
--- /dev/null
+++ b/test cases/keyval/1 basic/meson.build
@@ -0,0 +1,18 @@
+project('keyval basic test')
+
+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..dbdc5af
--- /dev/null
+++ b/test cases/keyval/1 basic/test.json
@@ -0,0 +1,7 @@
+{
+ "stdout": [
+ {
+ "line": "WARNING: Module unstable-keyval is now stable, please use the keyval module instead."
+ }
+ ]
+}
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..291ad93
--- /dev/null
+++ b/test cases/keyval/2 subdir/dir/meson.build
@@ -0,0 +1,13 @@
+
+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..adc5289
--- /dev/null
+++ b/test cases/keyval/3 load_config files/dir/meson.build
@@ -0,0 +1,13 @@
+
+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