Skip to content

Commit

Permalink
Merge pull request #203232 from Homebrew/broot-test
Browse files Browse the repository at this point in the history
broot: run test on Linux
  • Loading branch information
chenrui333 authored Jan 4, 2025
2 parents 8c20da8 + 655e83c commit 2e17440
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Formula/b/broot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,23 @@ def install
end

test do
return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]

output = shell_output("#{bin}/broot --help")
assert_match "lets you explore file hierarchies with a tree-like view", output

assert_match version.to_s, shell_output("#{bin}/broot --version")

require "pty"
require "io/console"
PTY.spawn(bin/"broot", "-c", ":print_tree", "--color", "no", "--outcmd", testpath/"output.txt",
err: :out) do |r, w, pid|
PTY.spawn(bin/"broot", "-c", ":print_tree", "--color", "no", "--outcmd", testpath/"output.txt") do |r, w, pid|
r.winsize = [20, 80] # broot dependency terminal requires width > 2
w.write "n\r"
assert_match "New Configuration files written in", r.read
Process.wait(pid)
output = ""
begin
r.each { |line| output += line }
rescue Errno::EIO
# GNU/Linux raises EIO when read is done on closed pty
end
assert_match "New Configuration files written in", output
assert_predicate Process::Status.wait(pid), :success?
end
assert_equal 0, $CHILD_STATUS.exitstatus
end
end

0 comments on commit 2e17440

Please sign in to comment.