summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-10-24 15:25:27 +0200
committerAlberto Sartori <alberto.sartori@huawei.com>2023-11-15 20:19:18 +0100
commit981b9b10d6f48fb2768110a9f81a5f4e880406b2 (patch)
tree9d3afb2e9c65862fe70cc1e476b5f4ae87e45183 /test
parentfe907ca625657dce0e2f08f2129cf36c840602d3 (diff)
downloadjustbuild-981b9b10d6f48fb2768110a9f81a5f4e880406b2.tar.gz
FileRoot: Add new absent root underlying type variant
Absent roots are characterised only by a Git tree hash, so a new variant of the underlying stored information was added in the form of a plain string. In order to avoid unwanted implicit conversions when instantiating via literal strings, we force callers of the constructors to explicitly differentiate between plain strings and filesystem paths. Existing tests were updated to reflect this. Co-authored-by: Alberto Sartori <alberto.sartori@huawei.com>
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/target_map/target_map.test.cpp14
-rw-r--r--test/buildtool/common/repository_config.test.cpp4
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api.test.hpp4
-rw-r--r--test/buildtool/file_system/file_root.test.cpp8
4 files changed, 19 insertions, 11 deletions
diff --git a/test/buildtool/build_engine/target_map/target_map.test.cpp b/test/buildtool/build_engine/target_map/target_map.test.cpp
index bd868b48..6397ba1d 100644
--- a/test/buildtool/build_engine/target_map/target_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/target_map.test.cpp
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <filesystem>
+
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/directory_map.hpp"
#include "src/buildtool/build_engine/base_maps/entity_name.hpp"
@@ -47,10 +49,14 @@ void SetupConfig() {
[[maybe_unused]] static auto done = CreateSymlinks();
// create the file roots
auto info = RepositoryConfig::RepositoryInfo{
- FileRoot{"test/buildtool/build_engine/target_map/data_src"},
- FileRoot{"test/buildtool/build_engine/target_map/data_targets"},
- FileRoot{"test/buildtool/build_engine/target_map/data_rules"},
- FileRoot{"test/buildtool/build_engine/target_map/data_expr"}};
+ FileRoot{std::filesystem::path{"test/buildtool/build_engine/target_map/"
+ "data_src"}},
+ FileRoot{std::filesystem::path{"test/buildtool/build_engine/target_map/"
+ "data_targets"}},
+ FileRoot{std::filesystem::path{"test/buildtool/build_engine/target_map/"
+ "data_rules"}},
+ FileRoot{std::filesystem::path{"test/buildtool/build_engine/target_map/"
+ "data_expr"}}};
RepositoryConfig::Instance().Reset();
RepositoryConfig::Instance().SetInfo("", std::move(info));
}
diff --git a/test/buildtool/common/repository_config.test.cpp b/test/buildtool/common/repository_config.test.cpp
index 29c89d50..cfde95ed 100644
--- a/test/buildtool/common/repository_config.test.cpp
+++ b/test/buildtool/common/repository_config.test.cpp
@@ -43,7 +43,7 @@ namespace {
return std::move(*root);
}
}
- return FileRoot{"missing"};
+ return FileRoot{std::filesystem::path{"missing"}};
}
[[nodiscard]] auto CreateFixedRepoInfo(
@@ -61,7 +61,7 @@ namespace {
std::string const& tfn = "TARGETS",
std::string const& rfn = "RULES",
std::string const& efn = "EXPRESSIONS") {
- static auto const kFileRoot = FileRoot{"file path"};
+ static auto const kFileRoot = FileRoot{std::filesystem::path{"file path"}};
return RepositoryConfig::RepositoryInfo{
kFileRoot, kFileRoot, kFileRoot, kFileRoot, bindings, tfn, rfn, efn};
}
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index ffee5184..bd02e0fb 100755
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -31,8 +31,8 @@
using ApiFactory = std::function<IExecutionApi::Ptr()>;
static inline void SetupConfig() {
- auto info = RepositoryConfig::RepositoryInfo{
- FileRoot{"test/buildtool/execution_engine/executor"}};
+ auto info = RepositoryConfig::RepositoryInfo{FileRoot{
+ std::filesystem::path{"test/buildtool/execution_engine/executor"}}};
RepositoryConfig::Instance().SetInfo("", std::move(info));
}
diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp
index eab17ff6..8828fb7b 100644
--- a/test/buildtool/file_system/file_root.test.cpp
+++ b/test/buildtool/file_system/file_root.test.cpp
@@ -165,7 +165,8 @@ TEST_CASE("Creating file root", "[file_root]") {
REQUIRE(root_path);
CHECK(FileRoot{*root_path}.Exists("."));
- CHECK_FALSE(FileRoot{"does_not_exist"}.Exists("."));
+ CHECK_FALSE(
+ FileRoot{std::filesystem::path{"does_not_exist"}}.Exists("."));
}
SECTION("git root") {
@@ -184,8 +185,9 @@ TEST_CASE("Creating file root", "[file_root]") {
REQUIRE(root_path);
CHECK(FileRoot{*root_path, /*ignore_special=*/true}.Exists("."));
- CHECK_FALSE(
- FileRoot{"does_not_exist", /*ignore_special=*/true}.Exists("."));
+ CHECK_FALSE(FileRoot{std::filesystem::path{"does_not_exist"},
+ /*ignore_special=*/true}
+ .Exists("."));
}
SECTION("git root ignore-special") {