Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests with HOMEBREW_DEVELOPER unset. #4909

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Library/Homebrew/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@
internal_dev_cmd = require? HOMEBREW_LIBRARY_PATH/"dev-cmd"/cmd
internal_cmd = internal_dev_cmd
if internal_dev_cmd && !ARGV.homebrew_developer?
system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
"--replace-all", "homebrew.devcmdrun", "true"
if (HOMEBREW_REPOSITORY/".git/config").exist?
system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
"--replace-all", "homebrew.devcmdrun", "true"
end
ENV["HOMEBREW_DEV_CMD_RUN"] = "1"
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def tests
ENV.delete("HOMEBREW_TEMP")
ENV.delete("HOMEBREW_NO_GITHUB_API")
ENV.delete("HOMEBREW_NO_EMOJI")
ENV.delete("HOMEBREW_DEVELOPER")
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat?
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic?
ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online?
Expand Down
22 changes: 10 additions & 12 deletions Library/Homebrew/test/cmd/uninstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

describe "::handle_unsatisfied_dependents" do
specify "when developer" do
ENV["HOMEBREW_DEVELOPER"] = "1"

expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Warning/).to_stderr
Expand All @@ -50,25 +52,21 @@
end

specify "when not developer" do
run_as_not_developer do
expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Error/).to_stderr
expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Error/).to_stderr

expect(described_class).to have_failed
end
expect(described_class).to have_failed
end

specify "when not developer and --ignore-dependencies is specified" do
ARGV << "--ignore-dependencies"

run_as_not_developer do
expect {
described_class.handle_unsatisfied_dependents(opts)
}.not_to output.to_stderr
expect {
described_class.handle_unsatisfied_dependents(opts)
}.not_to output.to_stderr

expect(described_class).not_to have_failed
end
expect(described_class).not_to have_failed
end
end
end
11 changes: 11 additions & 0 deletions Library/Homebrew/test/formula_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ class #{Formulary.class_s(dep_name)} < Formula
temporary_install(Failball.new)
}.to raise_error(RuntimeError)
end

describe "#caveats" do
subject(:formula_installer) { described_class.new(Testball.new) }

it "shows audit problems if HOMEBREW_DEVELOPER is set" do
ENV["HOMEBREW_DEVELOPER"] = "1"
formula_installer.install
expect(formula_installer).to receive(:audit_installed).and_call_original
formula_installer.caveats
end
end
end
12 changes: 0 additions & 12 deletions Library/Homebrew/test/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,6 @@ def esc(code)
end
end

describe "#run_as_not_developer" do
it "temporarily unsets HOMEBREW_DEVELOPER" do
ENV["HOMEBREW_DEVELOPER"] = "foo"

run_as_not_developer do
expect(ENV["HOMEBREW_DEVELOPER"]).to be nil
end

expect(ENV["HOMEBREW_DEVELOPER"]).to eq("foo")
end
end

describe "#which" do
let(:cmd) { dir/"foo" }

Expand Down
6 changes: 0 additions & 6 deletions Library/Homebrew/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,6 @@ def with_custom_locale(locale)
end
end

def run_as_not_developer
with_env(HOMEBREW_DEVELOPER: nil) do
yield
end
end

# Kernel.system but with exceptions
def safe_system(cmd, *args, **options)
return if Homebrew.system(cmd, *args, **options)
Expand Down