Commit b21614e
committed
analyze: address review comments and add tests
Addresses F1bonacc1's review on #462:
- app/process.go: in handleOutput() replace the direct Health/ReadyTime
mutation with a call to setProcHealth(Ready) so the update runs under
stateMtx, fixing the data race flagged in the review.
- cmd/analyze.go: remove the Run function; Cobra auto-prints help when
a parent command with no Run is invoked without a subcommand.
- cmd/analyze_critical_chain.go:
* extract `unreadySortOrder = time.Duration(math.MaxInt64)` and use it
consistently in readyOffsetForSort.
* when a positional argument names a process that is not part of the
dependency graph but is still known to the project (isolated
process), synthesize a DependencyNode so its timings are still
rendered, instead of erroring out.
* replace the manual string-join loop in formatNodeLine with
strings.Join.
* small refactor: renderCriticalChain(w io.Writer, ...) and
sortRootsByReadyTime(...) are now factored out so they can be
unit-tested without a running server.
New tests:
- cmd/analyze_critical_chain_test.go covers formatDuration,
formatOffset, readyOffsetForSort (including the unreadySortOrder
sentinel), formatNodeLine for all branches (nil state, ready with/
without readiness gap, not-ready, not-started, status annotations),
sibling ordering, and a full renderCriticalChain tree walk.
- app/process_timing_test.go covers setProcHealth -- asserts that
ProcessReadyTime is set on the first Ready transition, is not
overwritten on subsequent Ready calls, is not set for NotReady, and
a concurrent-Ready test that is intended to be exercised under the
race detector.
Verified locally:
- `go build ./...`
- `go vet ./...`
- `go test ./...` (all packages pass)
- `go test -race ./...` (equivalent to `make testrace`, all pass)
- `golangci-lint run -c .golangci.yaml` (0 issues)1 parent af6e05d commit b21614e
5 files changed
Lines changed: 524 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
755 | 753 | | |
756 | 754 | | |
757 | 755 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
9 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 19 | | |
26 | 20 | | |
27 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
74 | | - | |
75 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
76 | 93 | | |
77 | 94 | | |
78 | 95 | | |
| |||
95 | 112 | | |
96 | 113 | | |
97 | 114 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
108 | 127 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
116 | 137 | | |
117 | 138 | | |
118 | 139 | | |
119 | | - | |
| 140 | + | |
120 | 141 | | |
121 | 142 | | |
122 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
123 | 161 | | |
124 | | - | |
125 | | - | |
| 162 | + | |
| 163 | + | |
126 | 164 | | |
127 | 165 | | |
128 | | - | |
| 166 | + | |
129 | 167 | | |
130 | 168 | | |
131 | 169 | | |
132 | 170 | | |
133 | 171 | | |
134 | 172 | | |
135 | 173 | | |
136 | | - | |
| 174 | + | |
137 | 175 | | |
138 | 176 | | |
139 | 177 | | |
| 178 | + | |
140 | 179 | | |
141 | 180 | | |
142 | 181 | | |
| |||
158 | 197 | | |
159 | 198 | | |
160 | 199 | | |
161 | | - | |
| 200 | + | |
162 | 201 | | |
163 | 202 | | |
164 | 203 | | |
| |||
168 | 207 | | |
169 | 208 | | |
170 | 209 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 210 | + | |
179 | 211 | | |
180 | 212 | | |
181 | | - | |
| 213 | + | |
182 | 214 | | |
183 | 215 | | |
184 | 216 | | |
| |||
233 | 265 | | |
234 | 266 | | |
235 | 267 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 268 | + | |
245 | 269 | | |
246 | 270 | | |
247 | 271 | | |
| |||
0 commit comments