summaryrefslogtreecommitdiffstats
path: root/test cases/unit/35 dist script
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/unit/35 dist script
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/unit/35 dist script')
-rw-r--r--test cases/unit/35 dist script/meson.build10
-rw-r--r--test cases/unit/35 dist script/prog.c7
-rwxr-xr-xtest cases/unit/35 dist script/replacer.py16
-rw-r--r--test cases/unit/35 dist script/subprojects/sub/dist-script.py12
-rw-r--r--test cases/unit/35 dist script/subprojects/sub/meson.build11
-rw-r--r--test cases/unit/35 dist script/subprojects/sub/meson_options.txt1
-rw-r--r--test cases/unit/35 dist script/subprojects/sub/prog.c1
7 files changed, 58 insertions, 0 deletions
diff --git a/test cases/unit/35 dist script/meson.build b/test cases/unit/35 dist script/meson.build
new file mode 100644
index 0000000..8db4235
--- /dev/null
+++ b/test cases/unit/35 dist script/meson.build
@@ -0,0 +1,10 @@
+project('dist script', 'c',
+ version : '1.0.0')
+
+exe = executable('comparer', 'prog.c')
+test('compare', exe)
+
+meson.add_dist_script('replacer.py', '"incorrect"', '"correct"')
+meson.add_dist_script(find_program('replacer.py'), '"incorrect"', '"correct"')
+
+subproject('sub')
diff --git a/test cases/unit/35 dist script/prog.c b/test cases/unit/35 dist script/prog.c
new file mode 100644
index 0000000..1bb6b05
--- /dev/null
+++ b/test cases/unit/35 dist script/prog.c
@@ -0,0 +1,7 @@
+#include<string.h>
+
+#define REPLACEME "incorrect"
+
+int main(int argc, char **argv) {
+ return strcmp(REPLACEME, "correct");
+}
diff --git a/test cases/unit/35 dist script/replacer.py b/test cases/unit/35 dist script/replacer.py
new file mode 100755
index 0000000..96ccdcc
--- /dev/null
+++ b/test cases/unit/35 dist script/replacer.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import os
+import pathlib
+import sys
+
+if len(sys.argv) < 3:
+ sys.exit('usage: replacer.py <pattern> <replacement>')
+
+source_root = pathlib.Path(os.environ['MESON_DIST_ROOT'])
+
+modfile = source_root / 'prog.c'
+
+contents = modfile.read_text()
+contents = contents.replace(sys.argv[1], sys.argv[2])
+modfile.write_text(contents)
diff --git a/test cases/unit/35 dist script/subprojects/sub/dist-script.py b/test cases/unit/35 dist script/subprojects/sub/dist-script.py
new file mode 100644
index 0000000..1274f29
--- /dev/null
+++ b/test cases/unit/35 dist script/subprojects/sub/dist-script.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import os
+import pathlib
+import sys
+
+assert sys.argv[1] == 'success'
+
+source_root = pathlib.Path(os.environ['MESON_PROJECT_DIST_ROOT'])
+modfile = source_root / 'prog.c'
+with modfile.open('w') as f:
+ f.write('int main(){return 0;}')
diff --git a/test cases/unit/35 dist script/subprojects/sub/meson.build b/test cases/unit/35 dist script/subprojects/sub/meson.build
new file mode 100644
index 0000000..a41a3b6
--- /dev/null
+++ b/test cases/unit/35 dist script/subprojects/sub/meson.build
@@ -0,0 +1,11 @@
+project('sub', 'c')
+
+if get_option('broken_dist_script')
+ # Make sure we can add a dist script in a subproject, but it won't be run
+ # if not using --include-subprojects.
+ meson.add_dist_script('dist-script.py', 'broken')
+else
+ # The dist script replace prog.c with something that actually build.
+ meson.add_dist_script('dist-script.py', 'success')
+ executable('prog', 'prog.c')
+endif
diff --git a/test cases/unit/35 dist script/subprojects/sub/meson_options.txt b/test cases/unit/35 dist script/subprojects/sub/meson_options.txt
new file mode 100644
index 0000000..8f52e0f
--- /dev/null
+++ b/test cases/unit/35 dist script/subprojects/sub/meson_options.txt
@@ -0,0 +1 @@
+option('broken_dist_script', type: 'boolean', value: true)
diff --git a/test cases/unit/35 dist script/subprojects/sub/prog.c b/test cases/unit/35 dist script/subprojects/sub/prog.c
new file mode 100644
index 0000000..049b36a
--- /dev/null
+++ b/test cases/unit/35 dist script/subprojects/sub/prog.c
@@ -0,0 +1 @@
+#error This should be replaced by a program during dist