cli: harden tool output and tests
This commit is contained in:
@@ -35,12 +35,27 @@ TEST(ResourceCatalogTest, RomSchemaExposesActionsAndMetadata) {
|
||||
ASSERT_TRUE(rom_schema.ok());
|
||||
|
||||
const auto& actions = rom_schema->actions;
|
||||
ASSERT_EQ(actions.size(), 3);
|
||||
EXPECT_EQ(actions[0].name, "validate");
|
||||
EXPECT_FALSE(actions[0].effects.empty());
|
||||
EXPECT_FALSE(actions[0].returns.empty());
|
||||
EXPECT_EQ(actions[1].name, "diff");
|
||||
EXPECT_EQ(actions[2].name, "generate-golden");
|
||||
ASSERT_EQ(actions.size(), 4);
|
||||
auto has_info = std::find_if(
|
||||
actions.begin(), actions.end(),
|
||||
[](const auto& action) { return action.name == "info"; });
|
||||
EXPECT_NE(has_info, actions.end());
|
||||
auto has_validate = std::find_if(
|
||||
actions.begin(), actions.end(),
|
||||
[](const auto& action) { return action.name == "validate"; });
|
||||
EXPECT_NE(has_validate, actions.end());
|
||||
if (has_validate != actions.end()) {
|
||||
EXPECT_FALSE(has_validate->effects.empty());
|
||||
EXPECT_FALSE(has_validate->returns.empty());
|
||||
}
|
||||
auto has_diff = std::find_if(
|
||||
actions.begin(), actions.end(),
|
||||
[](const auto& action) { return action.name == "diff"; });
|
||||
EXPECT_NE(has_diff, actions.end());
|
||||
auto has_generate = std::find_if(
|
||||
actions.begin(), actions.end(),
|
||||
[](const auto& action) { return action.name == "generate-golden"; });
|
||||
EXPECT_NE(has_generate, actions.end());
|
||||
}
|
||||
|
||||
TEST(ResourceCatalogTest, PatchSchemaIncludesAsarAndCreateActions) {
|
||||
|
||||
@@ -235,8 +235,8 @@ TEST_F(ResourcePanelTest, ResourceLifecycle) {
|
||||
}
|
||||
|
||||
TEST_F(ResourcePanelTest, AlwaysEditorBound) {
|
||||
// Resource panels are always EditorBound
|
||||
EXPECT_EQ(panel_->GetPanelCategory(), PanelCategory::EditorBound);
|
||||
// Resource panels are CrossEditor by default
|
||||
EXPECT_EQ(panel_->GetPanelCategory(), PanelCategory::CrossEditor);
|
||||
}
|
||||
|
||||
TEST_F(ResourcePanelTest, AllowMultipleInstancesDefault) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -166,7 +166,7 @@ TEST(MemoryAnalyzeToolTest, GetUsageContainsLength) {
|
||||
|
||||
TEST(MemoryAnalyzeToolTest, GetDescriptionIsNotEmpty) {
|
||||
MemoryAnalyzeTool tool;
|
||||
EXPECT_THAT(tool.GetDescription(), Not(HasSubstr("")));
|
||||
EXPECT_FALSE(tool.GetDescription().empty());
|
||||
}
|
||||
|
||||
TEST(MemoryAnalyzeToolTest, DoesNotRequireLabels) {
|
||||
@@ -197,7 +197,7 @@ TEST(MemorySearchToolTest, GetUsageContainsStartEnd) {
|
||||
|
||||
TEST(MemorySearchToolTest, GetDescriptionIsNotEmpty) {
|
||||
MemorySearchTool tool;
|
||||
EXPECT_THAT(tool.GetDescription(), Not(HasSubstr("")));
|
||||
EXPECT_FALSE(tool.GetDescription().empty());
|
||||
}
|
||||
|
||||
TEST(MemorySearchToolTest, DoesNotRequireLabels) {
|
||||
@@ -226,7 +226,7 @@ TEST(MemoryCompareToolTest, GetUsageContainsExpected) {
|
||||
|
||||
TEST(MemoryCompareToolTest, GetDescriptionIsNotEmpty) {
|
||||
MemoryCompareTool tool;
|
||||
EXPECT_THAT(tool.GetDescription(), Not(HasSubstr("")));
|
||||
EXPECT_FALSE(tool.GetDescription().empty());
|
||||
}
|
||||
|
||||
TEST(MemoryCompareToolTest, DoesNotRequireLabels) {
|
||||
@@ -250,7 +250,7 @@ TEST(MemoryCheckToolTest, GetUsageContainsRegion) {
|
||||
|
||||
TEST(MemoryCheckToolTest, GetDescriptionIsNotEmpty) {
|
||||
MemoryCheckTool tool;
|
||||
EXPECT_THAT(tool.GetDescription(), Not(HasSubstr("")));
|
||||
EXPECT_FALSE(tool.GetDescription().empty());
|
||||
}
|
||||
|
||||
TEST(MemoryCheckToolTest, DoesNotRequireLabels) {
|
||||
@@ -279,7 +279,7 @@ TEST(MemoryRegionsToolTest, GetUsageContainsFormat) {
|
||||
|
||||
TEST(MemoryRegionsToolTest, GetDescriptionIsNotEmpty) {
|
||||
MemoryRegionsTool tool;
|
||||
EXPECT_THAT(tool.GetDescription(), Not(HasSubstr("")));
|
||||
EXPECT_FALSE(tool.GetDescription().empty());
|
||||
}
|
||||
|
||||
TEST(MemoryRegionsToolTest, DoesNotRequireLabels) {
|
||||
@@ -359,4 +359,3 @@ TEST(ALTTPMemoryMapTest, SRAMRegionSizeIsCorrect) {
|
||||
} // namespace agent
|
||||
} // namespace cli
|
||||
} // namespace yaze
|
||||
|
||||
|
||||
Reference in New Issue
Block a user