From f1e4fa98cc08553e4252c4d550a0b8aa91b60597 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Sat, 14 Dec 2024 16:39:28 -0500 Subject: [PATCH] replxx 0.0.4 (new formula) --- Formula/r/replxx.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Formula/r/replxx.rb diff --git a/Formula/r/replxx.rb b/Formula/r/replxx.rb new file mode 100644 index 0000000000000..0bd65eb90a2c7 --- /dev/null +++ b/Formula/r/replxx.rb @@ -0,0 +1,36 @@ +class Replxx < Formula + desc "Readline and libedit replacement" + homepage "https://github.com/AmokHuginnsson/replxx" + url "https://github.com/AmokHuginnsson/replxx/archive/refs/tags/release-0.0.4.tar.gz" + sha256 "a22988b2184e1d256e2d111b5749e16ffb1accbf757c7b248226d73c426844c4" + license all_of: ["BSD-3-Clause", "Unicode-TOU"] + + depends_on "cmake" => :build + + def install + system "cmake", "-S", ".", "-B", "build", "-DBUILD_SHARED_LIBS=ON", *std_cmake_args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + + pkgshare.install "examples" + end + + test do + cp_r pkgshare/"examples", testpath + cd "examples" do + system ENV.cc, "-c", "util.c", "-o", "util.o" + system ENV.cc, "c-api.c", "util.o", "-L#{lib}", "-I#{include}", "-lreplxx", "-lm", "-o", "test" + + # `test` executable is an interactive program so we use Open3 interact with it + Open3.popen3("test") do |stdin, stdout, stderr, _| + stdin.puts "hello" + output = stdout.gets + assert_match "thanks for the input: hello", output if output + + stdin.close # simulate Ctrl+D by closing stdin + + assert_empty stderr.read + end + end + end +end