diff --git a/Formula/catch2.rb b/Formula/catch2.rb new file mode 100644 index 0000000000..4c6d58e858 --- /dev/null +++ b/Formula/catch2.rb @@ -0,0 +1,34 @@ +class Catch2 < Formula + desc "Modern, C++-native, header-only, test framework" + homepage "https://github.com/catchorg/Catch2" + url "https://github.com/catchorg/Catch2/archive/v2.8.0.tar.gz" + sha256 "b567c37446cd22c8550bfeb7e2fe3f981b8f3ab8b2148499a522e7f61b8a481d" + + depends_on "cmake" => :build + + def install + mkdir "build" do + system "cmake", "..", "-DBUILD_TESTING=OFF", *std_cmake_args + system "cmake", "--build", ".", "--target", "install" + end + end + + test do + (testpath/"test.cpp").write <<~EOS + #define CATCH_CONFIG_MAIN + #include + TEST_CASE("Basic", "[catch2]") { + int x = 1; + SECTION("Test section 1") { + x = x + 1; + REQUIRE(x == 2); + } + SECTION("Test section 2") { + REQUIRE(x == 1); + } + } + EOS + system ENV.cxx, "test.cpp", "-std=c++11", "-o", "test" + system "./test" + end +end