From 23a0a019db9e6fa6878d83579fa64b50fcb47935 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Thu, 9 Jan 2025 11:23:38 -0500 Subject: [PATCH] heksa: update test --- Formula/h/heksa.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Formula/h/heksa.rb b/Formula/h/heksa.rb index 247071c35bc1e9..ba9761d8d033c2 100644 --- a/Formula/h/heksa.rb +++ b/Formula/h/heksa.rb @@ -31,18 +31,11 @@ def install test do require "pty" - - r, _w, pid = PTY.spawn("#{bin}/heksa -l 16 -f asc -o no #{test_fixtures("test.png")}") - - # remove ANSI colors - begin - output = r.read.gsub(/\e\[([;\d]+)?m/, "") - assert_match(/^.PNG/, output) - rescue Errno::EIO - # GNU/Linux raises EIO when read is done on closed pty + PTY.spawn(bin/"heksa", "-l", "16", "-f", "asc", "-o", "no", test_fixtures("test.png")) do |r, _w, pid| + assert_predicate Process::Status.wait(pid), :success? + output = OS.mac? ? r.read : r.read_nonblock(1024) + # remove ANSI colors + assert_match(/^\.PNG/, output.gsub(/\e\[([;\d]+)?m/, "")) end - - Process.wait(pid) - assert_equal 0, $CHILD_STATUS.exitstatus end end