summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/TARGETS1
-rw-r--r--test/end-to-end/cli/TARGETS8
-rw-r--r--test/end-to-end/cli/defaults.sh53
3 files changed, 62 insertions, 0 deletions
diff --git a/test/end-to-end/TARGETS b/test/end-to-end/TARGETS
index 1a984106..9bf99a36 100644
--- a/test/end-to-end/TARGETS
+++ b/test/end-to-end/TARGETS
@@ -5,6 +5,7 @@
, "tainted": ["test"]
, "dirs":
[ [["./", "actions", "TESTS"], "actions"]
+ , [["./", "cli", "TESTS"], "cli"]
, [["./", "generated-binary", "TESTS"], "generated-binary"]
, [["./", "targets", "TESTS"], "targets"]
, [["./", "user-errors", "TESTS"], "user-errors"]
diff --git a/test/end-to-end/cli/TARGETS b/test/end-to-end/cli/TARGETS
new file mode 100644
index 00000000..dd7b0444
--- /dev/null
+++ b/test/end-to-end/cli/TARGETS
@@ -0,0 +1,8 @@
+{ "defaults":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["defaults"]
+ , "test": ["defaults.sh"]
+ , "deps": [["test/end-to-end", "tool-under-test"]]
+ }
+, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["defaults"]}
+}
diff --git a/test/end-to-end/cli/defaults.sh b/test/end-to-end/cli/defaults.sh
new file mode 100644
index 00000000..70ae7ec7
--- /dev/null
+++ b/test/end-to-end/cli/defaults.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -e
+
+TOOL=$(realpath ./bin/tool-under-test)
+mkdir -p .root
+BUILDROOT=$(realpath .root)
+mkdir -p out
+OUTDIR=$(realpath out)
+
+
+mkdir src
+cd src
+touch ROOT
+
+cat > repos.json <<'EOF'
+{"repositories": {"": {"target_file_name": "TARGETS.local"}}}
+EOF
+export CONF=$(realpath repos.json)
+
+cat > TARGETS.local <<'EOF'
+{"a": {"type": "file_gen", "name": "a.txt", "data": "A-top-level"}}
+EOF
+
+echo
+echo === Default target ===
+${TOOL} build -C $CONF --local-build-root ${BUILDROOT} -Pa.txt | grep top-level
+
+
+echo
+echo === top-level module found ===
+
+mkdir foo
+cd foo
+cat > TARGETS <<'EOF'
+{"a": {"type": "file_gen", "name": "a.txt", "data": "WRONG"}}
+EOF
+${TOOL} build -C $CONF --local-build-root ${BUILDROOT} -Pa.txt | grep top-level
+
+echo === correct root referece ===
+
+cat > TARGETS.local <<'EOF'
+{"a": {"type": "file_gen", "name": "b.txt", "data": "A-local"}
+, "": {"type": "install", "deps": ["a", ["", "a"]]}
+}
+EOF
+
+${TOOL} install -C $CONF --local-build-root ${BUILDROOT} -o ${OUTDIR}/top-ref 2>&1
+echo
+grep top-level ${OUTDIR}/top-ref/a.txt
+grep local ${OUTDIR}/top-ref/b.txt
+
+echo
+echo === DONE ===