Skip to content

Commit

Permalink
Merge pull request #202099 from Homebrew/buku-test
Browse files Browse the repository at this point in the history
buku: update test to drop `expect` dependency
  • Loading branch information
BrewTestBot authored Dec 22, 2024
2 parents a37f433 + 3f9289e commit 61bb701
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions Formula/b/buku.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class Buku < Formula
depends_on "cryptography"
depends_on "[email protected]"

uses_from_macos "expect" => :test
uses_from_macos "libffi"

resource "arrow" do
Expand Down Expand Up @@ -186,28 +185,45 @@ def install
assert_match "Index 1: updated", shell_output("#{bin}/buku --nostdin --nc --update")

# Test crypto functionality
(testpath/"crypto-test").write <<~SHELL
require "expect"
require "pty"
timeout = 5
PTY.spawn(bin/"buku", "--lock") do |r, w, pid|
# Lock bookmark database
spawn #{bin}/buku --lock
expect "Password: "
send "password\r"
expect "Password: "
send "password\r"
expect {
-re ".*ERROR.*" { exit 1 }
"File encrypted"
}
refute_nil r.expect("Password: ", timeout), "Expected password input"
w.write "password\r"
refute_nil r.expect("Password: ", timeout), "Expected password confirmation input"
w.write "password\r"
output = ""
begin
r.each { |line| output += line }
rescue Errno::EIO
# GNU/Linux raises EIO when read is done on closed pty
end
refute_match "ERROR", output
assert_match "File encrypted", output
ensure
r.close
w.close
Process.wait pid
end
PTY.spawn(bin/"buku", "--unlock") do |r, w, pid|
# Unlock bookmark database
spawn #{bin}/buku --unlock
expect "Password: "
send "password\r"
expect {
-re ".*ERROR.*" { exit 1 }
"File decrypted"
}
SHELL
system "expect", "-f", "crypto-test"
refute_nil r.expect("Password: ", timeout), "Expected password input"
w.write "password\r"
output = ""
begin
r.each { |line| output += line }
rescue Errno::EIO
# GNU/Linux raises EIO when read is done on closed pty
end
refute_match "ERROR", output
assert_match "File decrypted", output
ensure
r.close
w.close
Process.wait pid
end

# Test database content and search
result = shell_output("#{bin}/buku --np --sany Homebrew")
Expand Down

0 comments on commit 61bb701

Please sign in to comment.