Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
check file line count and file closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2gedev committed Jan 23, 2015
1 parent a389488 commit 40daf70
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_chrono_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,25 @@ def confirm_daily_rotation(option)
begin
Delorean.time_travel_to '2015-01-22 23:59:59.990'
logger = ChronoLogger.new(@format)
old_logdev = logger.instance_variable_get('@logdev').dev
Parallel.map(['a', 'b'], option) do |letter|
5000.times do
logger.info letter * 5000
end
end
assert_no_match(/log shifting failed/, $stderr.string)
assert_no_match(/log writing failed/, $stderr.string)
assert { !old_logdev.closed? }
assert { File.exist?(old_log) }
assert { File.exist?(new_log) }
assert { File.read(old_log).count("\n") + File.read(new_log).count("\n") == 10000 }

sleep ChronoLogger::TimeBasedLogDevice::DELAY_SECOND_TO_CLOSE_FILE + 1
old_logdev.close if option[:in_processes]
assert { old_logdev.closed? } # TODO: check in multiprocess
assert { File.exist?(old_log) }
assert { File.exist?(new_log) }
assert { File.read(old_log).count("\n") + File.read(new_log).count("\n") == 10000 }
ensure
$stderr, stderr = stderr, $stderr
Delorean.back_to_the_present
Expand Down

0 comments on commit 40daf70

Please sign in to comment.