summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/generated-binary/TARGETS12
-rwxr-xr-xtest/end-to-end/generated-binary/compiled.sh23
-rw-r--r--test/end-to-end/generated-binary/data/RULES.compiled74
3 files changed, 108 insertions, 1 deletions
diff --git a/test/end-to-end/generated-binary/TARGETS b/test/end-to-end/generated-binary/TARGETS
index 2f9164e9..e19f97f3 100644
--- a/test/end-to-end/generated-binary/TARGETS
+++ b/test/end-to-end/generated-binary/TARGETS
@@ -5,5 +5,15 @@
, "keep": ["out/out.txt"]
, "deps": [["test/end-to-end", "tool-under-test"]]
}
-, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["shell"]}
+, "compile rules":
+ {"type": "install", "files": {"RULES": "data/RULES.compiled"}}
+, "compiled":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["compiled"]
+ , "test": ["compiled.sh"]
+ , "keep": ["graph.json", "out/out.txt"]
+ , "deps": [["test/end-to-end", "tool-under-test"], "compile rules"]
+ }
+, "TESTS":
+ {"type": "install", "tainted": ["test"], "deps": ["shell", "compiled"]}
}
diff --git a/test/end-to-end/generated-binary/compiled.sh b/test/end-to-end/generated-binary/compiled.sh
new file mode 100755
index 00000000..572e8187
--- /dev/null
+++ b/test/end-to-end/generated-binary/compiled.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+mkdir .tool-root
+touch ROOT
+cat > TARGETS <<'EOI'
+{ "program outputs": {"type": "generated files", "width": ["16"]}
+, "ALL":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["cat $(ls out-*.txt | sort) > out.txt"]
+ , "deps": ["program outputs"]
+ }
+}
+EOI
+
+echo
+echo "Analysing"
+bin/tool-under-test analyse --dump_graph graph.json 2>&1
+
+echo
+echo "Building"
+bin/tool-under-test install -o out --local_build_root .tool-root -J 16 2>&1
diff --git a/test/end-to-end/generated-binary/data/RULES.compiled b/test/end-to-end/generated-binary/data/RULES.compiled
new file mode 100644
index 00000000..b2c10dd9
--- /dev/null
+++ b/test/end-to-end/generated-binary/data/RULES.compiled
@@ -0,0 +1,74 @@
+{ "generated files":
+ { "string_fields": ["width"]
+ , "expression":
+ { "type": "RESULT"
+ , "artifacts":
+ { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "n"
+ , "range":
+ { "type": "range"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "width"}}
+ }
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "src"
+ , { "type": "join"
+ , "$1":
+ [ "#include <stdio.h>\n"
+ , "int main(int argc, char **argv) {\n"
+ , " printf(\"Hello from generated program #%s!\", \""
+ , {"type": "var", "name": "n"}
+ , "\");\n"
+ , " return 0;\n"
+ , "}\n"
+ ]
+ }
+ ]
+ , [ "src file"
+ , { "type": "singleton_map"
+ , "key": "hello.c"
+ , "value":
+ {"type": "BLOB", "data": {"type": "var", "name": "src"}}
+ }
+ ]
+ , [ "hello"
+ , { "type": "ACTION"
+ , "inputs": {"type": "var", "name": "src file"}
+ , "outs": ["hello"]
+ , "cmd": ["cc", "-o", "hello", "hello.c"]
+ , "env":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": "/bin:/sbin:/usr/bin:/usr/sbin"
+ }
+ }
+ ]
+ , [ "out"
+ , { "type": "ACTION"
+ , "inputs": {"type": "var", "name": "hello"}
+ , "outs":
+ [ { "type": "join"
+ , "$1": ["out-", {"type": "var", "name": "n"}, ".txt"]
+ }
+ ]
+ , "cmd":
+ [ "/bin/sh"
+ , "-c"
+ , { "type": "join"
+ , "$1":
+ ["./hello > out-", {"type": "var", "name": "n"}, ".txt"]
+ }
+ ]
+ }
+ ]
+ ]
+ , "body": {"type": "var", "name": "out"}
+ }
+ }
+ }
+ }
+ }
+}