tests: reduce some noise.

- Tweak the way offline skipping happens
- Skip more tests that break when offline
- Hide more stdout output from tests.
This commit is contained in:
Mike McQuaid 2017-04-22 12:26:18 +01:00
parent 268f2dbde2
commit a6df701fad
7 changed files with 17 additions and 8 deletions

View File

@ -33,7 +33,12 @@ module Homebrew
ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["HOMEBREW_NO_COMPAT"] = "1" if ARGV.include? "--no-compat"
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if ARGV.include? "--generic"
ENV["HOMEBREW_NO_GITHUB_API"] = "1" unless ARGV.include? "--online"
if ARGV.include? "--online"
ENV["HOMEBREW_TEST_ONLINE"] = "1"
else
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
end
if ARGV.include? "--official-cmd-taps"
ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] = "1"

View File

@ -81,7 +81,7 @@ describe Hbc::CLI::Style, :cask do
end
context "version" do
it "matches `HOMEBREW_RUBOCOP_VERSION`" do
it "matches `HOMEBREW_RUBOCOP_VERSION`", :needs_network do
stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote")
expect(status).to be_a_success

View File

@ -13,7 +13,9 @@ describe Hbc::CLI::Uninstall, :cask do
it "tries anyway on a non-present Cask when --force is given" do
expect {
Hbc::CLI::Uninstall.run("local-caffeine", "--force")
shutup do
Hbc::CLI::Uninstall.run("local-caffeine", "--force")
end
}.not_to raise_error
end

View File

@ -1,6 +1,6 @@
describe "brew bundle", :integration_test, :needs_test_cmd_taps do
describe "check" do
it "checks if a Brewfile's dependencies are satisfied" do
it "checks if a Brewfile's dependencies are satisfied", :needs_network do
setup_remote_tap "homebrew/bundle"
HOMEBREW_REPOSITORY.cd do

View File

@ -6,9 +6,7 @@ describe "brew pull", :integration_test do
.and be_a_failure
end
it "fetches a patch from a GitHub commit or pull request and applies it" do
skip "Requires network connection." if ENV["HOMEBREW_NO_GITHUB_API"]
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
CoreTap.instance.path.cd do
shutup do
system "git", "init"

View File

@ -139,7 +139,7 @@ describe Homebrew::MissingFormula do
end
context "::deleted_reason" do
subject { described_class.deleted_reason(formula) }
subject { described_class.deleted_reason(formula, silent: true) }
before do
Tap.clear_cache

View File

@ -61,6 +61,10 @@ RSpec.configure do |config|
skip "Python not installed." unless which("python")
end
config.before(:each, :needs_network) do
skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"]
end
config.around(:each) do |example|
begin
TEST_DIRECTORIES.each(&:mkpath)