Skip to content

Commit

Permalink
Merge pull request #199905 from Homebrew/language-heredocs-p-s
Browse files Browse the repository at this point in the history
formulae(p - s): use language-specific heredoc delimiters
  • Loading branch information
p-linnane authored Dec 3, 2024
2 parents 9ffe1ee + e4d62a5 commit 88514db
Show file tree
Hide file tree
Showing 26 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Formula/p/packetbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def install
prefix.install "_meta/kibana"
end

(bin/"packetbeat").write <<~EOS
(bin/"packetbeat").write <<~SH
#!/bin/sh
exec #{libexec}/bin/packetbeat \
--path.config #{etc}/packetbeat \
--path.data #{var}/lib/packetbeat \
--path.home #{prefix} \
--path.logs #{var}/log/packetbeat \
"$@"
EOS
SH

chmod 0555, bin/"packetbeat" # generate_completions_from_executable fails otherwise
generate_completions_from_executable(bin/"packetbeat", "completion", shells: [:bash, :zsh])
Expand Down
12 changes: 6 additions & 6 deletions Formula/p/pandoc-plot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ def install
end

test do
input_markdown_1 = <<~EOS
input_markdown_1 = <<~MARKDOWN
# pandoc-plot demo
```{.graphviz}
digraph {
pandoc -> plot
}
```
EOS
MARKDOWN

input_markdown_2 = <<~EOS
input_markdown_2 = <<~MARKDOWN
# repeat the same thing
```{.graphviz}
digraph {
pandoc -> plot
}
```
EOS
MARKDOWN

output_html_1 = pipe_output("pandoc --filter #{bin}/pandoc-plot -f markdown -t html5", input_markdown_1)
output_html_2 = pipe_output("pandoc --filter #{bin}/pandoc-plot -f markdown -t html5", input_markdown_2)
filename = output_html_1.match(%r{(plots/[\da-z]+\.png)}i)

expected_html_2 = <<~EOS
expected_html_2 = <<~HTML
<h1 id="repeat-the-same-thing">repeat the same thing</h1>
<figure>
<img src="#{filename}" />
</figure>
EOS
HTML

assert_equal expected_html_2, output_html_2
end
Expand Down
8 changes: 4 additions & 4 deletions Formula/p/pandoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def install
end

test do
input_markdown = <<~EOS
input_markdown = <<~MARKDOWN
# Homebrew
A package manager for humans. Cats should take a look at Tigerbrew.
EOS
expected_html = <<~EOS
MARKDOWN
expected_html = <<~HTML
<h1 id="homebrew">Homebrew</h1>
<p>A package manager for humans. Cats should take a look at
Tigerbrew.</p>
EOS
HTML
assert_equal expected_html, pipe_output("#{bin}/pandoc -f markdown -t html5", input_markdown)
end
end
4 changes: 2 additions & 2 deletions Formula/p/pandocomatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def install
A package manager for humans. Cats should take a look at Tigerbrew.
MARKDOWN
expected_html = <<~EOS
expected_html = <<~HTML
<h1 id="homebrew">Homebrew</h1>
<p>A package manager for humans. Cats should take a look at
Tigerbrew.</p>
EOS
HTML
system bin/"pandocomatic", "-i", "test.md", "-o", "test.html"
assert_equal expected_html, (testpath/"test.html").read
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/php-cs-fixer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class PhpCsFixer < Formula
def install
libexec.install "php-cs-fixer.phar"

(bin/"php-cs-fixer").write <<~EOS
(bin/"php-cs-fixer").write <<~PHP
#!#{Formula["[email protected]"].opt_bin}/php
<?php require '#{libexec}/php-cs-fixer.phar';
EOS
PHP
end

test do
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/pip-tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def install
end

test do
(testpath/"requirements.in").write <<~EOS
(testpath/"requirements.in").write <<~REQUIREMENTS
pip-tools
typing-extensions
EOS
REQUIREMENTS

compiled = shell_output("#{bin}/pip-compile requirements.in -q -o -")
assert_match "This file is autogenerated by pip-compile", compiled
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/procyon-decompiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def install
end

test do
fixture = <<~EOS
fixture = <<~JAVA
class T
{
public static void main(final String[] array) {
System.out.println("Hello World!");
}
}
EOS
JAVA

(testpath/"T.java").write fixture
system Formula["openjdk@21"].bin/"javac", "T.java"
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/protobuf-c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def install
end

test do
testdata = <<~EOS
testdata = <<~PROTO
syntax = "proto3";
package test;
message TestCase {
Expand All @@ -55,7 +55,7 @@ def install
message Test {
repeated TestCase case = 1;
}
EOS
PROTO
(testpath/"test.proto").write testdata
system Formula["protobuf"].opt_bin/"protoc", "test.proto", "--c_out=."

Expand Down
4 changes: 2 additions & 2 deletions Formula/p/protobuf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def install
end

test do
(testpath/"test.proto").write <<~EOS
(testpath/"test.proto").write <<~PROTO
syntax = "proto3";
package test;
message TestCase {
Expand All @@ -69,7 +69,7 @@ def install
message Test {
repeated TestCase case = 1;
}
EOS
PROTO
system bin/"protoc", "test.proto", "--cpp_out=."
end
end
4 changes: 2 additions & 2 deletions Formula/p/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def install
end

test do
testdata = <<~EOS
testdata = <<~PROTO
syntax = "proto3";
package test;
message TestCase {
Expand All @@ -74,7 +74,7 @@ def install
message Test {
repeated TestCase case = 1;
}
EOS
PROTO
(testpath/"test.proto").write testdata
system bin/"protoc", "test.proto", "--cpp_out=."

Expand Down
4 changes: 2 additions & 2 deletions Formula/p/protoc-gen-gogo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def install

test do
protofile = testpath/"proto3.proto"
protofile.write <<~EOS
protofile.write <<~PROTO
syntax = "proto3";
package proto3;
message Request {
string name = 1;
repeated int64 key = 2;
}
EOS
PROTO
system "protoc", "--gogo_out=.", "proto3.proto"
assert_predicate testpath/"proto3.pb.go", :exist?
refute_predicate (testpath/"proto3.pb.go").size, :zero?
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/protoc-gen-gogofaster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def install

test do
protofile = testpath/"proto3.proto"
protofile.write <<~EOS
protofile.write <<~PROTO
syntax = "proto3";
package proto3;
message Request {
string name = 1;
repeated int64 key = 2;
}
EOS
PROTO
system "protoc", "--gogofaster_out=.", "proto3.proto"
assert_predicate testpath/"proto3.pb.go", :exist?
refute_predicate (testpath/"proto3.pb.go").size, :zero?
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/pyqt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def install
next if r.name == "pyqt6-webengine" && OS.mac? && DevelopmentTools.clang_build_version <= 1200

r.stage do
inreplace "pyproject.toml", "[tool.sip.project]", <<~EOS
inreplace "pyproject.toml", "[tool.sip.project]", <<~TOML
[tool.sip.project]
sip-include-dirs = ["#{site_packages}/PyQt#{version.major}/bindings"]
EOS
TOML
system sip_install, "--target-dir", site_packages
end
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def install
next if r.name == "pyqt5-sip"

r.stage do
inreplace "pyproject.toml", "[tool.sip.project]", <<~EOS
inreplace "pyproject.toml", "[tool.sip.project]", <<~TOML
[tool.sip.project]
sip-include-dirs = ["#{site_packages}/PyQt#{version.major}/bindings"]
EOS
TOML
system sip_install, "--target-dir", site_packages
end
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/p/python-yq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def install
end

test do
input = <<~EOS
input = <<~YAML
foo:
bar: 1
baz: {bat: 3}
EOS
YAML
expected = <<~EOS
3
...
Expand Down
8 changes: 4 additions & 4 deletions Formula/r/remarshal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ def install

test do
json = "{\"foo.bar\":\"baz\",\"qux\":1}"
yaml = <<~EOS.chomp
yaml = <<~YAML.chomp
foo.bar: baz
qux: 1
EOS
toml = <<~EOS.chomp
YAML
toml = <<~TOML.chomp
"foo.bar" = "baz"
qux = 1
EOS
TOML
assert_equal yaml, pipe_output("#{bin}/remarshal -if=json -of=yaml", json)
assert_equal yaml, pipe_output("#{bin}/json2yaml", json)
assert_equal toml, pipe_output("#{bin}/remarshal -if=yaml -of=toml", yaml)
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rgbds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def install

test do
# Based on https://github.com/rednex/rgbds/blob/HEAD/test/asm/assert-const.asm
(testpath/"source.asm").write <<~EOS
(testpath/"source.asm").write <<~ASM
SECTION "rgbasm passing asserts", ROM0[0]
Label:
db 0
assert @
EOS
ASM
system bin/"rgbasm", "-o", "output.o", "source.asm"
system bin/"rgbobj", "-A", "-s", "data", "-p", "data", "output.o"
system bin/"rgbgfx", test_fixtures("test.png"), "-o", testpath/"test.2bpp"
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rqlite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def install
end
sleep 5

(testpath/"test.sql").write <<~EOS
(testpath/"test.sql").write <<~SQL
CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)
.schema
quit
EOS
SQL
output = shell_output("#{bin}/rqlite -p #{port} < test.sql")
assert_match "foo", output

Expand Down
4 changes: 2 additions & 2 deletions Formula/r/runme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def install
test do
system bin/"runme", "--version"
markdown = (testpath/"README.md")
markdown.write <<~EOS
markdown.write <<~MARKDOWN
# Some Markdown
Has some text.
```sh { name=foobar }
echo "Hello World"
```
EOS
MARKDOWN
assert_match "Hello World", shell_output("#{bin}/runme run --git-ignore=false foobar")
assert_match "foobar", shell_output("#{bin}/runme list --git-ignore=false")
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/salt-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def install
end

test do
(testpath/"test.sls").write <<~EOS
(testpath/"test.sls").write <<~YAML
/tmp/testfile:
file.managed:
- source: salt://{{unspaced_var}}/example
EOS
YAML
out = shell_output("#{bin}/salt-lint #{testpath}/test.sls", 2)
assert_match "[206] Jinja variables should have spaces before and after: '{{ var_name }}'", out
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/scheme48.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def install
end

test do
(testpath/"hello.scm").write <<~EOS
(testpath/"hello.scm").write <<~SCHEME
(display "Hello, World!") (newline)
EOS
SCHEME

expected = <<~EOS
Hello, World!\#{Unspecific}
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/solhint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def install
}
EOS

(testpath/"test.sol").write <<~EOS
(testpath/"test.sol").write <<~SOLIDITY
pragma solidity ^0.4.0;
contract Test {
function test() {
}
}
EOS
SOLIDITY
assert_match "error Code contains empty blocks no-empty-blocks",
shell_output("#{bin}/solhint --config #{test_config} test.sol 2>&1", 1)
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/solidity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def install
end

test do
(testpath/"hello.sol").write <<~EOS
(testpath/"hello.sol").write <<~SOLIDITY
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract HelloWorld {
function helloWorld() external pure returns (string memory) {
return "Hello, World!";
}
}
EOS
SOLIDITY

output = shell_output("#{bin}/solc --bin hello.sol")
assert_match "hello.sol:HelloWorld", output
Expand Down
Loading

0 comments on commit 88514db

Please sign in to comment.