Skip to content

Commit

Permalink
inlyne: update test to remove expect dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Jan 17, 2025
1 parent b44c891 commit e3f09b7
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions Formula/i/inlyne.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class Inlyne < Formula
depends_on "pkgconf" => :build
depends_on "rust" => :build

uses_from_macos "expect" => :test

on_linux do
depends_on "xorg-server" => :test
depends_on "libxkbcommon"
depends_on "wayland"
end
Expand All @@ -37,27 +36,34 @@ def install
test do

Check failure on line 36 in Formula/i/inlyne.rb

View workflow job for this annotation

GitHub Actions / Linux

`brew test --verbose inlyne` failed on Linux!

/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/test.rb:54:in `<main>'
assert_match version.to_s, shell_output("#{bin}/inlyne --version")

# Fails in Linux CI with
# "Failed to initialize any backend! Wayland status: XdgRuntimeDirNotSet X11 status: XOpenDisplayFailed"
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}
MARKDOWN

send -- "q\r"
ENV["INLYNE_LOG"] = "inlyne=debug,cosmic_text=trace"
ENV["NO_COLOR"] = "1"

expect eof
EOS
if OS.linux?
xvfb_pid = spawn Formula["xorg-server"].bin/"Xvfb", ":1"
ENV["DISPLAY"] = ":1"
sleep 5
end

system "expect", "-f", "test.exp"
Open3.popen2e(bin/"inlyne", test_markdown) do |_stdin, stdout_and_stderr, wait_thread|
sleep 2
if OS.mac? && Hardware::CPU.intel? && ENV["HOMEBREW_GITHUB_ACTIONS"]
# Fails to use Metal backend on Intel macOS CI
refute_predicate wait_thread, :alive?
else
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
ensure
Process.kill "TERM", xvfb_pid if xvfb_pid
end
end

0 comments on commit e3f09b7

Please sign in to comment.