From 59f4b5226a660d057222fe0ac7d1c3afcc28e484 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 9 Nov 2022 14:45:43 +0000 Subject: [PATCH] tests: test on Ubuntu 18.04. --- .devcontainer/on-create-command.sh | 20 +--- .github/workflows/tests.yml | 8 +- Library/Homebrew/dev-cmd/tests.rb | 105 ++++++++++-------- Library/Homebrew/development_tools.rb | 9 +- .../extend/os/linux/dependency_collector.rb | 26 ++++- .../extend/os/linux/development_tools.rb | 22 ++-- Library/Homebrew/extend/os/linux/formula.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/tap.rb | 3 + Library/Homebrew/test/caveats_spec.rb | 9 ++ Library/Homebrew/test/cmd/tap-info_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/audit_spec.rb | 3 + .../test/formula_installer_bottle_spec.rb | 4 +- Library/Homebrew/test/formula_spec.rb | 16 +++ Library/Homebrew/test/formulary_spec.rb | 10 +- .../test/installed_dependents_spec.rb | 2 + .../test/language/perl/shebang_spec.rb | 1 + .../test/language/python/shebang_spec.rb | 3 +- .../spec/shared_context/integration_test.rb | 2 + Library/Homebrew/test/tab_spec.rb | 4 + Library/Homebrew/test/tap_spec.rb | 3 +- 21 files changed, 162 insertions(+), 94 deletions(-) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index 677b3240f1..11c13b495a 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -1,23 +1,15 @@ #!/bin/bash set -e -# dump information variables for debugging -echo "==> env" -env | grep -v TOKEN -echo -echo "==> /etc/os-release" -cat /etc/os-release || true -echo -echo "==> /etc/lsb-release" -cat /etc/lsb-release || true -echo -echo "==> /etc/issue" -cat /etc/issue || true -echo - # fix permissions so Homebrew and Bundler don't complain sudo chmod -R g-w,o-w /home/linuxbrew +# everything below is too slow to do unless prebuilding so skip it +if [ -z "$CODESPACES_PREBUILD_TOKEN" ] +then + exit 0 +fi + # install Homebrew's development gems brew install-bundler-gems --groups=sorbet diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e01422163a..631848e3bb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,6 +12,7 @@ permissions: env: HOMEBREW_DEVELOPER: 1 HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_ENV_HINTS: 1 concurrency: group: "${{ github.ref }}" @@ -235,10 +236,9 @@ jobs: - name: tests (Ubuntu 22.04) test-flags: --online --coverage runs-on: ubuntu-22.04 - # Enable later once this can be fixed. - # - name: tests (Ubuntu 18.04) - # test-flags: --online --coverage - # runs-on: ubuntu-18.04 + - name: tests (Ubuntu 18.04) + test-flags: --online --coverage + runs-on: ubuntu-18.04 steps: - name: Set up Homebrew id: set-up-homebrew diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 2f293aead9..1335d35dcb 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -93,55 +93,7 @@ module Homebrew require "byebug" if args.byebug? HOMEBREW_LIBRARY_PATH.cd do - # Cleanup any unwanted user configuration. - allowed_test_env = %w[ - HOMEBREW_GITHUB_API_TOKEN - HOMEBREW_CACHE - HOMEBREW_LOGS - HOMEBREW_TEMP - HOMEBREW_USE_RUBY_FROM_PATH - ] - Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env| - next if allowed_test_env.include?(env) - - ENV.delete(env) - end - - # Codespaces /tmp is mounted 755 which makes Ruby warn constantly. - if (ENV["HOMEBREW_CODESPACES"] == "true") && (HOMEBREW_TEMP.to_s == "/tmp") - homebrew_prefix_tmp = "#{HOMEBREW_PREFIX}/tmp" - ENV["HOMEBREW_TEMP"] = homebrew_prefix_tmp - FileUtils.mkdir_p homebrew_prefix_tmp - system "chmod", "-R", "g-w,o-w", "/tmp" - end - - ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "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? - ENV["HOMEBREW_SORBET_RUNTIME"] = "1" - - ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp - - # Avoid local configuration messing with tests, e.g. git being configured - # to use GPG to sign by default - ENV["HOME"] = "#{HOMEBREW_LIBRARY_PATH}/test" - - # Print verbose output when requesting debug or verbose output. - ENV["HOMEBREW_VERBOSE_TESTS"] = "1" if args.debug? || args.verbose? - - if args.coverage? - ENV["HOMEBREW_TESTS_COVERAGE"] = "1" - FileUtils.rm_f "test/coverage/.resultset.json" - end - - # Override author/committer as global settings might be invalid and thus - # will cause silent failure during the setup of dummy Git repositories. - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" - end + setup_environment!(args) parallel = true @@ -237,4 +189,59 @@ module Homebrew Homebrew.failed = true end end + + def setup_environment!(args) + # Cleanup any unwanted user configuration. + allowed_test_env = %w[ + HOMEBREW_GITHUB_API_TOKEN + HOMEBREW_CACHE + HOMEBREW_LOGS + HOMEBREW_TEMP + HOMEBREW_USE_RUBY_FROM_PATH + ] + Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env| + next if allowed_test_env.include?(env) + + ENV.delete(env) + end + + # Codespaces HOMEBREW_PREFIX and /tmp are mounted 755 which makes Ruby warn constantly. + if (ENV["HOMEBREW_CODESPACES"] == "true") && (HOMEBREW_TEMP.to_s == "/tmp") + # Need to keep this fairly short to avoid socket paths being too long in tests. + homebrew_prefix_tmp = "/home/linuxbrew/tmp" + ENV["HOMEBREW_TEMP"] = homebrew_prefix_tmp + FileUtils.mkdir_p homebrew_prefix_tmp + system "chmod", "-R", "g-w,o-w", HOMEBREW_PREFIX, homebrew_prefix_tmp + end + + ENV["HOMEBREW_TESTS"] = "1" + ENV["HOMEBREW_NO_AUTO_UPDATE"] = "1" + ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "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? + ENV["HOMEBREW_SORBET_RUNTIME"] = "1" + + ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp + + # Avoid local configuration messing with tests, e.g. git being configured + # to use GPG to sign by default + ENV["HOME"] = "#{HOMEBREW_LIBRARY_PATH}/test" + + # Print verbose output when requesting debug or verbose output. + ENV["HOMEBREW_VERBOSE_TESTS"] = "1" if args.debug? || args.verbose? + + if args.coverage? + ENV["HOMEBREW_TESTS_COVERAGE"] = "1" + FileUtils.rm_f "test/coverage/.resultset.json" + end + + # Override author/committer as global settings might be invalid and thus + # will cause silent failure during the setup of dummy Git repositories. + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" + end + end end diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index e1288c9bcb..6a7014f902 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -99,12 +99,17 @@ class DevelopmentTools end sig { returns(T::Boolean) } - def build_system_too_old? + def needs_build_formulae? + needs_libc_formula? || needs_compiler_formula? + end + + sig { returns(T::Boolean) } + def needs_libc_formula? false end sig { returns(T::Boolean) } - def system_gcc_too_old? + def needs_compiler_formula? false end diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb index 52ea461877..785ca93326 100644 --- a/Library/Homebrew/extend/os/linux/dependency_collector.rb +++ b/Library/Homebrew/extend/os/linux/dependency_collector.rb @@ -13,20 +13,22 @@ class DependencyCollector sig { params(related_formula_names: T::Set[String]).returns(T.nilable(Dependency)) } def gcc_dep_if_needed(related_formula_names) # gcc is required for libgcc_s.so.1 if glibc or gcc are too old - return unless DevelopmentTools.build_system_too_old? + return unless DevelopmentTools.needs_build_formulae? return if building_global_dep_tree? return if related_formula_names.include?(GCC) return if global_dep_tree[GCC]&.intersect?(related_formula_names) + return unless formula_for(GCC) Dependency.new(GCC) end sig { params(related_formula_names: T::Set[String]).returns(T.nilable(Dependency)) } def glibc_dep_if_needed(related_formula_names) - return unless OS::Linux::Glibc.below_ci_version? + return unless DevelopmentTools.needs_libc_formula? return if building_global_dep_tree? return if related_formula_names.include?(GLIBC) return if global_dep_tree[GLIBC]&.intersect?(related_formula_names) + return unless formula_for(GLIBC) Dependency.new(GLIBC) end @@ -38,7 +40,7 @@ class DependencyCollector sig { void } def init_global_dep_tree_if_needed! - return unless DevelopmentTools.build_system_too_old? + return unless DevelopmentTools.needs_build_formulae? return if building_global_dep_tree? return unless global_dep_tree.empty? @@ -49,15 +51,27 @@ class DependencyCollector built_global_dep_tree! end + sig { params(name: String).returns(T.nilable(Formula)) } + def formula_for(name) + @formula_for ||= {} + @formula_for[name] ||= Formula[name] + rescue FormulaUnavailableError + nil + end + sig { params(name: String).returns(T::Array[String]) } def global_deps_for(name) @global_deps_for ||= {} # Always strip out glibc and gcc from all parts of dependency tree when # we're calculating their dependency trees. Other parts of Homebrew will # catch any circular dependencies. - @global_deps_for[name] ||= Formula[name].deps.map(&:name).flat_map do |dep| - [dep, *global_deps_for(dep)].compact - end.uniq + @global_deps_for[name] ||= if (formula = formula_for(name)) + formula.deps.map(&:name).flat_map do |dep| + [dep, *global_deps_for(dep)].compact + end.uniq + else + [] + end end # Use class variables to avoid this expensive logic needing to be done more diff --git a/Library/Homebrew/extend/os/linux/development_tools.rb b/Library/Homebrew/extend/os/linux/development_tools.rb index b0f5212da9..f5928260f4 100644 --- a/Library/Homebrew/extend/os/linux/development_tools.rb +++ b/Library/Homebrew/extend/os/linux/development_tools.rb @@ -8,10 +8,10 @@ class DevelopmentTools sig { params(tool: String).returns(T.nilable(Pathname)) } def locate(tool) (@locate ||= {}).fetch(tool) do |key| - @locate[key] = if build_system_too_old? && + @locate[key] = if needs_build_formulae? && (binutils_path = HOMEBREW_PREFIX/"opt/binutils/bin/#{tool}").executable? binutils_path - elsif build_system_too_old? && (glibc_path = HOMEBREW_PREFIX/"opt/glibc/bin/#{tool}").executable? + elsif needs_build_formulae? && (glibc_path = HOMEBREW_PREFIX/"opt/glibc/bin/#{tool}").executable? glibc_path elsif (homebrew_path = HOMEBREW_PREFIX/"bin/#{tool}").executable? homebrew_path @@ -27,18 +27,22 @@ class DevelopmentTools end sig { returns(T::Boolean) } - def build_system_too_old? - return @build_system_too_old if defined? @build_system_too_old + def needs_libc_formula? + return @needs_libc_formula if defined? @needs_libc_formula - @build_system_too_old = (system_gcc_too_old? || OS::Linux::Glibc.below_ci_version?) + @needs_libc_formula = OS::Linux::Glibc.below_ci_version? end sig { returns(T::Boolean) } - def system_gcc_too_old? - gcc = "/usr/bin/gcc" - return true unless File.exist?(gcc) + def needs_compiler_formula? + return @needs_compiler_formula if defined? @needs_compiler_formula - gcc_version(gcc) < OS::LINUX_GCC_CI_VERSION + gcc = "/usr/bin/gcc" + @needs_compiler_formula = if File.exist?(gcc) + gcc_version(gcc) < OS::LINUX_GCC_CI_VERSION + else + true + end end sig { returns(T::Hash[String, T.nilable(String)]) } diff --git a/Library/Homebrew/extend/os/linux/formula.rb b/Library/Homebrew/extend/os/linux/formula.rb index 91bb4180e4..77bc3a6a43 100644 --- a/Library/Homebrew/extend/os/linux/formula.rb +++ b/Library/Homebrew/extend/os/linux/formula.rb @@ -27,7 +27,7 @@ class Formula sig { params(spec: SoftwareSpec).void } def add_global_deps_to_spec(spec) - return unless DevelopmentTools.build_system_too_old? + return unless DevelopmentTools.needs_build_formulae? @global_deps ||= begin dependency_collector = spec.dependency_collector diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index b96764e008..a657aa5c61 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -246,7 +246,7 @@ class FormulaInstaller if Homebrew.default_prefix? && !build_from_source? && !build_bottle? && !formula.head? && formula.tap&.core_tap? && # Integration tests override homebrew-core locations - ENV["HOMEBREW_TEST_TMPDIR"].nil? && + ENV["HOMEBREW_INTEGRATION_TEST"].nil? && !pour_bottle? message = if !formula.pour_bottle? && formula.pour_bottle_check_unsatisfied_reason formula_message = formula.pour_bottle_check_unsatisfied_reason diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 452c136aca..a099b65977 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -797,6 +797,9 @@ class CoreTap < Tap return if instance.installed? return if Homebrew::EnvConfig.install_from_api? + # Tests override homebrew-core locations and we don't want to auto-tap in them. + return if ENV["HOMEBREW_TESTS"] + safe_system HOMEBREW_BREW_FILE, "tap", instance.name end diff --git a/Library/Homebrew/test/caveats_spec.rb b/Library/Homebrew/test/caveats_spec.rb index 5919148691..36ca7f884a 100644 --- a/Library/Homebrew/test/caveats_spec.rb +++ b/Library/Homebrew/test/caveats_spec.rb @@ -130,6 +130,11 @@ describe Caveats do end context "when f.service is not nil" do + before do + allow_any_instance_of(Object).to receive(:which).with("launchctl").and_return(true) + allow_any_instance_of(Object).to receive(:which).with("systemctl").and_return(true) + end + it "prints warning when no service deamon is found" do f = formula do url "foo-1.0" @@ -259,6 +264,10 @@ describe Caveats do let(:path) { f.prefix.resolved_path } before do + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + allow_any_instance_of(Pathname).to receive(:children).and_return([Pathname.new("child")]) allow_any_instance_of(Object).to receive(:which).with(any_args).and_return(Pathname.new("shell")) allow(Utils::Shell).to receive(:preferred).and_return(nil) diff --git a/Library/Homebrew/test/cmd/tap-info_spec.rb b/Library/Homebrew/test/cmd/tap-info_spec.rb index bc1a68a4a6..fa2914678c 100644 --- a/Library/Homebrew/test/cmd/tap-info_spec.rb +++ b/Library/Homebrew/test/cmd/tap-info_spec.rb @@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse" describe "brew tap-info" do it_behaves_like "parseable arguments" - it "gets information for a given Tap", :integration_test do + it "gets information for a given Tap", :integration_test, :needs_network do setup_test_tap expect { brew "tap-info", "--json=v1", "--installed" } diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 56031ac601..66573c6675 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -1202,6 +1202,9 @@ module Homebrew end specify "it warns when another formula does not have a symmetric conflict" do + stub_formula_loader formula("gcc") { url "gcc-1.0" } + stub_formula_loader formula("glibc") { url "glibc-1.0" } + foo = formula("foo") do url "https://brew.sh/foo-1.0.tgz" end diff --git a/Library/Homebrew/test/formula_installer_bottle_spec.rb b/Library/Homebrew/test/formula_installer_bottle_spec.rb index 1cc7037b93..f2daedb5ff 100644 --- a/Library/Homebrew/test/formula_installer_bottle_spec.rb +++ b/Library/Homebrew/test/formula_installer_bottle_spec.rb @@ -22,9 +22,9 @@ describe FormulaInstaller do expect(formula).to be_bottled expect(formula).to pour_bottle - stub_formula_loader formula stub_formula_loader formula("gcc") { url "gcc-1.0" } - stub_formula_loader formula("gcc@11") { url "gcc-11.0" } + stub_formula_loader formula("glibc") { url "glibc-1.0" } + stub_formula_loader formula fi = FormulaInstaller.new(formula) fi.fetch diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 0c7b2ee5d9..92a8299abb 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -150,6 +150,10 @@ describe Formula do end before do + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + allow(Formulary).to receive(:load_formula_from_path).with(f2.name, f2.path).and_return(f2) allow(Formulary).to receive(:factory).with(f2.name).and_return(f2) allow(f.tap).to receive(:versioned_formula_files).and_return([f2.path]) @@ -740,6 +744,10 @@ describe Formula do end specify "dependencies" do + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + f1 = formula "f1" do url "f1-1.0" end @@ -782,6 +790,10 @@ describe Formula do specify "runtime dependencies with optional deps from tap" do tap_loader = double + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + allow(tap_loader).to receive(:get_formula).and_raise(RuntimeError, "tried resolving tap formula") allow(Formulary).to receive(:loader_for).with("foo/bar/f1", from: nil).and_return(tap_loader) stub_formula_loader(formula("f2") { url("f2-1.0") }, "baz/qux/f2") @@ -831,6 +843,10 @@ describe Formula do end specify "requirements" do + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + f1 = formula "f1" do url "f1-1" diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index 97985d2a7f..3b3cd51f51 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -141,8 +141,10 @@ describe Formulary do context "with installed Formula" do before do allow(described_class).to receive(:loader_for).and_call_original - stub_formula_loader formula("gcc") { url "gcc-1.0" } - stub_formula_loader formula("gcc@11") { url "gcc-11.0" } + + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) end let(:installed_formula) { described_class.factory(formula_path) } @@ -283,6 +285,10 @@ describe Formulary do before do allow(described_class).to receive(:loader_for).and_return(described_class::FormulaAPILoader.new(formula_name)) + + # don't try to load/fetch gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) end it "returns a Formula when given a name" do diff --git a/Library/Homebrew/test/installed_dependents_spec.rb b/Library/Homebrew/test/installed_dependents_spec.rb index 29be0cf17d..f6721bd895 100644 --- a/Library/Homebrew/test/installed_dependents_spec.rb +++ b/Library/Homebrew/test/installed_dependents_spec.rb @@ -18,6 +18,8 @@ describe InstalledDependents do end def setup_test_keg(name, version, &block) + stub_formula("gcc") + stub_formula("glibc") stub_formula(name, version, &block) path = HOMEBREW_CELLAR/name/version diff --git a/Library/Homebrew/test/language/perl/shebang_spec.rb b/Library/Homebrew/test/language/perl/shebang_spec.rb index 38719dd709..4d6a1fd579 100644 --- a/Library/Homebrew/test/language/perl/shebang_spec.rb +++ b/Library/Homebrew/test/language/perl/shebang_spec.rb @@ -33,6 +33,7 @@ describe Language::Perl::Shebang do describe "#detected_perl_shebang" do it "can be used to replace Perl shebangs" do + allow(Formulary).to receive(:factory) allow(Formulary).to receive(:factory).with(perl_f.name).and_return(perl_f) Utils::Shebang.rewrite_shebang described_class.detected_perl_shebang(f), file diff --git a/Library/Homebrew/test/language/python/shebang_spec.rb b/Library/Homebrew/test/language/python/shebang_spec.rb index 96cb94257f..9d191f1b92 100644 --- a/Library/Homebrew/test/language/python/shebang_spec.rb +++ b/Library/Homebrew/test/language/python/shebang_spec.rb @@ -33,7 +33,8 @@ describe Language::Python::Shebang do describe "#detected_python_shebang" do it "can be used to replace Python shebangs" do - expect(Formulary).to receive(:factory).with(python_f.name).and_return(python_f) + allow(Formulary).to receive(:factory) + allow(Formulary).to receive(:factory).with(python_f.name).and_return(python_f) Utils::Shebang.rewrite_shebang described_class.detected_python_shebang(f, use_python_from_path: false), file expect(File.read(file)).to eq <<~EOS diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 1f21581840..441d902ee8 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -43,12 +43,14 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin end around do |example| + ENV["HOMEBREW_INTEGRATION_TEST"] = "1" (HOMEBREW_PREFIX/"bin").mkpath FileUtils.touch HOMEBREW_PREFIX/"bin/brew" example.run ensure FileUtils.rm_rf HOMEBREW_PREFIX/"bin" + ENV.delete("HOMEBREW_INTEGRATION_TEST") end # Generate unique ID to be able to diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb index 059a590d39..1c16059628 100644 --- a/Library/Homebrew/test/tab_spec.rb +++ b/Library/Homebrew/test/tab_spec.rb @@ -248,6 +248,10 @@ describe Tab do # < 1.1.7 runtime dependencies were wrong so are ignored stub_const("HOMEBREW_VERSION", "1.1.7") + # don't try to load gcc/glibc + allow(DevelopmentTools).to receive(:needs_libc_formula?).and_return(false) + allow(DevelopmentTools).to receive(:needs_compiler_formula?).and_return(false) + f = formula do url "foo-1.0" depends_on "bar" diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb index 355cd497bd..5223091291 100644 --- a/Library/Homebrew/test/tap_spec.rb +++ b/Library/Homebrew/test/tap_spec.rb @@ -258,8 +258,7 @@ describe Tap do expect(homebrew_foo_tap.git_last_commit).to match(/\A\d+ .+ ago\Z/) end - specify "#private?" do - skip "HOMEBREW_GITHUB_API_TOKEN is required" unless GitHub::API.credentials + specify "#private?", :needs_network do expect(homebrew_foo_tap).to be_private end