Commit 7a3706f
authored
* [fix] eliminate select race in checkUpdateHint that drops update hints (#301 regression)
The two-goroutine design introduced in #301 has a scheduler race: the
fetch goroutine's defer cancel() fires the instant it sends its result,
making both the result case and tctx.Done() ready simultaneously in the
collector's select. Go picks pseudo-randomly, dropping the result ~50%
of the time on linux CI.
Fix: collapse to a single goroutine that writes to a buffered out channel
directly. With no select between "result" and "cancellation", the result
is un-droppable by construction. Adds a 500-iteration stress test
(TestCheckUpdateHintNeverDropsResult) as a regression guard.
* [test] restore global rootCmd in TestExecute to fix order-dependent TestExamplePresent
Execute() triggers cobra's InitDefaultHelpCmd(), permanently grafting a
"help" subcommand onto the global rootCmd. Any later test iterating
rootCmd.Commands() (e.g. TestExamplePresent) saw a runnable "help" with
no Example and failed. Failure was order-dependent: ~80% of -shuffle
seeds triggered it.
Clean up by removing the cobra-added "help" command in TestExecute's
t.Cleanup, restoring the pre-Execute command set for subsequent tests.
1 parent 6d663a2 commit 7a3706f
3 files changed
Lines changed: 37 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
225 | 233 | | |
226 | 234 | | |
227 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 42 | | |
| 43 | + | |
59 | 44 | | |
| 45 | + | |
60 | 46 | | |
61 | 47 | | |
62 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
155 | 175 | | |
156 | 176 | | |
157 | 177 | | |
| |||
0 commit comments