Commit 24ac7da
committed
Fix OrderReporter producing empty test_order.log in parallel DRb mode
## Situation
OrderReporter writes test identifiers in its before_test method, but in
Rails parallel DRb mode (forked processes), before_test is never called.
The parallelization server only calls prerecord and record on the parent
process's reporters. Since tests execute in forked workers via
Minitest.run_one_method (which bypasses reporters entirely), the
test_order.log file is truncated on start and never written to.
This makes it impossible to bisect order-dependent flaky test failures
because the test order is never recorded.
## Execution
Instead of relying on the reporter API (which lacks worker identity in
DRb mode), prepend a TestOrderTracking module onto Minitest::Test that
hooks into before_setup. This fires inside the forked worker process
during run_one_method, where Process.pid correctly identifies the worker.
Each forked worker writes to its own file (test_order.worker-{pid}.log)
with sync writes enabled (workers never call report, so buffered writes
risk data loss on crash). The parent process's main test_order.log is
used in non-parallel mode where the parent is the test process.
On start, stale worker files from previous runs are cleaned up.1 parent 3e0df3f commit 24ac7da
2 files changed
Lines changed: 128 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
5 | 22 | | |
6 | 23 | | |
7 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
8 | 27 | | |
9 | 28 | | |
10 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
11 | 33 | | |
12 | 34 | | |
13 | 35 | | |
14 | 36 | | |
15 | 37 | | |
16 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
17 | 48 | | |
18 | 49 | | |
19 | | - | |
20 | | - | |
21 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
22 | 54 | | |
23 | 55 | | |
24 | | - | |
| 56 | + | |
25 | 57 | | |
26 | 58 | | |
27 | 59 | | |
28 | 60 | | |
29 | 61 | | |
30 | | - | |
31 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
32 | 67 | | |
33 | 68 | | |
34 | 69 | | |
35 | 70 | | |
36 | | - | |
37 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
38 | 85 | | |
39 | 86 | | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
12 | 20 | | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
17 | 25 | | |
18 | | - | |
| 26 | + | |
19 | 27 | | |
20 | | - | |
21 | | - | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
26 | 43 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
30 | 66 | | |
31 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
32 | 73 | | |
33 | | - | |
34 | | - | |
| 74 | + | |
| 75 | + | |
35 | 76 | | |
36 | 77 | | |
37 | | - | |
38 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
39 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
40 | 94 | | |
41 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
42 | 99 | | |
43 | 100 | | |
44 | 101 | | |
45 | 102 | | |
46 | 103 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 104 | | |
52 | 105 | | |
53 | 106 | | |
| |||
0 commit comments