test: avoid improper, late usage of formula DSL

This commit is contained in:
Bo Anderson 2022-08-24 23:52:40 +01:00
parent 88a8def34c
commit 15280ba107
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
9 changed files with 328 additions and 218 deletions

View File

@ -30,11 +30,16 @@ describe BuildEnvironment do
end end
describe BuildEnvironment::DSL do describe BuildEnvironment::DSL do
subject(:build_environment_dsl) { double.extend(described_class) } let(:build_environment_dsl) do
klass = described_class
Class.new do
extend(klass)
end
end
context "with a single argument" do context "with a single argument" do
before do subject do
build_environment_dsl.instance_eval do Class.new(build_environment_dsl) do
env :std env :std
end end
end end

View File

@ -7,15 +7,15 @@ require "formula"
describe Cleaner do describe Cleaner do
include FileUtils include FileUtils
subject(:cleaner) { described_class.new(f) }
let(:f) { formula("cleaner_test") { url "foo-1.0" } }
before do
f.prefix.mkpath
end
describe "#clean" do describe "#clean" do
subject(:cleaner) { described_class.new(f) }
let(:f) { formula("cleaner_test") { url "foo-1.0" } }
before do
f.prefix.mkpath
end
it "cleans files" do it "cleans files" do
f.bin.mkpath f.bin.mkpath
f.lib.mkpath f.lib.mkpath
@ -159,45 +159,54 @@ describe Cleaner do
end end
describe "::skip_clean" do describe "::skip_clean" do
def stub_formula_skip_clean(skip_paths)
formula("cleaner_test") do
url "foo-1.0"
skip_clean skip_paths
end
end
it "adds paths that should be skipped" do it "adds paths that should be skipped" do
f.class.skip_clean "bin" f = stub_formula_skip_clean("bin")
f.bin.mkpath f.bin.mkpath
cleaner.clean described_class.new(f).clean
expect(f.bin).to be_a_directory expect(f.bin).to be_a_directory
end end
it "also skips empty sub-directories under the added paths" do it "also skips empty sub-directories under the added paths" do
f.class.skip_clean "bin" f = stub_formula_skip_clean("bin")
subdir = f.bin/"subdir" subdir = f.bin/"subdir"
subdir.mkpath subdir.mkpath
cleaner.clean described_class.new(f).clean
expect(f.bin).to be_a_directory expect(f.bin).to be_a_directory
expect(subdir).to be_a_directory expect(subdir).to be_a_directory
end end
it "allows skipping broken symlinks" do it "allows skipping broken symlinks" do
f.class.skip_clean "symlink" f = stub_formula_skip_clean("symlink")
f.prefix.mkpath
symlink = f.prefix/"symlink" symlink = f.prefix/"symlink"
ln_s "target", symlink ln_s "target", symlink
cleaner.clean described_class.new(f).clean
expect(symlink).to be_a_symlink expect(symlink).to be_a_symlink
end end
it "allows skipping symlinks pointing to an empty directory" do it "allows skipping symlinks pointing to an empty directory" do
f.class.skip_clean "c" f = stub_formula_skip_clean("c")
dir = f.prefix/"b" dir = f.prefix/"b"
symlink = f.prefix/"c" symlink = f.prefix/"c"
dir.mkpath dir.mkpath
ln_s dir.basename, symlink ln_s dir.basename, symlink
cleaner.clean described_class.new(f).clean
expect(dir).not_to exist expect(dir).not_to exist
expect(symlink).to be_a_symlink expect(symlink).to be_a_symlink
@ -205,14 +214,14 @@ describe Cleaner do
end end
it "allows skipping symlinks whose target was pruned before" do it "allows skipping symlinks whose target was pruned before" do
f.class.skip_clean "a" f = stub_formula_skip_clean("a")
dir = f.prefix/"b" dir = f.prefix/"b"
symlink = f.prefix/"a" symlink = f.prefix/"a"
dir.mkpath dir.mkpath
ln_s dir.basename, symlink ln_s dir.basename, symlink
cleaner.clean described_class.new(f).clean
expect(dir).not_to exist expect(dir).not_to exist
expect(symlink).to be_a_symlink expect(symlink).to be_a_symlink
@ -220,37 +229,40 @@ describe Cleaner do
end end
it "allows skipping '.la' files" do it "allows skipping '.la' files" do
f = stub_formula_skip_clean(:la)
file = f.lib/"foo.la" file = f.lib/"foo.la"
f.class.skip_clean :la
f.lib.mkpath f.lib.mkpath
touch file touch file
cleaner.clean described_class.new(f).clean
expect(file).to exist expect(file).to exist
end end
it "allows skipping sub-directories" do it "allows skipping sub-directories" do
f = stub_formula_skip_clean("lib/subdir")
dir = f.lib/"subdir" dir = f.lib/"subdir"
f.class.skip_clean "lib/subdir"
dir.mkpath dir.mkpath
cleaner.clean described_class.new(f).clean
expect(dir).to be_a_directory expect(dir).to be_a_directory
end end
it "allows skipping paths relative to prefix" do it "allows skipping paths relative to prefix" do
f = stub_formula_skip_clean("bin/a")
dir1 = f.bin/"a" dir1 = f.bin/"a"
dir2 = f.lib/"bin/a" dir2 = f.lib/"bin/a"
f.class.skip_clean "bin/a"
dir1.mkpath dir1.mkpath
dir2.mkpath dir2.mkpath
cleaner.clean described_class.new(f).clean
expect(dir1).to exist expect(dir1).to exist
expect(dir2).not_to exist expect(dir2).not_to exist

View File

@ -832,15 +832,15 @@ describe Formula do
specify "service complicated" do specify "service complicated" do
f = formula do f = formula do
url "https://brew.sh/test-1.0.tbz" url "https://brew.sh/test-1.0.tbz"
end
f.class.service do service do
run [opt_bin/"beanstalkd"] run [opt_bin/"beanstalkd"]
run_type :immediate run_type :immediate
error_log_path var/"log/beanstalkd.error.log" error_log_path var/"log/beanstalkd.error.log"
log_path var/"log/beanstalkd.log" log_path var/"log/beanstalkd.log"
working_dir var working_dir var
keep_alive true keep_alive true
end
end end
expect(f.service).not_to be_nil expect(f.service).not_to be_nil
end end

View File

@ -98,11 +98,15 @@ describe Homebrew::Livecheck do
describe "::livecheck_url_to_string" do describe "::livecheck_url_to_string" do
let(:f_livecheck_url) do let(:f_livecheck_url) do
homepage_url_s = homepage_url
stable_url_s = stable_url
head_url_s = head_url
formula("test_livecheck_url") do formula("test_livecheck_url") do
desc "Test Livecheck URL formula" desc "Test Livecheck URL formula"
homepage "https://brew.sh" homepage homepage_url_s
url "https://brew.sh/test-0.0.1.tgz" url stable_url_s
head "https://github.com/Homebrew/brew.git" head head_url_s
end end
end end
@ -120,25 +124,15 @@ describe Homebrew::Livecheck do
end end
it "returns a URL string when given a livecheck_url string" do it "returns a URL string when given a livecheck_url string" do
f_livecheck_url.livecheck.url(livecheck_url)
expect(livecheck.livecheck_url_to_string(livecheck_url, f_livecheck_url)).to eq(livecheck_url) expect(livecheck.livecheck_url_to_string(livecheck_url, f_livecheck_url)).to eq(livecheck_url)
end end
it "returns a URL symbol when given a valid livecheck_url symbol" do it "returns a URL symbol when given a valid livecheck_url symbol" do
f_livecheck_url.livecheck.url(:head) expect(livecheck.livecheck_url_to_string(:head, f_livecheck_url)).to eq(head_url)
expect(livecheck.livecheck_url_to_string(head_url, f_livecheck_url)).to eq(head_url) expect(livecheck.livecheck_url_to_string(:homepage, f_livecheck_url)).to eq(homepage_url)
expect(livecheck.livecheck_url_to_string(:homepage, c_livecheck_url)).to eq(homepage_url)
f_livecheck_url.livecheck.url(:homepage) expect(livecheck.livecheck_url_to_string(:stable, f_livecheck_url)).to eq(stable_url)
expect(livecheck.livecheck_url_to_string(homepage_url, f_livecheck_url)).to eq(homepage_url) expect(livecheck.livecheck_url_to_string(:url, c_livecheck_url)).to eq(cask_url)
c_livecheck_url.livecheck.url(:homepage)
expect(livecheck.livecheck_url_to_string(homepage_url, c_livecheck_url)).to eq(homepage_url)
f_livecheck_url.livecheck.url(:stable)
expect(livecheck.livecheck_url_to_string(stable_url, f_livecheck_url)).to eq(stable_url)
c_livecheck_url.livecheck.url(:url)
expect(livecheck.livecheck_url_to_string(cask_url, c_livecheck_url)).to eq(cask_url)
end end
it "returns nil when not given a string or valid symbol" do it "returns nil when not given a string or valid symbol" do

View File

@ -5,26 +5,28 @@ require "formula"
require "service" require "service"
describe Homebrew::Service do describe Homebrew::Service do
let(:klass) do let(:name) { "formula_name" }
Class.new(Formula) do
def stub_formula(&block)
formula(name) do
url "https://brew.sh/test-1.0.tbz" url "https://brew.sh/test-1.0.tbz"
instance_eval(&block) if block
end end
end end
let(:name) { "formula_name" }
let(:path) { Formulary.core_path(name) }
let(:spec) { :stable }
let(:f) { klass.new(name, path, spec) }
describe "#std_service_path_env" do describe "#std_service_path_env" do
it "returns valid std_service_path_env" do it "returns valid std_service_path_env" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :immediate run opt_bin/"beanstalkd"
environment_variables PATH: std_service_path_env run_type :immediate
error_log_path var/"log/beanstalkd.error.log" environment_variables PATH: std_service_path_env
log_path var/"log/beanstalkd.log" error_log_path var/"log/beanstalkd.error.log"
working_dir var log_path var/"log/beanstalkd.log"
keep_alive true working_dir var
keep_alive true
end
end end
path = f.service.std_service_path_env path = f.service.std_service_path_env
@ -34,9 +36,11 @@ describe Homebrew::Service do
describe "#process_type" do describe "#process_type" do
it "throws for unexpected type" do it "throws for unexpected type" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
process_type :cow run opt_bin/"beanstalkd"
process_type :cow
end
end end
expect { expect {
@ -47,9 +51,11 @@ describe Homebrew::Service do
describe "#keep_alive" do describe "#keep_alive" do
it "throws for unexpected keys" do it "throws for unexpected keys" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
keep_alive test: "key" run opt_bin/"beanstalkd"
keep_alive test: "key"
end
end end
expect { expect {
@ -60,9 +66,11 @@ describe Homebrew::Service do
describe "#run_type" do describe "#run_type" do
it "throws for unexpected type" do it "throws for unexpected type" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :cow run opt_bin/"beanstalkd"
run_type :cow
end
end end
expect { expect {
@ -73,9 +81,11 @@ describe Homebrew::Service do
describe "#sockets" do describe "#sockets" do
it "throws for missing type" do it "throws for missing type" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
sockets "127.0.0.1:80" run opt_bin/"beanstalkd"
sockets "127.0.0.1:80"
end
end end
expect { expect {
@ -84,9 +94,11 @@ describe Homebrew::Service do
end end
it "throws for missing host" do it "throws for missing host" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
sockets "tcp://:80" run opt_bin/"beanstalkd"
sockets "tcp://:80"
end
end end
expect { expect {
@ -95,9 +107,11 @@ describe Homebrew::Service do
end end
it "throws for missing port" do it "throws for missing port" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
sockets "tcp://127.0.0.1" run opt_bin/"beanstalkd"
sockets "tcp://127.0.0.1"
end
end end
expect { expect {
@ -108,14 +122,16 @@ describe Homebrew::Service do
describe "#manual_command" do describe "#manual_command" do
it "returns valid manual_command" do it "returns valid manual_command" do
f.class.service do f = stub_formula do
run "#{HOMEBREW_PREFIX}/bin/beanstalkd" service do
run_type :immediate run "#{HOMEBREW_PREFIX}/bin/beanstalkd"
environment_variables PATH: std_service_path_env, ETC_DIR: etc/"beanstalkd" run_type :immediate
error_log_path var/"log/beanstalkd.error.log" environment_variables PATH: std_service_path_env, ETC_DIR: etc/"beanstalkd"
log_path var/"log/beanstalkd.log" error_log_path var/"log/beanstalkd.error.log"
working_dir var log_path var/"log/beanstalkd.log"
keep_alive true working_dir var
keep_alive true
end
end end
path = f.service.manual_command path = f.service.manual_command
@ -123,14 +139,16 @@ describe Homebrew::Service do
end end
it "returns valid manual_command without variables" do it "returns valid manual_command without variables" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :immediate run opt_bin/"beanstalkd"
environment_variables PATH: std_service_path_env run_type :immediate
error_log_path var/"log/beanstalkd.error.log" environment_variables PATH: std_service_path_env
log_path var/"log/beanstalkd.log" error_log_path var/"log/beanstalkd.error.log"
working_dir var log_path var/"log/beanstalkd.log"
keep_alive true working_dir var
keep_alive true
end
end end
path = f.service.manual_command path = f.service.manual_command
@ -140,21 +158,23 @@ describe Homebrew::Service do
describe "#to_plist" do describe "#to_plist" do
it "returns valid plist" do it "returns valid plist" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :immediate run [opt_bin/"beanstalkd", "test"]
environment_variables PATH: std_service_path_env, FOO: "BAR", ETC_DIR: etc/"beanstalkd" run_type :immediate
error_log_path var/"log/beanstalkd.error.log" environment_variables PATH: std_service_path_env, FOO: "BAR", ETC_DIR: etc/"beanstalkd"
log_path var/"log/beanstalkd.log" error_log_path var/"log/beanstalkd.error.log"
input_path var/"in/beanstalkd" log_path var/"log/beanstalkd.log"
root_dir var input_path var/"in/beanstalkd"
working_dir var root_dir var
keep_alive true working_dir var
launch_only_once true keep_alive true
process_type :interactive launch_only_once true
restart_delay 30 process_type :interactive
interval 5 restart_delay 30
macos_legacy_timers true interval 5
macos_legacy_timers true
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -216,9 +236,11 @@ describe Homebrew::Service do
end end
it "returns valid plist with socket" do it "returns valid plist with socket" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
sockets "tcp://127.0.0.1:80" run [opt_bin/"beanstalkd", "test"]
sockets "tcp://127.0.0.1:80"
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -265,9 +287,11 @@ describe Homebrew::Service do
end end
it "returns valid partial plist" do it "returns valid partial plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :immediate run opt_bin/"beanstalkd"
run_type :immediate
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -299,10 +323,12 @@ describe Homebrew::Service do
end end
it "returns valid interval plist" do it "returns valid interval plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :interval run opt_bin/"beanstalkd"
interval 5 run_type :interval
interval 5
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -336,10 +362,12 @@ describe Homebrew::Service do
end end
it "returns valid cron plist" do it "returns valid cron plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :cron run opt_bin/"beanstalkd"
cron "@daily" run_type :cron
cron "@daily"
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -378,9 +406,11 @@ describe Homebrew::Service do
end end
it "returns valid keepalive-exit plist" do it "returns valid keepalive-exit plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
keep_alive successful_exit: false run opt_bin/"beanstalkd"
keep_alive successful_exit: false
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -417,9 +447,11 @@ describe Homebrew::Service do
end end
it "returns valid keepalive-crashed plist" do it "returns valid keepalive-crashed plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
keep_alive crashed: true run opt_bin/"beanstalkd"
keep_alive crashed: true
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -456,9 +488,11 @@ describe Homebrew::Service do
end end
it "returns valid keepalive-path plist" do it "returns valid keepalive-path plist" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
keep_alive path: opt_pkgshare/"test-path" run opt_bin/"beanstalkd"
keep_alive path: opt_pkgshare/"test-path"
end
end end
plist = f.service.to_plist plist = f.service.to_plist
@ -497,19 +531,21 @@ describe Homebrew::Service do
describe "#to_systemd_unit" do describe "#to_systemd_unit" do
it "returns valid unit" do it "returns valid unit" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :immediate run [opt_bin/"beanstalkd", "test"]
environment_variables PATH: std_service_path_env, FOO: "BAR" run_type :immediate
error_log_path var/"log/beanstalkd.error.log" environment_variables PATH: std_service_path_env, FOO: "BAR"
log_path var/"log/beanstalkd.log" error_log_path var/"log/beanstalkd.error.log"
input_path var/"in/beanstalkd" log_path var/"log/beanstalkd.log"
root_dir var input_path var/"in/beanstalkd"
working_dir var root_dir var
keep_alive true working_dir var
process_type :interactive keep_alive true
restart_delay 30 process_type :interactive
macos_legacy_timers true restart_delay 30
macos_legacy_timers true
end
end end
unit = f.service.to_systemd_unit unit = f.service.to_systemd_unit
@ -538,10 +574,12 @@ describe Homebrew::Service do
end end
it "returns valid partial oneshot unit" do it "returns valid partial oneshot unit" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :immediate run opt_bin/"beanstalkd"
launch_only_once true run_type :immediate
launch_only_once true
end
end end
unit = f.service.to_systemd_unit unit = f.service.to_systemd_unit
@ -562,10 +600,12 @@ describe Homebrew::Service do
describe "#to_systemd_timer" do describe "#to_systemd_timer" do
it "returns valid timer" do it "returns valid timer" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :interval run [opt_bin/"beanstalkd", "test"]
interval 5 run_type :interval
interval 5
end
end end
unit = f.service.to_systemd_timer unit = f.service.to_systemd_timer
@ -584,9 +624,11 @@ describe Homebrew::Service do
end end
it "returns valid partial timer" do it "returns valid partial timer" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :immediate run opt_bin/"beanstalkd"
run_type :immediate
end
end end
unit = f.service.to_systemd_timer unit = f.service.to_systemd_timer
@ -604,10 +646,12 @@ describe Homebrew::Service do
end end
it "throws on incomplete cron" do it "throws on incomplete cron" do
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :cron run opt_bin/"beanstalkd"
cron "1 2 3 4" run_type :cron
cron "1 2 3 4"
end
end end
expect { expect {
@ -627,10 +671,12 @@ describe Homebrew::Service do
} }
styles.each do |cron, calendar| styles.each do |cron, calendar|
f.class.service do f = stub_formula do
run opt_bin/"beanstalkd" service do
run_type :cron run opt_bin/"beanstalkd"
cron cron.to_s run_type :cron
cron cron.to_s
end
end end
unit = f.service.to_systemd_timer unit = f.service.to_systemd_timer
@ -653,18 +699,22 @@ describe Homebrew::Service do
describe "#timed?" do describe "#timed?" do
it "returns false for immediate" do it "returns false for immediate" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :immediate run [opt_bin/"beanstalkd", "test"]
run_type :immediate
end
end end
expect(f.service.timed?).to be(false) expect(f.service.timed?).to be(false)
end end
it "returns true for interval" do it "returns true for interval" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :interval run [opt_bin/"beanstalkd", "test"]
run_type :interval
end
end end
expect(f.service.timed?).to be(true) expect(f.service.timed?).to be(true)
@ -673,35 +723,43 @@ describe Homebrew::Service do
describe "#keep_alive?" do describe "#keep_alive?" do
it "returns true when keep_alive set to hash" do it "returns true when keep_alive set to hash" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
keep_alive crashed: true run [opt_bin/"beanstalkd", "test"]
keep_alive crashed: true
end
end end
expect(f.service.keep_alive?).to be(true) expect(f.service.keep_alive?).to be(true)
end end
it "returns true when keep_alive set to true" do it "returns true when keep_alive set to true" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
keep_alive true run [opt_bin/"beanstalkd", "test"]
keep_alive true
end
end end
expect(f.service.keep_alive?).to be(true) expect(f.service.keep_alive?).to be(true)
end end
it "returns false when keep_alive not set" do it "returns false when keep_alive not set" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run [opt_bin/"beanstalkd", "test"]
end
end end
expect(f.service.keep_alive?).to be(false) expect(f.service.keep_alive?).to be(false)
end end
it "returns false when keep_alive set to false" do it "returns false when keep_alive set to false" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
keep_alive false run [opt_bin/"beanstalkd", "test"]
keep_alive false
end
end end
expect(f.service.keep_alive?).to be(false) expect(f.service.keep_alive?).to be(false)
@ -710,9 +768,11 @@ describe Homebrew::Service do
describe "#command" do describe "#command" do
it "returns @run data" do it "returns @run data" do
f.class.service do f = stub_formula do
run [opt_bin/"beanstalkd", "test"] service do
run_type :immediate run [opt_bin/"beanstalkd", "test"]
run_type :immediate
end
end end
command = f.service.command command = f.service.command

View File

@ -4,13 +4,22 @@
class Failball < Formula class Failball < Formula
def initialize(name = "failball", path = Pathname.new(__FILE__).expand_path, spec = :stable, def initialize(name = "failball", path = Pathname.new(__FILE__).expand_path, spec = :stable,
alias_path: nil, force_bottle: false) alias_path: nil, force_bottle: false)
self.class.instance_eval do
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
stable.sha256 TESTBALL_SHA256
end
super super
end end
DSL_PROC = proc do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
end.freeze
private_constant :DSL_PROC
DSL_PROC.call
def self.inherited(other)
super
other.instance_eval(&DSL_PROC)
end
def install def install
prefix.install "bin" prefix.install "bin"
prefix.install "libexec" prefix.install "libexec"

View File

@ -4,13 +4,22 @@
class Testball < Formula class Testball < Formula
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable,
alias_path: nil, force_bottle: false) alias_path: nil, force_bottle: false)
self.class.instance_eval do
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
stable.sha256 TESTBALL_SHA256
end
super super
end end
DSL_PROC = proc do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
end.freeze
private_constant :DSL_PROC
DSL_PROC.call
def self.inherited(other)
super
other.instance_eval(&DSL_PROC)
end
def install def install
prefix.install "bin" prefix.install "bin"
prefix.install "libexec" prefix.install "libexec"

View File

@ -4,18 +4,29 @@
class TestballBottle < Formula class TestballBottle < Formula
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable,
alias_path: nil, force_bottle: false) alias_path: nil, force_bottle: false)
self.class.instance_eval do
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
stable.sha256 TESTBALL_SHA256
stable.bottle do
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
sha256 cellar: :any_skip_relocation, Utils::Bottles.tag.to_sym => "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
end
cxxstdlib_check :skip
end
super super
end end
DSL_PROC = proc do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
bottle do
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
sha256 cellar: :any_skip_relocation, Utils::Bottles.tag.to_sym => "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
end
cxxstdlib_check :skip
end.freeze
private_constant :DSL_PROC
DSL_PROC.call
def self.inherited(other)
super
other.instance_eval(&DSL_PROC)
end
def install def install
prefix.install "bin" prefix.install "bin"
prefix.install "libexec" prefix.install "libexec"

View File

@ -4,19 +4,29 @@
class TestballBottleCellar < Formula class TestballBottleCellar < Formula
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable,
alias_path: nil, force_bottle: false) alias_path: nil, force_bottle: false)
self.class.instance_eval do
stable.url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
stable.sha256 TESTBALL_SHA256
hexdigest = "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
stable.bottle do
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
sha256 cellar: :any_skip_relocation, Utils::Bottles.tag.to_sym => hexdigest
end
cxxstdlib_check :skip
end
super super
end end
DSL_PROC = proc do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
bottle do
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
sha256 cellar: :any_skip_relocation, Utils::Bottles.tag.to_sym => "8f9aecd233463da6a4ea55f5f88fc5841718c013f3e2a7941350d6130f1dc149"
end
cxxstdlib_check :skip
end.freeze
private_constant :DSL_PROC
DSL_PROC.call
def self.inherited(other)
super
other.instance_eval(&DSL_PROC)
end
def install def install
prefix.install "bin" prefix.install "bin"
prefix.install "libexec" prefix.install "libexec"