#include #include #include #include #include #include #include #include namespace fs = std::filesystem; using Catch::Matchers::ContainsSubstring; namespace { fs::path sourceRoot() { if (const char* root = std::getenv("YAMS_SOURCE_DIR")) { return fs::path(root); } if (const char* root = std::getenv("MESON_SOURCE_ROOT")) { return fs::path(root); } return fs::current_path(); } std::string readText(const fs::path& path) { std::ifstream input(path); REQUIRE(input.good()); std::ostringstream buffer; buffer << input.rdbuf(); return buffer.str(); } } // namespace TEST_CASE("Homebrew service formulas run yams-daemon in foreground", "[cli][homebrew][service][formula][catch2]") { const fs::path root = sourceRoot(); const std::vector requiredPaths = { root / "packaging/homebrew/yams.rb.template", root / "packaging/homebrew/yams-nightly.rb.template", }; const std::vector optionalPaths = { root / "homebrew-yams/Formula/yams.rb", root / "homebrew-yams/Formula/yams-nightly.rb", }; for (const auto& path : requiredPaths) { INFO(path.string()); REQUIRE(fs::exists(path)); const std::string text = readText(path); CHECK_THAT(text, ContainsSubstring("run [opt_bin/\"yams-daemon\", \"--foreground\"]")); } for (const auto& path : optionalPaths) { INFO(path.string()); if (!fs::exists(path)) { continue; } const std::string text = readText(path); CHECK_THAT(text, ContainsSubstring("run [opt_bin/\"yams-daemon\", \"--foreground\"]")); } }