summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-07-08 10:29:05 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-07-08 17:18:20 +0200
commitb9880e8ecdce02f047dfb1d19de5f1ed07a82ac6 (patch)
tree15590ac7a8ac0c5fbf052e47ae80c9382f88e489 /test
parentbf159b19daf72627de01987cfbb12461705a5f22 (diff)
downloadjustbuild-b9880e8ecdce02f047dfb1d19de5f1ed07a82ac6.tar.gz
In install-cas be more liberal in parsing artifact identifiers
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/common/TARGETS12
-rw-r--r--test/buildtool/common/common.test.cpp42
2 files changed, 54 insertions, 0 deletions
diff --git a/test/buildtool/common/TARGETS b/test/buildtool/common/TARGETS
index 8890b8b8..c52301b4 100644
--- a/test/buildtool/common/TARGETS
+++ b/test/buildtool/common/TARGETS
@@ -33,6 +33,17 @@
]
, "stage": ["test", "buildtool", "common"]
}
+, "common":
+ { "type": ["@", "rules", "CC/test", "test"]
+ , "name": ["common"]
+ , "srcs": ["common.test.cpp"]
+ , "deps":
+ [ ["@", "catch2", "", "catch2"]
+ , ["test", "catch-main"]
+ , ["src/buildtool/common", "common"]
+ ]
+ , "stage": ["test", "buildtool", "common"]
+ }
, "repository_config":
{ "type": ["@", "rules", "CC/test", "test"]
, "name": ["repository_config"]
@@ -52,6 +63,7 @@
[ "action_description"
, "artifact_description"
, "artifact_factory"
+ , "common"
, "repository_config"
]
}
diff --git a/test/buildtool/common/common.test.cpp b/test/buildtool/common/common.test.cpp
new file mode 100644
index 00000000..ea5af597
--- /dev/null
+++ b/test/buildtool/common/common.test.cpp
@@ -0,0 +1,42 @@
+#include "catch2/catch.hpp"
+#include "src/buildtool/common/artifact.hpp"
+
+TEST_CASE("ObjectInfo::LiberalFromString", "[artifcat]") {
+ auto expected = *Artifact::ObjectInfo::FromString(
+ "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]");
+ auto expected_as_tree = *Artifact::ObjectInfo::FromString(
+ "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:0:t]");
+
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f]") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "[5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:f") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:file") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:11:notavalidletter") ==
+ expected);
+
+ // Without size, which is not honored in equality
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689") == expected);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:") == expected);
+ // Syntactically invalid size should be ignored
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:xyz") == expected);
+
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689::t") ==
+ expected_as_tree);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689::tree") ==
+ expected_as_tree);
+ CHECK(Artifact::ObjectInfo::LiberalFromString(
+ "5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689:xyz:t") ==
+ expected_as_tree);
+}