From 5c4c9263a83471cdf3ecb897cff4ad46d3b5dd62 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Fri, 27 Dec 2024 19:52:22 -0500 Subject: [PATCH] inlyne: update test to remove `expect` dependency --- Formula/i/inlyne.rb | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Formula/i/inlyne.rb b/Formula/i/inlyne.rb index 4c0c3c2f0d068..2f6602e8019e8 100644 --- a/Formula/i/inlyne.rb +++ b/Formula/i/inlyne.rb @@ -19,8 +19,6 @@ class Inlyne < Formula depends_on "pkgconf" => :build depends_on "rust" => :build - uses_from_macos "expect" => :test - on_linux do depends_on "libxkbcommon" depends_on "wayland" @@ -42,22 +40,20 @@ def install return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"] test_markdown = testpath/"test.md" - test_markdown.write <<~EOS + test_markdown.write <<~MARKDOWN _lorem_ **ipsum** dolor **sit** _amet_ - EOS - - script = (testpath/"test.exp") - script.write <<~EOS - #!/usr/bin/env expect -f - set timeout 2 - - spawn #{bin}/inlyne #{test_markdown} - - send -- "q\r" - - expect eof - EOS - - system "expect", "-f", "test.exp" + MARKDOWN + + ENV["INLYNE_LOG"] = "inlyne=debug,cosmic_text=trace" + ENV["NO_COLOR"] = "1" + + Open3.popen2e(bin/"inlyne", test_markdown) do |_stdin, stdout_and_stderr, wait_thread| + sleep 2 + Process.kill "TERM", wait_thread.pid + output = stdout_and_stderr.read + assert_match "Line LTR: 'lorem ipsum dolor sit amet'", output + assert_match(/style: Italic,.*\n.*Run \[\]: 'lorem'/, output) + refute_match "ERROR", output + end end end