Skip to content

Commit 80050a3

Browse files
committed
Use block so Files are closed after writing
This fixes test errors where the file had no content.
1 parent c4eaa52 commit 80050a3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ruby/lib/minitest/queue/build_status_reporter.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ def progress
107107
end
108108

109109
def write_failure_file(file)
110-
JSON.dump(error_reports.map(&:to_h), File.open(file, 'w'))
110+
File.open(file, 'w') do |f|
111+
JSON.dump(error_reports.map(&:to_h), f)
112+
end
111113
end
112114

113115
def write_flaky_tests_file(file)
114-
JSON.dump(flaky_reports, File.open(file, 'w'))
116+
File.open(file, 'w') do |f|
117+
JSON.dump(flaky_reports, f)
118+
end
115119
end
116120

117121
private

ruby/lib/minitest/queue/runner.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ def display_warnings(build)
323323
warnings = build.pop_warnings.map do |type, attributes|
324324
attributes.merge(type: type)
325325
end.compact
326-
JSON.dump(warnings, File.open(queue_config.warnings_file, 'w'))
326+
File.open(queue_config.warnings_file, 'w') do |f|
327+
JSON.dump(warnings, f)
328+
end
327329
end
328330

329331
def run_tests_in_fork(queue)

0 commit comments

Comments
 (0)