diff options
| author | Koichi Sasada <ko1@atdot.net> | 2026-02-03 17:37:05 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2026-02-04 12:40:59 +0900 |
| commit | 2ba2950d20e82f82017a52da9b09fdf1291479a2 (patch) | |
| tree | 43f08500d74913fa5764fabcf0dfea61e001bde6 /tool/lib | |
| parent | 2dc4e872e8bc6ee86ee734310970f66cc9dd51af (diff) | |
show loadavg if the test fails
to survey the following failure:
```
1) Failure:
TestFile#test_stat [/tmp/ruby/src/trunk-repeat20/test/ruby/test_file.rb:412]:
Expected |1770056232.744032 - 1770056230.6465776| (2.097454309463501) to be <= 1.
```
BTW I found that `test/ruby/test_file.rb:412` `assert_in_delta atime, stat.atime.to_f, delta`
only fails (mtime, ctime doesn't fail on 100 days).
Diffstat (limited to 'tool/lib')
| -rw-r--r-- | tool/lib/test/unit/assertions.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tool/lib/test/unit/assertions.rb b/tool/lib/test/unit/assertions.rb index 19581fc3ab..0908666166 100644 --- a/tool/lib/test/unit/assertions.rb +++ b/tool/lib/test/unit/assertions.rb @@ -128,8 +128,16 @@ module Test def assert_in_delta exp, act, delta = 0.001, msg = nil n = (exp - act).abs + loadavg = begin + if File.readable?("/proc/loadavg") + " (/proc/loadavg=#{File.read("/proc/loadavg").strip})" + end + rescue StandardError + nil + end + loadavg ||= "" msg = message(msg) { - "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}" + "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}#{loadavg}" } assert delta >= n, msg end |
