summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-04-25 12:12:14 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-04-25 15:26:53 +0200
commit32322ff28c151d8ec5510b7019365d573e44bddf (patch)
treeba1d961cb7414bed54fc8a617f51fcd15d620fcd /test
parent32981ac5493a7d9925130609ad123ae2ac9984ab (diff)
downloadjustbuild-32322ff28c151d8ec5510b7019365d573e44bddf.tar.gz
expression: add "msg" argument to "to_subdir"
... allowing to provide additional information in case of conflict during flat staging.
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/TARGETS1
-rw-r--r--test/end-to-end/user-errors/TARGETS8
-rwxr-xr-xtest/end-to-end/user-errors/flat-stage.sh64
3 files changed, 73 insertions, 0 deletions
diff --git a/test/end-to-end/TARGETS b/test/end-to-end/TARGETS
index 03b76c0e..720834fd 100644
--- a/test/end-to-end/TARGETS
+++ b/test/end-to-end/TARGETS
@@ -7,6 +7,7 @@
[ [["./", "actions", "TESTS"], "actions"]
, [["./", "generated-binary", "TESTS"], "generated-binary"]
, [["./", "targets", "TESTS"], "targets"]
+ , [["./", "user-errors", "TESTS"], "user-errors"]
]
}
}
diff --git a/test/end-to-end/user-errors/TARGETS b/test/end-to-end/user-errors/TARGETS
new file mode 100644
index 00000000..cb1b881e
--- /dev/null
+++ b/test/end-to-end/user-errors/TARGETS
@@ -0,0 +1,8 @@
+{ "flat-stage":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["flat-stage"]
+ , "test": ["flat-stage.sh"]
+ , "deps": [["test/end-to-end", "tool-under-test"]]
+ }
+, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["flat-stage"]}
+}
diff --git a/test/end-to-end/user-errors/flat-stage.sh b/test/end-to-end/user-errors/flat-stage.sh
new file mode 100755
index 00000000..e0ee2780
--- /dev/null
+++ b/test/end-to-end/user-errors/flat-stage.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+set -e
+
+mkdir .tool-root
+touch ROOT
+mkdir subdir
+touch foo.txt subdir/foo.txt
+cat > RULES <<'EOI'
+{ "data":
+ { "target_fields": ["srcs"]
+ , "string_fields": ["flat"]
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "srcs"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "x"
+ , "range": {"type": "FIELD", "name": "srcs"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "x"}}
+ }
+ }
+ ]
+ , ["internal information", "DeBuG-InFoRmAtIoN"]
+ , [ "result"
+ , { "type": "to_subdir"
+ , "subdir": "data"
+ , "flat": {"type": "FIELD", "name": "flat"}
+ , "msg":
+ [ "DataRuleSpecificErrorMessage"
+ , {"type": "var", "name": "internal information"}
+ ]
+ , "$1": {"type": "var", "name": "srcs"}
+ }
+ ]
+ ]
+ , "body":
+ {"type": "RESULT", "artifacts": {"type": "var", "name": "result"}}
+ }
+ }
+}
+EOI
+
+cat > TARGETS <<'EOI'
+{ "full": {"type": "data", "srcs": ["foo.txt", "subdir/foo.txt"]}
+, "flat":
+ {"type": "data", "srcs": ["foo.txt", "subdir/foo.txt"], "flat": ["YES"]}
+}
+EOI
+
+
+bin/tool-under-test build --local_build_root .tool-root -f build.log full 2>&1
+echo
+grep 'DataRuleSpecificErrorMessage' build.log && exit 1 || :
+grep 'DeBuG-InFoRmAtIoN' build.log && exit 1 || :
+
+bin/tool-under-test build --local_build_root .tool-root -f build.log flat 2>&1 && exit 1 || :
+echo
+grep 'DataRuleSpecificErrorMessage' build.log
+grep "DeBuG-InFoRmAtIoN" build.log
+
+echo OK