cli: harden tool output and tests

This commit is contained in:
scawful
2025-12-22 14:52:33 -05:00
parent 76512daba2
commit face88a940
9 changed files with 85 additions and 23 deletions

View File

@@ -26,12 +26,25 @@ namespace {
using ::testing::HasSubstr;
using ::testing::Not;
std::filesystem::path FindProjectRoot() {
std::filesystem::path root = std::filesystem::current_path();
while (!root.empty() && root != root.root_path()) {
if (std::filesystem::exists(root / "CMakeLists.txt") &&
std::filesystem::exists(root / "src" / "cli")) {
return root;
}
root = root.parent_path();
}
return std::filesystem::current_path();
}
// Test fixture for FileSystemTool tests
class FileSystemToolTest : public ::testing::Test {
protected:
void SetUp() override {
// Create test directories and files
test_dir_ = std::filesystem::temp_directory_path() / "yaze_fs_tool_test";
test_dir_ =
FindProjectRoot() / "test_temp" / "yaze_fs_tool_test";
std::filesystem::create_directories(test_dir_ / "subdir");
// Create test files