Class: Homebrew::DevCmd::Tests Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Tests
- Includes:
- SystemCommand::Mixin
- Defined in:
- dev-cmd/tests.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/tests.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Tests::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::Tests::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/tests.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'dev-cmd/tests.rb', line 44 def run # Given we might be testing various commands, we probably want everything (except sorbet-static) Homebrew.install_bundler_gems!(groups: Homebrew.valid_gem_groups - ["sorbet"]) HOMEBREW_LIBRARY_PATH.cd do setup_environment! parallel = true only = args.only files = if only test_name, line = only.split(":", 2) if line.nil? Dir.glob("test/{#{test_name},#{test_name}/**/*}_spec.rb") else parallel = false ["test/#{test_name}_spec.rb:#{line}"] end elsif args.changed? changed_test_files else Dir.glob("test/**/*_spec.rb") end if files.blank? raise UsageError, "The `--only` argument requires a valid file or folder name!" if only if args.changed? opoo "No tests are directly associated with the changed files!" return end end parallel = false if args.profile parallel_rspec_log_name = "parallel_runtime_rspec" parallel_rspec_log_name = "#{parallel_rspec_log_name}.generic" if args.generic? parallel_rspec_log_name = "#{parallel_rspec_log_name}.online" if args.online? parallel_rspec_log_name = "#{parallel_rspec_log_name}.log" parallel_rspec_log_path = if ENV["CI"] "tests/#{parallel_rspec_log_name}" else "#{HOMEBREW_CACHE}/#{parallel_rspec_log_name}" end ENV["PARALLEL_RSPEC_LOG_PATH"] = parallel_rspec_log_path parallel_args = if ENV["CI"] %W[ --combine-stderr --serialize-stdout --runtime-log #{parallel_rspec_log_path} ] else %w[ --nice ] end # Generate seed ourselves and output later to avoid multiple different # seeds being output when running parallel tests. seed = args.seed || rand(0xFFFF).to_i bundle_args = ["-I", HOMEBREW_LIBRARY_PATH/"test"] bundle_args += %W[ --seed #{seed} --color --require spec_helper ] bundle_args << "--fail-fast" if args.fail_fast? bundle_args << "--profile" << args.profile if args.profile # TODO: Refactor and move to extend/os # rubocop:disable Homebrew/MoveToExtendOS unless OS.mac? bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask" files = files.grep_v(%r{^test/(os/mac|cask)(/.*|_spec\.rb)$}) end unless OS.linux? bundle_args << "--tag" << "~needs_linux" files = files.grep_v(%r{^test/os/linux(/.*|_spec\.rb)$}) end # rubocop:enable Homebrew/MoveToExtendOS bundle_args << "--tag" << "~needs_network" unless args.online? unless ENV["CI"] bundle_args << "--tag" << "~needs_ci" \ << "--tag" << "~needs_svn" end puts "Randomized with seed #{seed}" ENV["HOMEBREW_DEBUG"] = "1" if args.debug? # Used in spec_helper.rb to require the "debug" gem. # Submit test flakiness information using BuildPulse # BUILDPULSE used in spec_helper.rb if use_buildpulse? ENV["BUILDPULSE"] = "1" ohai "Running tests with BuildPulse-friendly settings" end # Workaround for: # # ``` # ruby: no -r allowed while running setuid (SecurityError) # ``` Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid if parallel system "bundle", "exec", "parallel_rspec", *parallel_args, "--", *bundle_args, "--", *files else system "bundle", "exec", "rspec", *bundle_args, "--", *files end success = $CHILD_STATUS.success? run_buildpulse if use_buildpulse? return if success Homebrew.failed = true end end |