aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-11-10 10:04:30 -0500
committerMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2020-02-05 13:23:55 -0500
commit6c963726cf7b9781fed55fd4ba41f81bca2d4dbb (patch)
tree1ddffedeb8b45eeb38cc89ef26e13a0b6160296e
parentc2e6565029779b749dc3423291524115af1b2bd7 (diff)
downloadmeson-6c963726cf7b9781fed55fd4ba41f81bca2d4dbb.zip
meson-6c963726cf7b9781fed55fd4ba41f81bca2d4dbb.tar.gz
meson-6c963726cf7b9781fed55fd4ba41f81bca2d4dbb.tar.bz2
add native-file properties tests
-rw-r--r--docs/markdown/Reference-manual.md4
-rw-r--r--test cases/common/192 args flattening/meson.build10
-rw-r--r--test cases/common/228 native prop/meson.build10
-rw-r--r--test cases/common/228 native prop/nativefile.ini3
-rw-r--r--test cases/failing/97 no native prop/meson.build3
5 files changed, 23 insertions, 7 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index e3830cc..690ae0b 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1786,6 +1786,10 @@ the following methods.
returns the "cross" compiler if we're currently cross-compiling and
the "native" compiler if we're not.
+- `get_native_property(propname, fallback_value)` returns the given
+ property from a native file, the optional second argument is returned
+ if the given property is not found.
+
- `has_exe_wrapper()` returns true when doing a cross build if there
is a wrapper command that can be used to execute cross built
binaries (for example when cross compiling from Linux to Windows,
diff --git a/test cases/common/192 args flattening/meson.build b/test cases/common/192 args flattening/meson.build
index 6da2e8f..42eb6d5 100644
--- a/test cases/common/192 args flattening/meson.build
+++ b/test cases/common/192 args flattening/meson.build
@@ -1,29 +1,25 @@
project('args flattening')
arr = get_variable('does-not-exist', ['bar', 'baz'])
-
assert(arr == ['bar', 'baz'], 'get_variable with array fallback is broken')
set_variable('arr', ['bar', 'baz'])
-
assert(arr == ['bar', 'baz'], 'set_variable(array) is broken')
conf = configuration_data()
-
conf.set('foo', ['bar', 'baz'])
-
assert(conf.get('foo') == ['bar', 'baz'], 'configuration_data.set(array) is broken')
arr = conf.get('does-not-exist', ['bar', 'baz'])
-
assert(arr == ['bar', 'baz'], 'configuration_data.get with array fallback is broken')
arr = meson.get_cross_property('does-not-exist', ['bar', 'baz'])
-
assert(arr == ['bar', 'baz'], 'meson.get_cross_property with array fallback is broken')
+arr = meson.get_native_property('does-not-exist', ['bar', 'baz'])
+assert(arr == ['bar', 'baz'], 'meson.get_native_property with array fallback is broken')
+
# Test deprecated behaviour
conf.set(['foo', 'bar'])
-
message(conf.get('foo'))
diff --git a/test cases/common/228 native prop/meson.build b/test cases/common/228 native prop/meson.build
new file mode 100644
index 0000000..5cffcad
--- /dev/null
+++ b/test cases/common/228 native prop/meson.build
@@ -0,0 +1,10 @@
+project('get native prop')
+
+x = meson.get_native_property('astring')
+assert(x=='mystring', 'did not get native property string. did you use "meson setup --native-file native.txt"')
+
+x = meson.get_native_property('notexist', 'fallback')
+assert(x=='fallback', 'fallback did not work')
+
+x = meson.get_native_property('anarray')
+assert(x==['one', 'two'], 'array did not work') \ No newline at end of file
diff --git a/test cases/common/228 native prop/nativefile.ini b/test cases/common/228 native prop/nativefile.ini
new file mode 100644
index 0000000..03c1e03
--- /dev/null
+++ b/test cases/common/228 native prop/nativefile.ini
@@ -0,0 +1,3 @@
+[properties]
+astring = 'mystring'
+anarray = ['one', 'two'] \ No newline at end of file
diff --git a/test cases/failing/97 no native prop/meson.build b/test cases/failing/97 no native prop/meson.build
new file mode 100644
index 0000000..2b7b46e
--- /dev/null
+++ b/test cases/failing/97 no native prop/meson.build
@@ -0,0 +1,3 @@
+project('missing native property')
+
+message(meson.get_native_property('nonexisting'))