Merge pull request #4455 from reitermarkus/heredocs
Use more descriptive heredoc names.
This commit is contained in:
commit
459e2bfa48
@ -258,7 +258,7 @@ module Hbc
|
||||
end
|
||||
|
||||
def trash_paths(*paths, command: nil, **_)
|
||||
result = command.run!("/usr/bin/osascript", args: ["-e", <<~'EOS', *paths])
|
||||
result = command.run!("/usr/bin/osascript", args: ["-e", <<~APPLESCRIPT, *paths])
|
||||
on run argv
|
||||
repeat with i from 1 to (count argv)
|
||||
set item i of argv to (item i of argv as POSIX file)
|
||||
@ -279,7 +279,7 @@ module Hbc
|
||||
return output
|
||||
end tell
|
||||
end run
|
||||
EOS
|
||||
APPLESCRIPT
|
||||
|
||||
# Remove AppleScript's automatic newline.
|
||||
result.tap { |r| r.stdout.sub!(/\n$/, "") }
|
||||
|
||||
@ -21,7 +21,7 @@ module Hbc
|
||||
end
|
||||
|
||||
def self.template(cask_token)
|
||||
<<~EOS
|
||||
<<~RUBY
|
||||
cask '#{cask_token}' do
|
||||
version ''
|
||||
sha256 ''
|
||||
@ -32,7 +32,7 @@ module Hbc
|
||||
|
||||
app ''
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
def self.help
|
||||
|
||||
@ -27,11 +27,11 @@ module Homebrew
|
||||
package_url = "#{bintray_repo_url}/#{bintray_package}"
|
||||
|
||||
unless system curl_executable, "--silent", "--fail", "--output", "/dev/null", package_url
|
||||
package_blob = <<~EOS
|
||||
package_blob = <<~JSON
|
||||
{"name": "#{bintray_package}",
|
||||
"public_download_numbers": true,
|
||||
"public_stats": true}
|
||||
EOS
|
||||
JSON
|
||||
curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}",
|
||||
"--header", "Content-Type: application/json",
|
||||
"--data", package_blob, bintray_repo_url
|
||||
|
||||
@ -30,7 +30,7 @@ module Homebrew
|
||||
|
||||
(tap.path/"Formula").mkpath
|
||||
|
||||
readme = <<~EOS
|
||||
readme = <<~MARKDOWN
|
||||
# #{titleized_user} #{titleized_repo}
|
||||
|
||||
## How do I install these formulae?
|
||||
@ -46,10 +46,10 @@ module Homebrew
|
||||
|
||||
## Documentation
|
||||
`brew help`, `man brew` or check [Homebrew's documentation](https://docs.brew.sh).
|
||||
EOS
|
||||
MARKDOWN
|
||||
write_path(tap, "README.md", readme)
|
||||
|
||||
travis = <<~EOS
|
||||
travis = <<~YAML
|
||||
language: c
|
||||
os: osx
|
||||
compiler: clang
|
||||
@ -71,7 +71,7 @@ module Homebrew
|
||||
|
||||
script:
|
||||
- brew test-bot
|
||||
EOS
|
||||
YAML
|
||||
write_path(tap, ".travis.yml", travis)
|
||||
end
|
||||
end
|
||||
|
||||
@ -392,10 +392,10 @@ class Pathname
|
||||
mkpath
|
||||
targets.each do |target|
|
||||
target = Pathname.new(target) # allow pathnames or strings
|
||||
join(target.basename).write <<~EOS
|
||||
join(target.basename).write <<~SH
|
||||
#!/bin/bash
|
||||
exec "#{target}" "$@"
|
||||
EOS
|
||||
SH
|
||||
end
|
||||
end
|
||||
|
||||
@ -404,10 +404,10 @@ class Pathname
|
||||
env_export = ""
|
||||
env.each { |key, value| env_export += "#{key}=\"#{value}\" " }
|
||||
dirname.mkpath
|
||||
write <<~EOS
|
||||
write <<~SH
|
||||
#!/bin/bash
|
||||
#{env_export}exec "#{target}" "$@"
|
||||
EOS
|
||||
SH
|
||||
end
|
||||
|
||||
# Writes a wrapper env script and moves all files to the dst
|
||||
@ -427,10 +427,10 @@ class Pathname
|
||||
java_home = if java_version
|
||||
"JAVA_HOME=\"$(#{Language::Java.java_home_cmd(java_version)})\" "
|
||||
end
|
||||
join(script_name).write <<~EOS
|
||||
join(script_name).write <<~SH
|
||||
#!/bin/bash
|
||||
#{java_home}exec java #{java_opts} -jar #{target_jar} "$@"
|
||||
EOS
|
||||
SH
|
||||
end
|
||||
|
||||
def install_metafiles(from = Pathname.pwd)
|
||||
|
||||
@ -1738,10 +1738,10 @@ class Formula
|
||||
# keep Homebrew's site-packages in sys.path when using system Python
|
||||
user_site_packages = home/"Library/Python/2.7/lib/python/site-packages"
|
||||
user_site_packages.mkpath
|
||||
(user_site_packages/"homebrew.pth").write <<~EOS
|
||||
(user_site_packages/"homebrew.pth").write <<~PYTHON
|
||||
import site; site.addsitedir("#{HOMEBREW_PREFIX}/lib/python2.7/site-packages")
|
||||
import sys, os; sys.path = (os.environ["PYTHONPATH"].split(os.pathsep) if "PYTHONPATH" in os.environ else []) + ["#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"] + sys.path
|
||||
EOS
|
||||
PYTHON
|
||||
end
|
||||
|
||||
public
|
||||
|
||||
@ -77,7 +77,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def template
|
||||
<<~EOS
|
||||
<<~ERB
|
||||
# Documentation: https://docs.brew.sh/Formula-Cookbook
|
||||
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
|
||||
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
|
||||
@ -147,7 +147,7 @@ module Homebrew
|
||||
system "false"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
ERB
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,20 +46,20 @@ module Language
|
||||
end
|
||||
|
||||
def self.in_sys_path?(python, path)
|
||||
script = <<~EOS
|
||||
script = <<~PYTHON
|
||||
import os, sys
|
||||
[os.path.realpath(p) for p in sys.path].index(os.path.realpath("#{path}"))
|
||||
EOS
|
||||
PYTHON
|
||||
quiet_system python, "-c", script
|
||||
end
|
||||
|
||||
def self.setup_install_args(prefix)
|
||||
shim = <<~EOS
|
||||
shim = <<~PYTHON
|
||||
import setuptools, tokenize
|
||||
__file__ = 'setup.py'
|
||||
exec(compile(getattr(tokenize, 'open', open)(__file__).read()
|
||||
.replace('\\r\\n', '\\n'), __file__, 'exec'))
|
||||
EOS
|
||||
PYTHON
|
||||
%W[
|
||||
-c
|
||||
#{shim}
|
||||
|
||||
@ -138,7 +138,7 @@ class Sandbox
|
||||
end
|
||||
|
||||
class SandboxProfile
|
||||
SEATBELT_ERB = <<~EOS.freeze
|
||||
SEATBELT_ERB = <<~ERB.freeze
|
||||
(version 1)
|
||||
(debug deny) ; log all denied operations to /var/log/system.log
|
||||
<%= rules.join("\n") %>
|
||||
@ -157,7 +157,7 @@ class Sandbox
|
||||
(with no-sandbox)
|
||||
) ; allow certain processes running without sandbox
|
||||
(allow default) ; allow everything else
|
||||
EOS
|
||||
ERB
|
||||
|
||||
attr_reader :rules
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ describe Hbc::Artifact::Pkg, :cask do
|
||||
|
||||
file = double(path: Pathname.new("/tmp/choices.xml"))
|
||||
|
||||
expect(file).to receive(:write).with(<<~EOS)
|
||||
expect(file).to receive(:write).with <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
@ -49,7 +49,7 @@ describe Hbc::Artifact::Pkg, :cask do
|
||||
\t</dict>
|
||||
</array>
|
||||
</plist>
|
||||
EOS
|
||||
XML
|
||||
|
||||
expect(file).to receive(:close)
|
||||
expect(file).to receive(:unlink)
|
||||
|
||||
@ -3,55 +3,55 @@ describe Hbc::CaskLoader::FromContentLoader do
|
||||
|
||||
describe "::can_load?" do
|
||||
it "returns true for Casks specified with `cask \"token\" do … end`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask "token" do
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask \"token\" do; end`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask "token" do; end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask 'token' do … end`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask 'token' do
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask 'token' do; end`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask 'token' do; end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask(\"token\") { … }`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask("token") {
|
||||
}
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask(\"token\") {}`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask("token") {}
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask('token') { … }`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask('token') {
|
||||
}
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "returns true for Casks specified with `cask('token') {}`" do
|
||||
expect(described_class).to be_able_to_load <<~EOS
|
||||
expect(described_class).to be_able_to_load <<~RUBY
|
||||
cask('token') {}
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -11,11 +11,11 @@ describe Hbc::CaskLoader::FromURILoader do
|
||||
end
|
||||
|
||||
it "returns false when given a String with Cask contents containing a URL" do
|
||||
expect(described_class).not_to be_able_to_load <<~EOS
|
||||
expect(described_class).not_to be_able_to_load <<~RUBY
|
||||
cask 'token' do
|
||||
url 'http://example.com/'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ describe Hbc::CLI::Cat, :cask do
|
||||
|
||||
describe "given a basic Cask" do
|
||||
let(:basic_cask_content) {
|
||||
<<~EOS
|
||||
<<~RUBY
|
||||
cask 'basic-cask' do
|
||||
version '1.2.3'
|
||||
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
|
||||
@ -17,7 +17,7 @@ describe Hbc::CLI::Cat, :cask do
|
||||
|
||||
app 'TestCask.app'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
}
|
||||
|
||||
it "displays the Cask file content about the specified Cask" do
|
||||
|
||||
@ -28,7 +28,7 @@ describe Hbc::CLI::Create, :cask do
|
||||
it "drops a template down for the specified Cask" do
|
||||
described_class.run("new-cask")
|
||||
template = File.read(Hbc::CaskLoader.path("new-cask"))
|
||||
expect(template).to eq <<~EOS
|
||||
expect(template).to eq <<~RUBY
|
||||
cask 'new-cask' do
|
||||
version ''
|
||||
sha256 ''
|
||||
@ -39,7 +39,7 @@ describe Hbc::CLI::Create, :cask do
|
||||
|
||||
app ''
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "raises an exception when more than one Cask is given" do
|
||||
|
||||
@ -109,11 +109,11 @@ describe Hbc::CLI::Uninstall, :cask do
|
||||
timestamped_versions.each do |timestamped_version|
|
||||
caskroom_path.join(".metadata", *timestamped_version, "Casks").tap(&:mkpath)
|
||||
.join("#{token}.rb").open("w") do |caskfile|
|
||||
caskfile.puts <<~EOS
|
||||
caskfile.puts <<~RUBY
|
||||
cask '#{token}' do
|
||||
version '#{timestamped_version[0]}'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
caskroom_path.join(timestamped_version[0]).mkpath
|
||||
end
|
||||
@ -155,13 +155,13 @@ describe Hbc::CLI::Uninstall, :cask do
|
||||
|
||||
saved_caskfile.dirname.mkpath
|
||||
|
||||
IO.write saved_caskfile, <<~EOS
|
||||
IO.write saved_caskfile, <<~RUBY
|
||||
cask 'ive-been-renamed' do
|
||||
version :latest
|
||||
|
||||
app 'ive-been-renamed.app'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "can still uninstall those Casks" do
|
||||
|
||||
@ -123,7 +123,7 @@ describe Hbc::Pkg, :cask do
|
||||
end
|
||||
|
||||
let(:pkg_info_plist) do
|
||||
<<~EOS
|
||||
<<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
@ -138,7 +138,7 @@ describe Hbc::Pkg, :cask do
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
EOS
|
||||
XML
|
||||
end
|
||||
|
||||
it "correctly parses a Property List" do
|
||||
|
||||
@ -17,7 +17,7 @@ describe Hbc::SystemCommand::Result, :cask do
|
||||
EOS
|
||||
}
|
||||
let(:plist) {
|
||||
<<~EOS
|
||||
<<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
@ -61,7 +61,7 @@ describe Hbc::SystemCommand::Result, :cask do
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
EOS
|
||||
XML
|
||||
}
|
||||
|
||||
context "when stdout contains garbage before XML" do
|
||||
|
||||
@ -4,10 +4,10 @@ describe "brew custom-external-command", :integration_test do
|
||||
cmd = "custom-external-command-#{rand}"
|
||||
file = path/"brew-#{cmd}"
|
||||
|
||||
file.write <<~EOS
|
||||
file.write <<~SH
|
||||
#!/bin/sh
|
||||
echo 'I am #{cmd}.'
|
||||
EOS
|
||||
SH
|
||||
FileUtils.chmod "+x", file
|
||||
|
||||
expect { brew cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
|
||||
|
||||
@ -26,9 +26,9 @@ describe "brew install", :integration_test do
|
||||
end
|
||||
|
||||
specify "install failures" do
|
||||
path = setup_test_formula "testball1", <<~EOS
|
||||
path = setup_test_formula "testball1", <<~RUBY
|
||||
version "1.0"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
|
||||
@ -36,7 +36,7 @@ describe "brew install", :integration_test do
|
||||
.and be_a_success
|
||||
|
||||
FileUtils.rm path
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
version "2.0"
|
||||
|
||||
devel do
|
||||
@ -44,7 +44,7 @@ describe "brew install", :integration_test do
|
||||
sha256 "#{Formulary.factory("testball1").stable.checksum.hexdigest}"
|
||||
version "3.0"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(/`brew upgrade testball1`/).to_stderr
|
||||
@ -90,11 +90,11 @@ describe "brew install", :integration_test do
|
||||
end
|
||||
|
||||
it "can install keg-only Formulae" do
|
||||
path_keg_only = setup_test_formula "testball1", <<~EOS
|
||||
path_keg_only = setup_test_formula "testball1", <<~RUBY
|
||||
version "1.0"
|
||||
|
||||
keg_only "test reason"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
|
||||
@ -102,11 +102,11 @@ describe "brew install", :integration_test do
|
||||
.and be_a_success
|
||||
|
||||
FileUtils.rm path_keg_only
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
version "2.0"
|
||||
|
||||
keg_only "test reason"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(/testball1 1.0 is already installed/).to_stderr
|
||||
@ -132,7 +132,7 @@ describe "brew install", :integration_test do
|
||||
system "git", "commit", "-m", "Initial repo commit"
|
||||
end
|
||||
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
version "1.0"
|
||||
|
||||
head "file://#{repo_path}", :using => :git
|
||||
@ -140,7 +140,7 @@ describe "brew install", :integration_test do
|
||||
def install
|
||||
prefix.install Dir["*"]
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
# Ignore dependencies, because we'll try to resolve requirements in build.rb
|
||||
# and there will be the git requirement, but we cannot instantiate git
|
||||
@ -175,13 +175,13 @@ describe "brew install", :integration_test do
|
||||
end
|
||||
|
||||
it "succeeds when a non-fatal requirement isn't satisfied" do
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
class NonFatalRequirement < Requirement
|
||||
satisfy(build_env: false) { false }
|
||||
end
|
||||
|
||||
depends_on NonFatalRequirement
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(/NonFatalRequirement unsatisfied!/).to_stderr
|
||||
@ -190,14 +190,14 @@ describe "brew install", :integration_test do
|
||||
end
|
||||
|
||||
it "fails when a fatal requirement isn't satisfied" do
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
class FatalRequirement < Requirement
|
||||
fatal true
|
||||
satisfy { false }
|
||||
end
|
||||
|
||||
depends_on FatalRequirement
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(/FatalRequirement unsatisfied!/).to_stderr
|
||||
|
||||
@ -3,11 +3,11 @@ describe "brew irb", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
irb_test = HOMEBREW_TEMP/"irb-test.rb"
|
||||
irb_test.write <<~EOS
|
||||
irb_test.write <<~RUBY
|
||||
"testball".f
|
||||
:testball.f
|
||||
exit
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "irb", irb_test }
|
||||
.to output(/Interactive Homebrew Shell/).to_stdout
|
||||
|
||||
@ -29,9 +29,9 @@ describe "brew link", :integration_test do
|
||||
end
|
||||
|
||||
it "refuses to link keg-only Formulae" do
|
||||
setup_test_formula "testball1", <<~EOS
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
keg_only "just because"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }.to be_a_success
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
describe "brew options", :integration_test do
|
||||
it "prints a given Formula's options" do
|
||||
setup_test_formula "testball", <<~EOS
|
||||
setup_test_formula "testball", <<~RUBY
|
||||
depends_on "bar" => :recommended
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "options", "testball" }
|
||||
.to output("--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support\n\n").to_stdout
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
describe "brew switch", :integration_test do
|
||||
it "allows switching between Formula versions" do
|
||||
setup_test_formula "testball", <<~EOS
|
||||
setup_test_formula "testball", <<~RUBY
|
||||
keg_only "just because"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball" }.to be_a_success
|
||||
|
||||
|
||||
@ -2,10 +2,10 @@ describe "brew uses", :integration_test do
|
||||
it "prints the Formulae a given Formula is used by" do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
setup_test_formula "baz", <<~EOS
|
||||
setup_test_formula "baz", <<~RUBY
|
||||
url "https://example.com/baz-1.0"
|
||||
depends_on "bar"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "uses", "baz" }
|
||||
.to be_a_success
|
||||
|
||||
@ -2,10 +2,10 @@ describe "brew deps", :integration_test do
|
||||
before do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
setup_test_formula "baz", <<~EOS
|
||||
setup_test_formula "baz", <<~RUBY
|
||||
url "https://example.com/baz-1.0"
|
||||
depends_on "bar"
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "outputs no dependencies for a Formula that has no dependencies" do
|
||||
|
||||
@ -19,20 +19,20 @@ module Homebrew
|
||||
def formula_text(name, body = nil, options = {})
|
||||
path = dir/"#{name}.rb"
|
||||
|
||||
path.write <<~EOS
|
||||
path.write <<~RUBY
|
||||
class #{Formulary.class_s(name)} < Formula
|
||||
#{body}
|
||||
end
|
||||
#{options[:patch]}
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
described_class.new(path)
|
||||
end
|
||||
|
||||
specify "simple valid Formula" do
|
||||
ft = formula_text "valid", <<~EOS
|
||||
ft = formula_text "valid", <<~RUBY
|
||||
url "http://www.example.com/valid-1.0.tar.gz"
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect(ft).not_to have_data
|
||||
expect(ft).not_to have_end
|
||||
@ -50,9 +50,9 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "#data?" do
|
||||
ft = formula_text "data", <<~EOS
|
||||
ft = formula_text "data", <<~RUBY
|
||||
patch :DATA
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect(ft).to have_data
|
||||
end
|
||||
@ -78,11 +78,11 @@ module Homebrew
|
||||
|
||||
describe "#problems" do
|
||||
it "is empty by default" do
|
||||
fa = formula_auditor "foo", <<~EOS
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect(fa.problems).to be_empty
|
||||
end
|
||||
@ -92,11 +92,11 @@ module Homebrew
|
||||
specify "file permissions" do
|
||||
allow(File).to receive(:umask).and_return(022)
|
||||
|
||||
fa = formula_auditor "foo", <<~EOS
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
path = fa.formula.path
|
||||
path.chmod 0400
|
||||
@ -107,25 +107,25 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "DATA but no __END__" do
|
||||
fa = formula_auditor "foo", <<~EOS
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
patch :DATA
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_file
|
||||
expect(fa.problems).to eq(["'DATA' was found, but no '__END__'"])
|
||||
end
|
||||
|
||||
specify "__END__ but no DATA" do
|
||||
fa = formula_auditor "foo", <<~EOS
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
__END__
|
||||
a patch goes here
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_file
|
||||
expect(fa.problems).to eq(["'__END__' was found, but 'DATA' is not used"])
|
||||
@ -139,12 +139,12 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "no issue" do
|
||||
fa = formula_auditor "foo", <<~EOS
|
||||
fa = formula_auditor "foo", <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
homepage "http://example.com"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_file
|
||||
expect(fa.problems).to eq([])
|
||||
@ -153,11 +153,11 @@ module Homebrew
|
||||
|
||||
describe "#line_problems" do
|
||||
specify "pkgshare" do
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.line_problems 'ohai "#{share}/foo"', 3
|
||||
expect(fa.problems.shift).to eq("Use \#{pkgshare} instead of \#{share}/foo")
|
||||
@ -185,12 +185,12 @@ module Homebrew
|
||||
# Formulae with "++" in their name would break various audit regexps:
|
||||
# Error: nested *?+ in regexp: /^libxml++3\s/
|
||||
specify "++ in name" do
|
||||
fa = formula_auditor "foolibc++", <<~EOS, strict: true
|
||||
fa = formula_auditor "foolibc++", <<~RUBY, strict: true
|
||||
class Foolibcxx < Formula
|
||||
desc "foolibc++ is a test"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.line_problems 'ohai "#{share}/foolibc++"', 3
|
||||
expect(fa.problems.shift)
|
||||
@ -206,12 +206,12 @@ module Homebrew
|
||||
specify "#audit_github_repository when HOMEBREW_NO_GITHUB_API is set" do
|
||||
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
|
||||
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true, online: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true, online: true
|
||||
class Foo < Formula
|
||||
homepage "https://github.com/example/example"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_github_repository
|
||||
expect(fa.problems).to eq([])
|
||||
@ -224,14 +224,14 @@ module Homebrew
|
||||
subject { fa }
|
||||
|
||||
let(:fa) do
|
||||
formula_auditor "foo", <<~EOS, new_formula: true
|
||||
formula_auditor "foo", <<~RUBY, new_formula: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
homepage "http://example.com"
|
||||
|
||||
depends_on "openssl"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:f_openssl) do
|
||||
@ -256,14 +256,14 @@ module Homebrew
|
||||
subject { fa }
|
||||
|
||||
let(:fa) do
|
||||
formula_auditor "foo", <<~EOS, new_formula: true
|
||||
formula_auditor "foo", <<~RUBY, new_formula: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
homepage "http://example.com"
|
||||
|
||||
depends_on "bc"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:f_bc) do
|
||||
@ -288,13 +288,13 @@ module Homebrew
|
||||
|
||||
describe "#audit_keg_only_style" do
|
||||
specify "keg_only_needs_downcasing" do
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
|
||||
keg_only "Because why not"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_keg_only_style
|
||||
expect(fa.problems)
|
||||
@ -302,13 +302,13 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "keg_only_redundant_period" do
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
|
||||
keg_only "because this line ends in a period."
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_keg_only_style
|
||||
expect(fa.problems)
|
||||
@ -316,7 +316,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "keg_only_handles_block_correctly" do
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
|
||||
@ -327,7 +327,7 @@ module Homebrew
|
||||
problem
|
||||
EOF
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_keg_only_style
|
||||
expect(fa.problems)
|
||||
@ -335,13 +335,13 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "keg_only_handles_whitelist_correctly" do
|
||||
fa = formula_auditor "foo", <<~EOS, strict: true
|
||||
fa = formula_auditor "foo", <<~RUBY, strict: true
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
|
||||
keg_only "Apple ships foo in the CLT package"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_keg_only_style
|
||||
expect(fa.problems)
|
||||
@ -364,13 +364,13 @@ module Homebrew
|
||||
let(:formula_path) { tap_path/formula_subpath }
|
||||
|
||||
before do
|
||||
origin_formula_path.write <<~EOS
|
||||
origin_formula_path.write <<~RUBY
|
||||
class Foo#{foo_version} < Formula
|
||||
url "https://example.com/foo-1.0.tar.gz"
|
||||
revision 2
|
||||
version_scheme 1
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
origin_tap_path.mkpath
|
||||
origin_tap_path.cd do
|
||||
@ -525,11 +525,11 @@ module Homebrew
|
||||
|
||||
describe "#audit_url_is_not_binary" do
|
||||
specify "it detects a url containing darwin and x86_64" do
|
||||
fa = formula_auditor "foo", <<~EOS, official_tap: true
|
||||
fa = formula_auditor "foo", <<~RUBY, official_tap: true
|
||||
class Foo < Formula
|
||||
url "https://example.com/example-darwin.x86_64.tar.gz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_url_is_not_binary
|
||||
|
||||
@ -538,11 +538,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it detects a url containing darwin and amd64" do
|
||||
fa = formula_auditor "foo", <<~EOS, official_tap: true
|
||||
fa = formula_auditor "foo", <<~RUBY, official_tap: true
|
||||
class Foo < Formula
|
||||
url "https://example.com/example-darwin.amd64.tar.gz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_url_is_not_binary
|
||||
|
||||
@ -551,7 +551,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it works on the devel spec" do
|
||||
fa = formula_auditor "foo", <<~EOS, official_tap: true
|
||||
fa = formula_auditor "foo", <<~RUBY, official_tap: true
|
||||
class Foo < Formula
|
||||
url "https://example.com/valid-1.0.tar.gz"
|
||||
|
||||
@ -559,7 +559,7 @@ module Homebrew
|
||||
url "https://example.com/example-darwin.x86_64.tar.gz"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_url_is_not_binary
|
||||
|
||||
@ -568,7 +568,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it works on the head spec" do
|
||||
fa = formula_auditor "foo", <<~EOS, official_tap: true
|
||||
fa = formula_auditor "foo", <<~RUBY, official_tap: true
|
||||
class Foo < Formula
|
||||
url "https://example.com/valid-1.0.tar.gz"
|
||||
|
||||
@ -576,7 +576,7 @@ module Homebrew
|
||||
url "https://example.com/example-darwin.x86_64.tar.gz"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_url_is_not_binary
|
||||
|
||||
@ -585,7 +585,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
specify "it ignores resource urls" do
|
||||
fa = formula_auditor "foo", <<~EOS, official_tap: true
|
||||
fa = formula_auditor "foo", <<~RUBY, official_tap: true
|
||||
class Foo < Formula
|
||||
url "https://example.com/valid-1.0.tar.gz"
|
||||
|
||||
@ -593,7 +593,7 @@ module Homebrew
|
||||
url "https://example.com/example-darwin.x86_64.tar.gz"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
fa.audit_url_is_not_binary
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe "brew test", :integration_test do
|
||||
it "tests a given Formula" do
|
||||
setup_test_formula "testball", <<~EOS
|
||||
setup_test_formula "testball", <<~RUBY
|
||||
head "https://github.com/example/testball2.git"
|
||||
|
||||
devel do
|
||||
@ -12,7 +12,7 @@ describe "brew test", :integration_test do
|
||||
|
||||
test do
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball" }.to be_a_success
|
||||
|
||||
|
||||
@ -100,12 +100,12 @@ describe FormulaInstaller do
|
||||
specify "check installation sanity pinned dependency" do
|
||||
dep_name = "dependency"
|
||||
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
||||
dep_path.write <<~EOS
|
||||
dep_path.write <<~RUBY
|
||||
class #{Formulary.class_s(dep_name)} < Formula
|
||||
url "foo"
|
||||
version "0.2"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
Formulary.cache.delete(dep_path)
|
||||
dependency = Formulary.factory(dep_name)
|
||||
|
||||
@ -6,7 +6,7 @@ describe Formulary do
|
||||
let(:formula_name) { "testball_bottle" }
|
||||
let(:formula_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" }
|
||||
let(:formula_content) do
|
||||
<<~EOS
|
||||
<<~RUBY
|
||||
class #{described_class.class_s(formula_name)} < Formula
|
||||
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
||||
sha256 TESTBALL_SHA256
|
||||
@ -22,7 +22,7 @@ describe Formulary do
|
||||
prefix.install "libexec"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
let(:bottle_dir) { Pathname.new("#{TEST_FIXTURE_DIR}/bottles") }
|
||||
let(:bottle) { bottle_dir/"testball_bottle-0.1.#{Utils::Bottles.tag}.bottle.tar.gz" }
|
||||
@ -81,10 +81,10 @@ describe Formulary do
|
||||
context "when the Formula has the wrong class" do
|
||||
let(:formula_name) { "giraffe" }
|
||||
let(:formula_content) do
|
||||
<<~EOS
|
||||
<<~RUBY
|
||||
class Wrong#{described_class.class_s(formula_name)} < Formula
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "raises an error" do
|
||||
|
||||
@ -53,10 +53,10 @@ describe JavaRequirement do
|
||||
let(:java) { path/"java" }
|
||||
|
||||
def setup_java_with_version(version)
|
||||
IO.write java, <<~EOS
|
||||
IO.write java, <<~SH
|
||||
#!/bin/sh
|
||||
echo 'java version "#{version}"'
|
||||
EOS
|
||||
SH
|
||||
FileUtils.chmod "+x", java
|
||||
end
|
||||
|
||||
|
||||
@ -86,9 +86,9 @@ describe Homebrew::MissingFormula do
|
||||
Tap.clear_cache
|
||||
tap_path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
tap_path.mkpath
|
||||
(tap_path/"tap_migrations.json").write <<~EOS
|
||||
(tap_path/"tap_migrations.json").write <<~JSON
|
||||
{ "migrated-formula": "homebrew/bar" }
|
||||
EOS
|
||||
JSON
|
||||
end
|
||||
|
||||
context "with a migrated formula" do
|
||||
|
||||
@ -111,7 +111,7 @@ describe RuboCop::Cop::FormulaAudit::ChecksumCase do
|
||||
|
||||
context "When auditing checksum with autocorrect" do
|
||||
it "When there is uppercase sha256" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
stable do
|
||||
@ -124,9 +124,9 @@ describe RuboCop::Cop::FormulaAudit::ChecksumCase do
|
||||
end
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = <<~EOS
|
||||
corrected_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
stable do
|
||||
@ -139,7 +139,7 @@ describe RuboCop::Cop::FormulaAudit::ChecksumCase do
|
||||
end
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
new_source = autocorrect_source(source)
|
||||
expect(new_source).to eq(corrected_source)
|
||||
|
||||
@ -31,17 +31,17 @@ describe RuboCop::Cop::FormulaAudit::ClassName do
|
||||
end
|
||||
|
||||
it "supports auto-correcting deprecated parent classes" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < AmazonWebServicesFormula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = <<~EOS
|
||||
corrected_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
new_source = autocorrect_source(source)
|
||||
expect(new_source).to eq(corrected_source)
|
||||
|
||||
@ -62,26 +62,26 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
|
||||
|
||||
context "When auditing formula components order with autocorrect" do
|
||||
it "When url precedes homepage" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
homepage "http://example.com"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
correct_source = <<~EOS
|
||||
correct_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "http://example.com"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = autocorrect_source(source)
|
||||
expect(corrected_source).to eq(correct_source)
|
||||
end
|
||||
|
||||
it "When `resource` precedes `depends_on`" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url "https://example.com/foo-1.0.tgz"
|
||||
|
||||
@ -91,9 +91,9 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
|
||||
|
||||
depends_on "openssl"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
correct_source = <<~EOS
|
||||
correct_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url "https://example.com/foo-1.0.tgz"
|
||||
|
||||
@ -103,7 +103,7 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
|
||||
url "https://example.com/foo-2.0.tgz"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = autocorrect_source(source)
|
||||
expect(corrected_source).to eq(correct_source)
|
||||
|
||||
@ -74,23 +74,23 @@ describe RuboCop::Cop::NewFormulaAudit::DependencyOrder do
|
||||
|
||||
context "autocorrect" do
|
||||
it "wrong conditional depends_on order" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "http://example.com"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
depends_on "apple" if build.with? "foo"
|
||||
depends_on "foo" => :optional
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
correct_source = <<~EOS
|
||||
correct_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "http://example.com"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
depends_on "foo" => :optional
|
||||
depends_on "apple" if build.with? "foo"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = autocorrect_source(source)
|
||||
expect(corrected_source).to eq(correct_source)
|
||||
|
||||
@ -102,19 +102,19 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do
|
||||
end
|
||||
|
||||
it "autocorrects all rules" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
desc ' an bar: commandline foo '
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
correct_source = <<~EOS
|
||||
correct_source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
desc 'an bar: command-line'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
corrected_source = autocorrect_source(source, "/homebrew-core/Formula/foo.rb")
|
||||
expect(corrected_source).to eq(correct_source)
|
||||
|
||||
@ -5,11 +5,11 @@ describe RuboCop::Cop::FormulaAudit::Homepage do
|
||||
|
||||
context "When auditing homepage" do
|
||||
it "When there is no homepage" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expected_offenses = [{ message: "Formula should have a homepage.",
|
||||
severity: :convention,
|
||||
@ -25,12 +25,12 @@ describe RuboCop::Cop::FormulaAudit::Homepage do
|
||||
end
|
||||
|
||||
it "Homepage with ftp" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "ftp://example.com/foo"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expected_offenses = [{ message: "The homepage should start with http or https (URL is ftp://example.com/foo).",
|
||||
severity: :convention,
|
||||
@ -62,12 +62,12 @@ describe RuboCop::Cop::FormulaAudit::Homepage do
|
||||
}
|
||||
|
||||
formula_homepages.each do |name, homepage|
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class #{name.capitalize} < Formula
|
||||
homepage "#{homepage}"
|
||||
url "http://example.com/#{name}-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
inspect_source(source)
|
||||
if homepage =~ %r{http:\/\/www\.freedesktop\.org}
|
||||
|
||||
@ -113,7 +113,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
||||
end
|
||||
|
||||
it "Formula with nested `def patches`" do
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "ftp://example.com/foo"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
@ -125,7 +125,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
||||
}
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
expected_offenses = [{ message: "Use the patch DSL instead of defining a 'patches' method",
|
||||
severity: :convention,
|
||||
@ -162,7 +162,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
||||
"https://patch-diff.githubusercontent.com/raw/foo/foo-bar/pull/100.patch",
|
||||
]
|
||||
patch_urls.each do |patch_url|
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
homepage "ftp://example.com/foo"
|
||||
url "http://example.com/foo-1.0.tgz"
|
||||
@ -171,7 +171,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
||||
sha256 "63376b8fdd6613a91976106d9376069274191860cd58f039b29ff16de1925621"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
inspect_source(source)
|
||||
expected_offense = if patch_url =~ %r{/raw\.github\.com/}
|
||||
|
||||
@ -111,12 +111,12 @@ describe RuboCop::Cop::FormulaAudit::Urls do
|
||||
"col" => 2,
|
||||
}]
|
||||
formulas.each do |formula|
|
||||
source = <<~EOS
|
||||
source = <<~RUBY
|
||||
class Foo < Formula
|
||||
desc "foo"
|
||||
url "#{formula["url"]}"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
expected_offenses = [{ message: formula["msg"],
|
||||
severity: :convention,
|
||||
line: 3,
|
||||
|
||||
@ -8,10 +8,10 @@ cask 'with-uninstall-script-app' do
|
||||
app 'MyFancyApp/MyFancyApp.app'
|
||||
|
||||
postflight do
|
||||
IO.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~EOS
|
||||
IO.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||
#!/bin/sh
|
||||
/bin/rm -r "#{appdir}/MyFancyApp.app"
|
||||
EOS
|
||||
SH
|
||||
end
|
||||
|
||||
uninstall script: {
|
||||
|
||||
@ -127,7 +127,7 @@ RSpec.shared_context "integration test" do
|
||||
else
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz"
|
||||
end
|
||||
content = <<~EOS
|
||||
content = <<~RUBY
|
||||
desc "Some test"
|
||||
homepage "https://example.com/#{name}"
|
||||
url "file://#{tarball}"
|
||||
@ -147,24 +147,24 @@ RSpec.shared_context "integration test" do
|
||||
#{content}
|
||||
|
||||
# something here
|
||||
EOS
|
||||
RUBY
|
||||
when "foo"
|
||||
content = <<~EOS
|
||||
content = <<~RUBY
|
||||
url "https://example.com/#{name}-1.0"
|
||||
EOS
|
||||
RUBY
|
||||
when "bar"
|
||||
content = <<~EOS
|
||||
content = <<~RUBY
|
||||
url "https://example.com/#{name}-1.0"
|
||||
depends_on "foo"
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
|
||||
Formulary.core_path(name).tap do |formula_path|
|
||||
formula_path.write <<~EOS
|
||||
formula_path.write <<~RUBY
|
||||
class #{Formulary.class_s(name)} < Formula
|
||||
#{content}
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -18,22 +18,22 @@ describe Tap do
|
||||
end
|
||||
|
||||
def setup_tap_files
|
||||
formula_file.write <<~EOS
|
||||
formula_file.write <<~RUBY
|
||||
class Foo < Formula
|
||||
url "https://example.com/foo-1.0.tar.gz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
alias_file.parent.mkpath
|
||||
ln_s formula_file, alias_file
|
||||
|
||||
(path/"formula_renames.json").write <<~EOS
|
||||
(path/"formula_renames.json").write <<~JSON
|
||||
{ "oldname": "foo" }
|
||||
EOS
|
||||
JSON
|
||||
|
||||
(path/"tap_migrations.json").write <<~EOS
|
||||
(path/"tap_migrations.json").write <<~JSON
|
||||
{ "removed-formula": "homebrew/foo" }
|
||||
EOS
|
||||
JSON
|
||||
|
||||
[
|
||||
cmd_file,
|
||||
@ -350,11 +350,11 @@ describe CoreTap do
|
||||
|
||||
specify "files" do
|
||||
formula_file = subject.formula_dir/"foo.rb"
|
||||
formula_file.write <<~EOS
|
||||
formula_file.write <<~RUBY
|
||||
class Foo < Formula
|
||||
url "https://example.com/foo-1.0.tar.gz"
|
||||
end
|
||||
EOS
|
||||
RUBY
|
||||
|
||||
alias_file = subject.alias_dir/"bar"
|
||||
alias_file.parent.mkpath
|
||||
|
||||
@ -92,10 +92,10 @@ describe "globally-scoped helper methods" do
|
||||
let(:shell) { dir/"myshell" }
|
||||
|
||||
it "starts an interactive shell session" do
|
||||
IO.write shell, <<~EOS
|
||||
IO.write shell, <<~SH
|
||||
#!/bin/sh
|
||||
echo called > "#{dir}/called"
|
||||
EOS
|
||||
SH
|
||||
|
||||
FileUtils.chmod 0755, shell
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user