Skip to content

Commit

Permalink
Merge pull request #12967 from Bo98/tests-stdin
Browse files Browse the repository at this point in the history
test/spec_helper: prevent stdin trashing
  • Loading branch information
MikeMcQuaid committed Mar 7, 2022
2 parents 8554a4e + 4db0b99 commit 66c266a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/test/spec_helper.rb
Expand Up @@ -214,12 +214,14 @@ def find_files

@__stdout = $stdout.clone
@__stderr = $stderr.clone
@__stdin = $stdin.clone

begin
if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("HOMEBREW_VERBOSE_TESTS")
$stdout.reopen(File::NULL)
$stderr.reopen(File::NULL)
end
$stdin.reopen(File::NULL)

begin
timeout = example.metadata.fetch(:timeout, 60)
Expand All @@ -236,8 +238,10 @@ def find_files

$stdout.reopen(@__stdout)
$stderr.reopen(@__stderr)
$stdin.reopen(@__stdin)
@__stdout.close
@__stderr.close
@__stdin.close

Formulary.clear_cache
Tap.clear_cache
Expand Down

0 comments on commit 66c266a

Please sign in to comment.