-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202099 from Homebrew/buku-test
buku: update test to drop `expect` dependency
- Loading branch information
Showing
1 changed file
with
37 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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") | ||
|