Skip to content

Commit

Permalink
Work around an logging issue on Windows
Browse files Browse the repository at this point in the history
The file was always overwritten, but seeking to the end fixes this.
  • Loading branch information
larskanis committed Nov 3, 2023
1 parent 1c67bbf commit babfda4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ def log_and_run( logpath, *cmd )

# Eliminate the noise of creating/tearing down the database by
# redirecting STDERR/STDOUT to a logfile
logfh = File.open( logpath, File::WRONLY|File::CREAT|File::APPEND )
system( *cmd, [STDOUT, STDERR] => logfh )
File.open( logpath, File::WRONLY|File::CREAT|File::APPEND ) do |logfh|
# Seek manually on Windows to the end of the log file, otherwise the content is overwritten.
logfh.seek(0, :END) if RUBY_PLATFORM =~ /mingw|mswin/
system( *cmd, [STDOUT, STDERR] => logfh )
end

raise "Command failed: [%s]" % [cmd.join(' ')] unless $?.success?
end
Expand Down

0 comments on commit babfda4

Please sign in to comment.