From ab39a174effd2ab77c21046412038b1d9376d6ff Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Tue, 27 Feb 2024 11:53:17 +0100 Subject: [PATCH] beakerlib 1.30 (new formula) Signed-off-by: Cristian Le --- Formula/b/beakerlib.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Formula/b/beakerlib.rb diff --git a/Formula/b/beakerlib.rb b/Formula/b/beakerlib.rb new file mode 100644 index 0000000000000..7e65003933db5 --- /dev/null +++ b/Formula/b/beakerlib.rb @@ -0,0 +1,39 @@ +class Beakerlib < Formula + desc "Shell-level integration testing library" + homepage "https://github.com/beakerlib/beakerlib" + url "https://github.com/beakerlib/beakerlib/archive/refs/tags/1.30.tar.gz" + sha256 "bd06fc61b32d9caf4324587706a8363e37e771355da8297d0c5ba0023ae31098" + license "GPL-2.0-only" + + uses_from_macos "gnu-getopt", since: :ventura + on_macos do + # Fix `readlink` + depends_on "coreutils" + end + + def install + system "make", "DD=#{prefix}", "install" + (prefix.glob "**/*.sh").each do |f| + inreplace f, "readlink", "#{Formula["coreutils"].opt_bin}/greadlink", false if OS.mac? + inreplace f, "getopt", "#{Formula["gnu-getopt"].opt_bin}/getopt", false if OS.mac? + end + end + + test do + (testpath/"test.sh").write <<~EOS + #!/usr/bin/env bash + source #{share}/beakerlib/beakerlib.sh || exit 1 + rlJournalStart + rlPhaseStartTest + rlPass "All works" + rlPhaseEnd + rlJournalEnd + EOS + expected_journal = /\[\s*PASS\s*\]\s*::\s*All works/ + ENV["BEAKERLIB_DIR"] = testpath + system "bash", "#{testpath}/test.sh" + assert_match expected_journal, File.read(testpath/"journal.txt") + assert_match "TESTRESULT_STATE=complete", File.read(testpath/"TestResults") + assert_match "TESTRESULT_RESULT_STRING=PASS", File.read(testpath/"TestResults") + end +end