diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-20 17:54:07 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-26 17:57:29 +0200 |
commit | db961e1e9fba6e0c439f69ac8342ef887d9d19a6 (patch) | |
tree | fdca64d26fed112afe20e59dcc42417ce3f0143e /test/buildtool/build_engine/base_maps/source_map.test.cpp | |
parent | 01a0ed081f8eb6f7c41cd1052b146813fb94f699 (diff) | |
download | justbuild-db961e1e9fba6e0c439f69ac8342ef887d9d19a6.tar.gz |
Add non-upwards symlinks in the rule language...
via a 'SYMLINK' constructor function. This works similarly to the
'FILE' construct, but the name given must point to a non-upwards
symlink and a symlink artifact is being generated from it.
Also updates the relevant tests.
Diffstat (limited to 'test/buildtool/build_engine/base_maps/source_map.test.cpp')
-rw-r--r-- | test/buildtool/build_engine/base_maps/source_map.test.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/buildtool/build_engine/base_maps/source_map.test.cpp b/test/buildtool/build_engine/base_maps/source_map.test.cpp index 3b787ffe..05157870 100644 --- a/test/buildtool/build_engine/base_maps/source_map.test.cpp +++ b/test/buildtool/build_engine/base_maps/source_map.test.cpp @@ -28,6 +28,14 @@ namespace { using namespace BuildMaps::Base; // NOLINT void SetupConfig(bool use_git) { + // manually create locally a test symlink in data_src; should match the + // git test_repo structure + if (not use_git) { + auto link_path = kBasePath / "data_src/foo/link"; + if (not FileSystemManager::Exists(link_path)) { + REQUIRE(FileSystemManager::CreateSymlink("dummy", link_path)); + } + } auto root = FileRoot{kBasePath / "data_src"}; if (use_git) { auto repo_path = CreateTestRepo(); @@ -156,3 +164,24 @@ TEST_CASE("subdir file") { CHECK(artifacts["bar/file"]["data"]["size"] == 0); } } + +TEST_CASE("subdir symlink") { + nlohmann::json artifacts; + auto name = EntityName{"", "foo", "link"}; + auto consumer = [&artifacts](auto values) { + artifacts = (*values[0])->Artifacts()->ToJson(); + }; + + SECTION("via file") { + CHECK(ReadSourceTarget(name, consumer, /*use_git=*/false)); + CHECK(artifacts["link"]["type"] == "LOCAL"); + CHECK(artifacts["link"]["data"]["path"] == "foo/link"); + } + + SECTION("via git tree") { + CHECK(ReadSourceTarget(name, consumer, /*use_git=*/true)); + CHECK(artifacts["link"]["type"] == "KNOWN"); + CHECK(artifacts["link"]["data"]["id"] == kSrcLinkId); + CHECK(artifacts["link"]["data"]["size"] == 5); // content: dummy + } +} |