Class: Homebrew::TestBot::CleanupAfter Private

Inherits:
TestCleanup show all
Defined in:
test_bot/cleanup_after.rb

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.

Instance Attribute Summary

Attributes inherited from Test

#steps

Instance Method Summary collapse

Methods inherited from Test

#failed_steps, #ignored_steps

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Instance Method Details

#run!(args:) ⇒ Object

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.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'test_bot/cleanup_after.rb', line 7

def run!(args:)
  if ENV["HOMEBREW_GITHUB_ACTIONS"].present? && ENV["GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED"].blank? &&
     # don't need to do post-build cleanup unless testing test-bot itself.
     !args.test_default_formula?
    return
  end

  test_header(:CleanupAfter)

  pkill_if_needed

  cleanup_shared

  # Keep all "brew" invocations after cleanup_shared
  # (which cleans up Homebrew/brew)
  return unless local?(args)

  FileUtils.rm_rf ENV.fetch("HOMEBREW_HOME")
  FileUtils.rm_rf ENV.fetch("HOMEBREW_LOGS")
end