aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Filippov <alekseyf@google.com>2018-03-15 22:50:53 +0000
committerAleksey Filippov <alekseyf@google.com>2018-04-16 22:51:34 +0100
commitf4ea6ac454139a8076cead4dde773dd8e27801a2 (patch)
treedd1dfb72dfcb028dcbbf5e20057e9436324a7744
parentcb761718f0fad4a6ee6396149d03c5b6b1586f44 (diff)
downloadmeson-f4ea6ac454139a8076cead4dde773dd8e27801a2.zip
meson-f4ea6ac454139a8076cead4dde773dd8e27801a2.tar.gz
meson-f4ea6ac454139a8076cead4dde773dd8e27801a2.tar.bz2
Add '189 same target name flat layout' test
-rwxr-xr-xrun_unittests.py9
-rw-r--r--test cases/common/189 same target name flat layout/foo.c1
-rw-r--r--test cases/common/189 same target name flat layout/main.c16
-rw-r--r--test cases/common/189 same target name flat layout/meson.build11
-rw-r--r--test cases/common/189 same target name flat layout/subdir/foo.c1
-rw-r--r--test cases/common/189 same target name flat layout/subdir/meson.build1
6 files changed, 39 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 4ed75ea..775fd31 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1917,6 +1917,15 @@ int main(int argc, char **argv) {
self.init(testdir, extra_args=['--layout=flat'])
self.build()
+ def test_identical_target_name_in_subdir_flat_layout(self):
+ '''
+ Test that identical targets in different subdirs do not collide
+ if layout is flat.
+ '''
+ testdir = os.path.join(self.common_test_dir, '189 same target name flat layout')
+ self.init(testdir, extra_args=['--layout=flat'])
+ self.build()
+
def test_flock(self):
exception_raised = False
with tempfile.TemporaryDirectory() as tdir:
diff --git a/test cases/common/189 same target name flat layout/foo.c b/test cases/common/189 same target name flat layout/foo.c
new file mode 100644
index 0000000..ed42789
--- /dev/null
+++ b/test cases/common/189 same target name flat layout/foo.c
@@ -0,0 +1 @@
+int meson_test_main_foo(void) { return 10; }
diff --git a/test cases/common/189 same target name flat layout/main.c b/test cases/common/189 same target name flat layout/main.c
new file mode 100644
index 0000000..6f02aeb
--- /dev/null
+++ b/test cases/common/189 same target name flat layout/main.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int meson_test_main_foo(void);
+int meson_test_subproj_foo(void);
+
+int main(void) {
+ if (meson_test_main_foo() != 10) {
+ printf("Failed meson_test_main_foo\n");
+ return 1;
+ }
+ if (meson_test_subproj_foo() != 20) {
+ printf("Failed meson_test_subproj_foo\n");
+ return 1;
+ }
+ return 0;
+}
diff --git a/test cases/common/189 same target name flat layout/meson.build b/test cases/common/189 same target name flat layout/meson.build
new file mode 100644
index 0000000..a3c95fa
--- /dev/null
+++ b/test cases/common/189 same target name flat layout/meson.build
@@ -0,0 +1,11 @@
+project('subdir targets', 'c')
+
+# Idea behind this test is to create targets with identical name
+# but different output files. We can do this by choosing different
+# name_prefix of libraries. Target id does not depend on name_prefix.
+
+main_foo = static_library('foo', 'foo.c', name_prefix : 'main')
+subdir('subdir') # defines subdir_foo
+
+exe = executable('prog', 'main.c', link_with : [main_foo, subdir_foo])
+test('main test', exe)
diff --git a/test cases/common/189 same target name flat layout/subdir/foo.c b/test cases/common/189 same target name flat layout/subdir/foo.c
new file mode 100644
index 0000000..f334292
--- /dev/null
+++ b/test cases/common/189 same target name flat layout/subdir/foo.c
@@ -0,0 +1 @@
+int meson_test_subproj_foo(void) { return 20; }
diff --git a/test cases/common/189 same target name flat layout/subdir/meson.build b/test cases/common/189 same target name flat layout/subdir/meson.build
new file mode 100644
index 0000000..223a5ef
--- /dev/null
+++ b/test cases/common/189 same target name flat layout/subdir/meson.build
@@ -0,0 +1 @@
+subdir_foo = static_library('foo', 'foo.c', name_prefix : 'subdir')