diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/build_engine/target_map/TARGETS | 16 | ||||
-rw-r--r-- | test/buildtool/build_engine/target_map/target_map_internals.test.cpp | 35 | ||||
-rwxr-xr-x | test/end-to-end/actions/conflicts.sh | 34 |
3 files changed, 84 insertions, 1 deletions
diff --git a/test/buildtool/build_engine/target_map/TARGETS b/test/buildtool/build_engine/target_map/TARGETS index 36799630..4c2eed56 100644 --- a/test/buildtool/build_engine/target_map/TARGETS +++ b/test/buildtool/build_engine/target_map/TARGETS @@ -26,6 +26,20 @@ ] , "stage": ["test", "buildtool", "build_engine", "target_map"] } +, "target_map_internals": + { "type": ["@", "rules", "CC/test", "test"] + , "name": ["target_map_internals"] + , "srcs": ["target_map_internals.test.cpp"] + , "deps": + [ ["@", "catch2", "", "catch2"] + , ["test", "catch-main"] + , [ "src/buildtool/build_engine/target_map" + , "target_map_testable_internals" + ] + , ["src/buildtool/build_engine/expression", "expression"] + ] + , "stage": ["test", "buildtool", "build_engine", "target_map"] + } , "test_data": { "type": ["@", "rules", "data", "staged"] , "srcs": @@ -67,6 +81,6 @@ , "TESTS": { "type": "install" , "tainted": ["test"] - , "deps": ["result_map", "target_map"] + , "deps": ["result_map", "target_map", "target_map_internals"] } } diff --git a/test/buildtool/build_engine/target_map/target_map_internals.test.cpp b/test/buildtool/build_engine/target_map/target_map_internals.test.cpp new file mode 100644 index 00000000..72d5b59c --- /dev/null +++ b/test/buildtool/build_engine/target_map/target_map_internals.test.cpp @@ -0,0 +1,35 @@ +#include "catch2/catch.hpp" +#include "src/buildtool/build_engine/expression/expression.hpp" +#include "src/buildtool/build_engine/target_map/utils.hpp" + +TEST_CASE("Tree conflicts", "[tree_conflict]") { + auto overlap = Expression::FromJson(R"({ "foo/bar": "content-1" + , "foo/bar/baz": "content-2"})"_json); + REQUIRE(overlap); + auto overlap_conflict = BuildMaps::Target::Utils::tree_conflict(overlap); + CHECK(overlap_conflict); + CHECK(*overlap_conflict == "foo/bar"); + + auto root_overlap = Expression::FromJson(R"({ ".": "content-1" + , "foo": "content-2"})"_json); + REQUIRE(root_overlap); + auto root_overlap_conflict = + BuildMaps::Target::Utils::tree_conflict(root_overlap); + CHECK(root_overlap_conflict); + CHECK(*root_overlap_conflict == "."); +} + +TEST_CASE("No conflict", "[tree_conflict]") { + auto no_overlap = Expression::FromJson(R"({ "foo/bar/baz.txt": "content-1" + , "foo/bar/baz": "content-2"})"_json); + REQUIRE(no_overlap); + auto no_overlap_conflict = + BuildMaps::Target::Utils::tree_conflict(no_overlap); + CHECK(!no_overlap_conflict); + + auto single_root = Expression::FromJson(R"({ ".": "content-1"})"_json); + REQUIRE(single_root); + auto single_root_conflict = + BuildMaps::Target::Utils::tree_conflict(single_root); + CHECK(!single_root_conflict); +} diff --git a/test/end-to-end/actions/conflicts.sh b/test/end-to-end/actions/conflicts.sh index 089e742a..0adf0476 100755 --- a/test/end-to-end/actions/conflicts.sh +++ b/test/end-to-end/actions/conflicts.sh @@ -156,6 +156,35 @@ cat > RULES <<'EOI' } } } +, "file-file-conflict": + { "expression": + { "type": "let*" + , "bindings": + [ [ "map" + , { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "foo/bar/baz.txt" + , "value": {"type": "BLOB", "data": "Some content"} + } + , { "type": "singleton_map" + , "key": "foo/bar/baz.txt/other/file.txt" + , "value": {"type": "BLOB", "data": "A different content"} + } + ] + } + ] + , [ "out" + , { "type": "ACTION" + , "inputs": {"type": "var", "name": "map"} + , "outs": ["out"] + , "cmd": ["cp", "foo.txt", "out"] + } + ] + ] + , "body": {"type": "RESULT", "artifacts": {"type": "var", "name": "out"}} + } + } } EOI cat > TARGETS <<'EOI' @@ -166,6 +195,7 @@ cat > TARGETS <<'EOI' , "input-tree-conflict": {"type": "input-tree-conflict"} , "artifacts-tree-conflict": {"type": "artifacts-tree-conflict"} , "runfiles-tree-conflict": {"type": "runfiles-tree-conflict"} +, "file-file-conflict": {"type": "file-file-conflict"} } EOI @@ -197,4 +227,8 @@ echo grep -i 'error.*runfiles.*conflict.*tree.*foo' log echo +./bin/tool-under-test analyse -f log file-file-conflict 2>&1 && exit 1 || : +grep -i 'error.*.*conflict.*foo/bar/baz.txt' log + +echo echo DONE |