Skip to content

Commit

Permalink
Merge pull request #199789 from Homebrew/squiggly-heredocs-2
Browse files Browse the repository at this point in the history
formulae: use language-specific heredoc / squiggly heredoc
  • Loading branch information
BrewTestBot authored Dec 3, 2024
2 parents dea4ccd + 150827b commit 4fae1c8
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 104 deletions.
25 changes: 11 additions & 14 deletions Formula/f/flagd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,19 @@ def install

test do
port = free_port

json_url = "https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.json"
resolve_boolean_command = <<~BASH
curl \
--request POST \
--data '{"flagKey":"myBoolFlag","context":{}}' \
--header "Content-Type: application/json" \
localhost:#{port}/schema.v1.Service/ResolveBoolean
BASH

pid = spawn bin/"flagd", "start", "-f", json_url, "-p", port.to_s
begin
pid = fork do
exec bin/"flagd", "start", "-f",
"https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.json",
"-p", port.to_s
end
sleep 3

resolve_boolean_command = <<-BASH
curl -X POST "localhost:#{port}/schema.v1.Service/ResolveBoolean" -d '{"flagKey":"myBoolFlag","context":{}}' -H "Content-Type: application/json"
BASH

expected_output = /true/

assert_match expected_output, shell_output(resolve_boolean_command)
assert_match(/true/, shell_output(resolve_boolean_command))
ensure
Process.kill("TERM", pid)
Process.wait(pid)
Expand Down
9 changes: 5 additions & 4 deletions Formula/f/foot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ def install

mkdir_p config_dir

File.write config_file, <<-EOF
config_file.write <<~INI
[cursor]
style=blok
EOF
INI

assert_match(
/blok: not one of 'block', 'underline', 'beam'/,
shell_output("#{bin}/foot --check-config 2>&1", 230),
)

File.write config_file, <<-EOF
rm(config_file)
config_file.write <<~INI
[cursor]
style=block
EOF
INI

assert_empty shell_output("#{bin}/foot --check-config")
end
Expand Down
5 changes: 2 additions & 3 deletions Formula/k/kanata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def install
end

test do
minimal_config = <<-CFG
(testpath/"kanata.kbd").write <<~LISP
(defsrc
caps grv i
j k l
Expand All @@ -45,9 +45,8 @@ def install
cap (tap-hold-press 200 200 caps lctl)
grv (tap-hold-press 200 200 grv (layer-toggle arrows))
)
CFG
LISP

(testpath/"kanata.kbd").write(minimal_config)
system bin/"kanata", "--check"
end
end
2 changes: 1 addition & 1 deletion Formula/p/podman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def caveats
EOS
end
on_macos do
<<-EOS
<<~EOS
In order to run containers locally, podman depends on a Linux kernel.
One can be started manually using `podman machine` from this package.
To start a podman VM automatically at login, also install the cask
Expand Down
64 changes: 32 additions & 32 deletions Formula/r/rust-analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,42 @@ def rpc(json)
end

test do
input = rpc <<-EOF
{
"jsonrpc":"2.0",
"id":1,
"method":"initialize",
"params": {
"rootUri": "file:/dev/null",
"capabilities": {}
input = rpc <<~JSON
{
"jsonrpc":"2.0",
"id":1,
"method":"initialize",
"params": {
"rootUri": "file:/dev/null",
"capabilities": {}
}
}
}
EOF
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"initialized",
"params": {}
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"method":"initialized",
"params": {}
}
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"id": 1,
"method":"shutdown",
"params": null
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"id": 1,
"method":"shutdown",
"params": null
}
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"exit",
"params": {}
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"method":"exit",
"params": {}
}
JSON

output = /Content-Length: \d+\r\n\r\n/

Expand Down
23 changes: 10 additions & 13 deletions Formula/s/slides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,25 @@ def install
end

test do
(testpath/"test.md").write <<-MARKDOWN
# Slide 1
Content
(testpath/"test.md").write <<~MARKDOWN
# Slide 1
Content
---
---
# Slide 2
More Content
# Slide 2
More Content
MARKDOWN

# Bubbletea-based apps are hard to test even under PTY.spawn (or via
# expect) because they rely on vt100-like answerback support, such as
# "<ESC>[6n" to report the cursor position. For now we just run the command
# for a second and see that it tried to send some ANSI out of it.
require "pty"
r, _, pid = PTY.spawn "#{bin}/slides test.md"
sleep 1
Process.kill("TERM", pid)
begin
assert_match(/\e\[/, r.read)
rescue Errno::EIO
# GNU/Linux raises EIO when read is done on closed pty
PTY.spawn(bin/"slides", "test.md") do |r, _, pid|
sleep 1
Process.kill("TERM", pid)
assert_match(/\e\[/, r.read_nonblock(1024))
end
end
end
64 changes: 32 additions & 32 deletions Formula/t/texlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@ def rpc(json)
end

test do
input = rpc <<-EOF
{
"jsonrpc":"2.0",
"id":1,
"method":"initialize",
"params": {
"rootUri": "file:/dev/null",
"capabilities": {}
input = rpc <<~JSON
{
"jsonrpc":"2.0",
"id":1,
"method":"initialize",
"params": {
"rootUri": "file:/dev/null",
"capabilities": {}
}
}
}
EOF
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"initialized",
"params": {}
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"method":"initialized",
"params": {}
}
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"id": 1,
"method":"shutdown",
"params": null
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"id": 1,
"method":"shutdown",
"params": null
}
JSON

input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"exit",
"params": {}
}
EOF
input += rpc <<~JSON
{
"jsonrpc":"2.0",
"method":"exit",
"params": {}
}
JSON

output = /Content-Length: \d+\r\n\r\n/

Expand Down
10 changes: 5 additions & 5 deletions Formula/v/vhs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def install
end

test do
(testpath/"test.tape").write <<-TAPE
Output test.gif
Type "Foo Bar"
Enter
Sleep 1s
(testpath/"test.tape").write <<~TAPE
Output test.gif
Type "Foo Bar"
Enter
Sleep 1s
TAPE

system bin/"vhs", "validate", "test.tape"
Expand Down

0 comments on commit 4fae1c8

Please sign in to comment.