Skip to content

Commit

Permalink
Merge pull request #199907 from Homebrew/language-heredocs-m
Browse files Browse the repository at this point in the history
m*: use language-specific heredoc delimiters
  • Loading branch information
ZhongRuoyu authored Dec 3, 2024
2 parents abaa5af + e90f729 commit 7f66111
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Formula/m/macvim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def install
# Simple test to check if MacVim was linked to Homebrew's Python 3
py3_exec_prefix = shell_output(Formula["[email protected]"].opt_libexec/"bin/python-config --exec-prefix")
assert_match py3_exec_prefix.chomp, output
(testpath/"commands.vim").write <<~EOS
(testpath/"commands.vim").write <<~VIM
:python3 import vim; vim.current.buffer[0] = 'hello python3'
:wq
EOS
VIM
system bin/"mvim", "-v", "-T", "dumb", "-s", "commands.vim", "test.txt"
assert_equal "hello python3", (testpath/"test.txt").read.chomp
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mailcatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def install
smtp_port = free_port
http_port = free_port
system bin/"mailcatcher", "--smtp-port", smtp_port.to_s, "--http-port", http_port.to_s
(testpath/"mailcatcher.exp").write <<~EOS
(testpath/"mailcatcher.exp").write <<~EXPECT
#!/usr/bin/env expect
set timeout 3
Expand Down Expand Up @@ -235,7 +235,7 @@ def install
"221 *" { }
eof { exit }
}
EOS
EXPECT

system "expect", "-f", "mailcatcher.exp"
assert_match "[email protected]", shell_output("curl --silent http://localhost:#{http_port}/messages")
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/makeself.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def install
source = testpath/"source"
source.mkdir
(source/"foo").write "bar"
(source/"script.sh").write <<~EOS
(source/"script.sh").write <<~SH
#!/bin/sh
echo 'Hello Homebrew!'
EOS
SH
chmod 0755, source/"script.sh"
system bin/"makeself", source, "testfile.run", "'A test file'", "./script.sh"
assert_match "Hello Homebrew!", shell_output("./testfile.run --target output")
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ def install
end

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
INI
etc.install "my.cnf"
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mcpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def install
end

test do
(testpath/"test.c.in").write <<~EOS
(testpath/"test.c.in").write <<~C
#define RET 5
int main() { return RET; }
EOS
C

(testpath/"test.c").write shell_output("#{bin}/mcpp test.c.in")
system ENV.cc, "test.c", "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mdsh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def install
test do
(testpath/"README.md").write "`$ seq 4 | sort -r`"
system bin/"mdsh"
assert_equal <<~EOS.strip, (testpath/"README.md").read
assert_equal <<~MARKDOWN.strip, (testpath/"README.md").read
`$ seq 4 | sort -r`
```
Expand All @@ -35,7 +35,7 @@ def install
2
1
```
EOS
MARKDOWN

assert_match version.to_s, shell_output("#{bin}/mdsh --version")
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/medusa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def install
test do
system "truffle", "init"

(testpath/"contracts/test.sol").write <<~EOS
(testpath/"contracts/test.sol").write <<~SOLIDITY
pragma solidity ^0.8.0;
contract Test {
function assert_true() public {
Expand All @@ -39,7 +39,7 @@ def install
assert(false);
}
}
EOS
SOLIDITY

fuzz_output = shell_output("#{bin}/medusa fuzz --compilation-target #{testpath} --test-limit 100", 7)
assert_match(/PASSED.*assert_true/, fuzz_output)
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/meson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def install
return 0;
}
C
(testpath/"meson.build").write <<~EOS
(testpath/"meson.build").write <<~MESON
project('hello', 'c')
executable('hello', 'helloworld.c')
EOS
MESON

system bin/"meson", "setup", "build"
assert_predicate testpath/"build/build.ninja", :exist?
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/metashell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def install
end

test do
(testpath/"test.hpp").write <<~EOS
(testpath/"test.hpp").write <<~CPP
template <class T> struct add_const { using type = const T; };
add_const<int>::type
EOS
CPP
output = pipe_output("#{bin}/metashell -H", (testpath/"test.hpp").read)
assert_match "const int", output
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/metricbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def install
prefix.install "build/kibana"
end

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

chmod 0555, bin/"metricbeat" # generate_completions_from_executable fails otherwise
generate_completions_from_executable(bin/"metricbeat", "completion", shells: [:bash, :zsh])
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def install
end

test do
(testpath/"command.exp").write <<~EOS
(testpath/"command.exp").write <<~EXPECT
set timeout -1
spawn #{bin}/mg
match_max 100000
send -- "\u0018\u0003"
expect eof
EOS
EXPECT

system "expect", "-f", "command.exp"
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mimirtool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def install
assert_match version.to_s, shell_output("#{bin}/mimirtool version")

# Check that the binary runs as expected by testing the 'rules check' command
test_rule = <<~EOF
test_rule = <<~YAML
namespace: my_namespace
groups:
- name: example
interval: 5m
rules:
- record: job_http_inprogress_requests_sum
expr: sum by (job) (http_inprogress_requests)
EOF
YAML

(testpath/"rule.yaml").write(test_rule)

Expand Down
8 changes: 4 additions & 4 deletions Formula/m/minisign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def install

test do
(testpath/"homebrew.txt").write "Hello World!"
(testpath/"keygen.exp").write <<~EOS
(testpath/"keygen.exp").write <<~EXPECT
set timeout -1
spawn #{bin}/minisign -G
expect -exact "Please enter a password to protect the secret key."
Expand All @@ -42,19 +42,19 @@ def install
Password (one more time): "
send -- "Homebrew\n"
expect eof
EOS
EXPECT

system "expect", "-f", "keygen.exp"
assert_path_exists testpath/"minisign.pub"
assert_path_exists testpath/".minisign/minisign.key"

(testpath/"signing.exp").write <<~EOS
(testpath/"signing.exp").write <<~EXPECT
set timeout -1
spawn #{bin}/minisign -Sm homebrew.txt
expect -exact "Password: "
send -- "Homebrew\n"
expect eof
EOS
EXPECT

system "expect", "-f", "signing.exp"
assert_path_exists testpath/"homebrew.txt.minisig"
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def install
generate_completions_from_executable(bin/"mise", "completion")
lib.mkpath
touch lib/".disable-self-update"
(share/"fish"/"vendor_conf.d"/"mise-activate.fish").write <<~EOS
(share/"fish"/"vendor_conf.d"/"mise-activate.fish").write <<~FISH
if [ "$MISE_FISH_AUTO_ACTIVATE" != "0" ]
#{opt_bin}/mise activate fish | source
end
EOS
FISH
end

def caveats
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mit-scheme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def install

test do
# https://www.cs.indiana.edu/pub/scheme-repository/code/num/primes.scm
(testpath/"primes.scm").write <<~EOS
(testpath/"primes.scm").write <<~SCHEME
;
; primes
; By Ozan Yigit
Expand Down Expand Up @@ -96,7 +96,7 @@ def install
(sieve (interval-list 2 n)))
; (primes<= 300)
EOS
SCHEME

output = shell_output(
"#{bin}/mit-scheme --load primes.scm --eval '(primes<= 72)' < /dev/null",
Expand Down
4 changes: 2 additions & 2 deletions Formula/m/mmtabbarview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def install
end

test do
(testpath/"test.m").write <<~EOS
(testpath/"test.m").write <<~OBJC
#import <MMTabBarView/MMTabBarView.h>
int main() {
MMTabBarView *view = [MMTabBarView alloc];
[view release];
return 0;
}
EOS
OBJC
system ENV.cc, "test.m", "-F#{frameworks}", "-framework", "MMTabBarView", "-framework", "Foundation", "-o", "test"
system "./test"
end
Expand Down
Loading

0 comments on commit 7f66111

Please sign in to comment.