summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/buildtool/file_system/create_fs_test_git_bundle.sh17
-rw-r--r--test/buildtool/file_system/directory_entries.test.cpp3
-rw-r--r--test/buildtool/file_system/file_root.test.cpp24
-rw-r--r--test/buildtool/file_system/git_repo.test.cpp72
-rw-r--r--test/buildtool/file_system/git_tree.test.cpp51
-rw-r--r--test/other_tools/git_operations/critical_git_ops.test.cpp2
-rw-r--r--test/other_tools/git_operations/git_repo_remote.test.cpp8
7 files changed, 52 insertions, 125 deletions
diff --git a/test/buildtool/file_system/create_fs_test_git_bundle.sh b/test/buildtool/file_system/create_fs_test_git_bundle.sh
index 400f7e00..7958546c 100644
--- a/test/buildtool/file_system/create_fs_test_git_bundle.sh
+++ b/test/buildtool/file_system/create_fs_test_git_bundle.sh
@@ -18,19 +18,18 @@ set -e
# ---
# Structure of test_repo:
# ---
-# <root> <--kTreeId (tree)
+# <root> <--kTreeId: c610db170fbcad5f2d66fe19972495923f3b2536 (tree)
# |
-# +--bar <--kBarId (blob)
-# +--foo <--kFooId (blob)
-# +--baz <--kBazOneId (tree)
+# +--bar <--kBarId: ba0e162e1c47469e3fe4b393a8bf8c569f302116 (blob)
+# +--foo <--kFooId: 19102815663d23f8b75a47e7a01965dcdc96468c (blob)
+# +--baz <--kBazId: 27b32561185c2825150893774953906c6daa6798 (tree)
# | +--bar
# | +--foo
-# | +--baz <--kBazTwoId (tree)
-# | | +--bar
-# | | +--foo
# |
# ---
#
+# kCommitId: e4fc610c60716286b98cf51ad0c8f0d50f3aebb5 (commit)
+#
# foo is a regular file
# bar is an executable
#
@@ -44,11 +43,9 @@ cd test_repo
printf %s "foo" >> foo # no newline
printf %s "bar" >> bar # no newline
chmod +x bar
-mkdir -p baz/baz/
+mkdir -p baz
cp foo baz/foo
cp bar baz/bar
-cp foo baz/baz/foo
-cp bar baz/baz/bar
# create the repo
git init > /dev/null 2>&1
diff --git a/test/buildtool/file_system/directory_entries.test.cpp b/test/buildtool/file_system/directory_entries.test.cpp
index 585af659..4ef550f8 100644
--- a/test/buildtool/file_system/directory_entries.test.cpp
+++ b/test/buildtool/file_system/directory_entries.test.cpp
@@ -25,9 +25,6 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
-auto const kTreeId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"};
-auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
-auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
[[nodiscard]] auto GetTestDir() -> std::filesystem::path {
auto* tmp_dir = std::getenv("TEST_TMPDIR");
diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp
index 1255a263..e00ca6cc 100644
--- a/test/buildtool/file_system/file_root.test.cpp
+++ b/test/buildtool/file_system/file_root.test.cpp
@@ -25,7 +25,7 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
-auto const kTreeId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"};
+auto const kTreeId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
@@ -68,7 +68,7 @@ void TestFileRootReadFile(FileRoot const& root) {
CHECK(*bar == "bar");
REQUIRE(root.Exists("baz"));
- CHECK_FALSE(root.IsFile("baz"));
+ REQUIRE(root.IsDirectory("baz"));
}
void TestFileRootReadEntries(FileRoot const& root,
@@ -89,8 +89,7 @@ void TestFileRootReadEntries(FileRoot const& root,
void TestFileRootReadDirectory(FileRoot const& root) {
TestFileRootReadEntries(root, ".", true);
- TestFileRootReadEntries(root, "baz", true);
- TestFileRootReadEntries(root, "baz/baz", false);
+ TestFileRootReadEntries(root, "baz", false);
}
void TestFileRootReadFileType(FileRoot const& root) {
@@ -98,12 +97,25 @@ void TestFileRootReadFileType(FileRoot const& root) {
REQUIRE(foo_type);
CHECK(*foo_type == ObjectType::File);
- auto bar_type = root.FileType("baz/baz/bar");
+ auto bar_type = root.FileType("baz/bar");
REQUIRE(bar_type);
CHECK(*bar_type == ObjectType::Executable);
CHECK_FALSE(root.FileType("baz"));
CHECK_FALSE(root.FileType("does_not_exist"));
+
+ // Check subdir
+ REQUIRE(root.Exists("baz/foo"));
+ REQUIRE(root.IsFile("baz/foo"));
+ auto bazfoo = root.ReadFile("baz/foo");
+ REQUIRE(bazfoo);
+ CHECK(*bazfoo == "foo");
+
+ REQUIRE(root.Exists("baz/bar"));
+ REQUIRE(root.IsFile("baz/bar"));
+ auto bazbar = root.ReadFile("baz/bar");
+ REQUIRE(bazbar);
+ CHECK(*bazbar == "bar");
}
} // namespace
@@ -232,7 +244,7 @@ TEST_CASE("Creating artifact descriptions", "[file_root]") {
ObjectType::File,
"repo"});
- auto bar = root->ToArtifactDescription("baz/baz/bar", "repo");
+ auto bar = root->ToArtifactDescription("baz/bar", "repo");
REQUIRE(bar);
CHECK(*bar ==
ArtifactDescription{ArtifactDigest{kBarId, 3, /*is_tree=*/false},
diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp
index 34be03ff..df283c6e 100644
--- a/test/buildtool/file_system/git_repo.test.cpp
+++ b/test/buildtool/file_system/git_repo.test.cpp
@@ -26,12 +26,9 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
auto const kRootCommit =
- std::string{"bc5f88b46bbf0c4c61da7a1296fa9a0559b92822"};
-auto const kRootId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"};
-auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
-auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
-auto const kBazOneId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
-auto const kBazTwoId = std::string{"27b32561185c2825150893774953906c6daa6798"};
+ std::string{"e4fc610c60716286b98cf51ad0c8f0d50f3aebb5"};
+auto const kRootId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
+auto const kBazId = std::string{"27b32561185c2825150893774953906c6daa6798"};
} // namespace
@@ -237,14 +234,7 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
auto entry_baz_c =
repo->GetSubtreeFromCommit(kRootCommit, "baz", logger);
REQUIRE(entry_baz_c);
- CHECK(*entry_baz_c == kBazOneId);
- }
-
- SECTION("Get inner blob id") {
- auto entry_bazbazfoo_c =
- repo->GetSubtreeFromCommit(kRootCommit, "baz/baz/foo", logger);
- REQUIRE(entry_bazbazfoo_c);
- CHECK(*entry_bazbazfoo_c == kFooId);
+ CHECK(*entry_baz_c == kBazId);
}
}
@@ -258,13 +248,7 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
SECTION("Get inner tree id") {
auto entry_baz_t = repo->GetSubtreeFromTree(kRootId, "baz", logger);
REQUIRE(entry_baz_t);
- CHECK(*entry_baz_t == kBazOneId);
- }
- SECTION("Get inner blob id") {
- auto entry_bazbazfoo_t =
- repo->GetSubtreeFromTree(kRootId, "baz/baz/foo", logger);
- REQUIRE(entry_bazbazfoo_t);
- CHECK(*entry_bazbazfoo_t == kFooId);
+ CHECK(*entry_baz_t == kBazId);
}
}
@@ -279,10 +263,10 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
REQUIRE(root_path_from_baz);
CHECK(*root_path_from_baz == *repo_path);
- auto root_path_from_bazbazfoo = GitRepo::GetRepoRootFromPath(
- *repo_path / "baz/baz/foo", logger);
- REQUIRE(root_path_from_bazbazfoo);
- CHECK(*root_path_from_bazbazfoo == *repo_path);
+ auto root_path_from_bazfoo =
+ GitRepo::GetRepoRootFromPath(*repo_path / "baz/foo", logger);
+ REQUIRE(root_path_from_bazfoo);
+ CHECK(*root_path_from_bazfoo == *repo_path);
auto root_path_non_exist =
GitRepo::GetRepoRootFromPath("does_not_exist", logger);
@@ -317,15 +301,7 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
auto entry_baz_p =
repo->GetSubtreeFromPath(path_baz, kRootCommit, logger);
REQUIRE(entry_baz_p);
- CHECK(*entry_baz_p == kBazOneId);
- }
-
- SECTION("Get inner blob id") {
- auto path_bazbazfoo = *repo_path / "baz/baz/foo";
- auto entry_bazbazfoo_p =
- repo->GetSubtreeFromPath(path_bazbazfoo, kRootCommit, logger);
- REQUIRE(entry_bazbazfoo_p);
- CHECK(*entry_bazbazfoo_p == kFooId);
+ CHECK(*entry_baz_p == kBazId);
}
}
@@ -401,22 +377,21 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
REQUIRE(remote_repo);
REQUIRE(remote_repo->IsRepoFake());
// Get subtree entry id from commit
- auto entry_bazbar_c =
+ auto entry_baz_c =
remote_repo->GetSubtreeFromCommit(
- kRootCommit, "baz/bar", logger);
- REQUIRE(entry_bazbar_c);
- CHECK(*entry_bazbar_c == kBarId);
+ kRootCommit, "baz", logger);
+ REQUIRE(entry_baz_c);
+ CHECK(*entry_baz_c == kBazId);
} break;
case 1: {
auto remote_repo = GitRepo::Open(remote_cas);
REQUIRE(remote_repo);
REQUIRE(remote_repo->IsRepoFake());
// Get subtree entry id from root tree id
- auto entry_bazbar_t =
- remote_repo->GetSubtreeFromTree(
- kRootId, "baz/bar", logger);
- REQUIRE(entry_bazbar_t);
- CHECK(*entry_bazbar_t == kBarId);
+ auto entry_baz_t = remote_repo->GetSubtreeFromTree(
+ kRootId, "baz", logger);
+ REQUIRE(entry_baz_t);
+ CHECK(*entry_baz_t == kBazId);
} break;
case 2: {
auto remote_repo = GitRepo::Open(remote_cas);
@@ -434,12 +409,11 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
REQUIRE(remote_repo);
REQUIRE(remote_repo->IsRepoFake());
// Get subtree entry id from path
- auto path_bazbar = *remote_repo_path / "baz/bar";
- auto entry_bazbar_p =
- remote_repo->GetSubtreeFromPath(
- path_bazbar, kRootCommit, logger);
- REQUIRE(entry_bazbar_p);
- CHECK(*entry_bazbar_p == kBarId);
+ auto path_baz = *remote_repo_path / "baz";
+ auto entry_baz_p = remote_repo->GetSubtreeFromPath(
+ path_baz, kRootCommit, logger);
+ REQUIRE(entry_baz_p);
+ CHECK(*entry_baz_p == kBazId);
} break;
case 4: {
auto remote_repo = GitRepo::Open(remote_cas);
diff --git a/test/buildtool/file_system/git_tree.test.cpp b/test/buildtool/file_system/git_tree.test.cpp
index 1526e9c9..41eb40d9 100644
--- a/test/buildtool/file_system/git_tree.test.cpp
+++ b/test/buildtool/file_system/git_tree.test.cpp
@@ -24,7 +24,7 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
-auto const kTreeId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"};
+auto const kTreeId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
auto const kFailId = std::string{"0123456789abcdef0123456789abcdef01234567"};
@@ -348,36 +348,11 @@ TEST_CASE("Lookup entries by name", "[git_tree]") {
CHECK(entry_baz_bar->IsBlob());
CHECK(entry_baz_bar->Hash() == entry_bar->Hash());
- auto entry_baz_baz = tree_baz->LookupEntryByName("baz");
- REQUIRE(entry_baz_baz);
- CHECK(entry_baz_baz->IsTree());
-
SECTION("Lookup missing entries") {
CHECK_FALSE(tree_baz->LookupEntryByName("fool"));
CHECK_FALSE(tree_baz->LookupEntryByName("barn"));
CHECK_FALSE(tree_baz->LookupEntryByName("bazel"));
}
-
- SECTION("Lookup entries in sub-sub-tree") {
- auto const& tree_baz_baz = entry_baz_baz->Tree();
- REQUIRE(tree_baz_baz);
-
- auto entry_baz_baz_foo = tree_baz_baz->LookupEntryByName("foo");
- REQUIRE(entry_baz_baz_foo);
- CHECK(entry_baz_baz_foo->IsBlob());
- CHECK(entry_baz_baz_foo->Hash() == entry_foo->Hash());
-
- auto entry_baz_baz_bar = tree_baz_baz->LookupEntryByName("bar");
- REQUIRE(entry_baz_baz_bar);
- CHECK(entry_baz_baz_bar->IsBlob());
- CHECK(entry_baz_baz_bar->Hash() == entry_bar->Hash());
-
- SECTION("Lookup missing entries") {
- CHECK_FALSE(tree_baz_baz->LookupEntryByName("fool"));
- CHECK_FALSE(tree_baz_baz->LookupEntryByName("barn"));
- CHECK_FALSE(tree_baz_baz->LookupEntryByName("bazel"));
- }
- }
}
}
@@ -431,35 +406,11 @@ TEST_CASE("Lookup entries by path", "[git_tree]") {
CHECK(entry_baz_bar->IsBlob());
CHECK(entry_baz_bar->Hash() == entry_bar->Hash());
- auto entry_baz_baz = tree_root->LookupEntryByPath("baz/baz");
- REQUIRE(entry_baz_baz);
- CHECK(entry_baz_baz->IsTree());
-
SECTION("Lookup missing entries") {
CHECK_FALSE(tree_root->LookupEntryByPath("baz/fool"));
CHECK_FALSE(tree_root->LookupEntryByPath("baz/barn"));
CHECK_FALSE(tree_root->LookupEntryByPath("baz/bazel"));
}
-
- SECTION("Lookup entries in sub-sub-tree") {
- auto entry_baz_baz_foo =
- tree_root->LookupEntryByPath("baz/baz/foo");
- REQUIRE(entry_baz_baz_foo);
- CHECK(entry_baz_baz_foo->IsBlob());
- CHECK(entry_baz_baz_foo->Hash() == entry_foo->Hash());
-
- auto entry_baz_baz_bar =
- tree_root->LookupEntryByPath("baz/baz/bar");
- REQUIRE(entry_baz_baz_bar);
- CHECK(entry_baz_baz_bar->IsBlob());
- CHECK(entry_baz_baz_bar->Hash() == entry_bar->Hash());
-
- SECTION("Lookup missing entries") {
- CHECK_FALSE(tree_root->LookupEntryByPath("baz/baz/fool"));
- CHECK_FALSE(tree_root->LookupEntryByPath("baz/baz/barn"));
- CHECK_FALSE(tree_root->LookupEntryByPath("baz/baz/bazel"));
- }
- }
}
}
diff --git a/test/other_tools/git_operations/critical_git_ops.test.cpp b/test/other_tools/git_operations/critical_git_ops.test.cpp
index 092a3293..2fae228b 100644
--- a/test/other_tools/git_operations/critical_git_ops.test.cpp
+++ b/test/other_tools/git_operations/critical_git_ops.test.cpp
@@ -26,7 +26,7 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
auto const kRootCommit =
- std::string{"bc5f88b46bbf0c4c61da7a1296fa9a0559b92822"};
+ std::string{"e4fc610c60716286b98cf51ad0c8f0d50f3aebb5"};
} // namespace
diff --git a/test/other_tools/git_operations/git_repo_remote.test.cpp b/test/other_tools/git_operations/git_repo_remote.test.cpp
index 5e4f9f9e..42ad9eb7 100644
--- a/test/other_tools/git_operations/git_repo_remote.test.cpp
+++ b/test/other_tools/git_operations/git_repo_remote.test.cpp
@@ -26,12 +26,8 @@ namespace {
auto const kBundlePath =
std::string{"test/buildtool/file_system/data/test_repo.bundle"};
auto const kRootCommit =
- std::string{"bc5f88b46bbf0c4c61da7a1296fa9a0559b92822"};
-auto const kRootId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"};
-auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
-auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
-auto const kBazOneId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
-auto const kBazTwoId = std::string{"27b32561185c2825150893774953906c6daa6798"};
+ std::string{"e4fc610c60716286b98cf51ad0c8f0d50f3aebb5"};
+auto const kRootId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"};
} // namespace