Reputation: 849
I have a series of minitests that work just fine Ubuntu 22.04.2 Ruby ruby 3.2.3 minitest:4.25.4 rake:13.2.1
These are being kicked off with rake:
bundle exec rake test $@
# rakefile:
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = 'ut/ut_*.rb'
end
These work correctly when the UTs pass and when they fail.
The problem is that sometimes to help debug I use a puts() to print some data. The output from that sometimes appears and sometimes it doesn't.
I put a sample line in after_setup to see this.
def after_setup
super
# $svc.log.line('here')
# puts('')
# $stdout.flush
end
# note: The $svc.log.line() is my logger that prints a line using puts() i.e.:
# puts(line)
# $stdout.flush
If I uncomment $svc.log.line by itself, it sometimes works and I see "here" and any other debug lines that I use. But if I add or delete a debug line, it may (or may not) stop working.
If I uncomment puts('') by itself, ditto, adding or removing an additional debug line may or may not cause all the output. Also adding some text in the puts('here') seems to work or not. Note that I sometimes get the newlines but the rest of debug line text don't show.
If I add the additional $stdout.flush that sometimes works and sometimes doesn't. (I've also tried $stderr.flush.)
Note: when I say that it "sometimes works and sometimes doesn't" it means I run rake again without making any changes to the unit test or code under test.
Is there a minitest or rake switch or something else I can do that causes all output to be printed no matter what?
Update: This is not a issue. It was a failure on my part to reset the verbosity of the logger singleton. When minitest executed the tests in random order the logger output would show or not depending on whether the log UT executed before the other UTs.
Upvotes: 0
Views: 65