Commit de1a8ef
committed
fix(ci): correct print callback arity in AdoCli.CI.Watcher
Bug: the default :print_callback was \&IO.write/2 (a 2-arity
function expecting device + data), but every render function
called it as `print.(line)` (1-arity). On first status
update, this raised:
(BadArityError) &IO.write/2 with arity 2 called with 1 argument
("? Build 9655 · status=inProgress result=nil · <1s\n")
(ado_cli 0.2.2) lib/ado_cli/ci/watcher.ex:124: render_status/3
So every invocation of `ado ci watch` crashed on the first
poll, before it could ever print a single status line.
Fix: change the default to a 1-arity wrapper:
&IO.write(:stdio, &1)
Also made render_status/3 and render_final/2 public (`def`
instead of `defp`) so they can be unit-tested directly.
Added a regression test that exercises render_status/3 with a
1-arity print collector and asserts the printed output. This
test would have failed (BadArityError) on the broken version.
315 tests pass, mix ci 8/8 green, reach still 1 finding in
our code (logout behaviour candidate, false positive).1 parent 8ac8dde commit de1a8ef
2 files changed
Lines changed: 43 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | | - | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 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 | + | |
41 | 76 | | |
42 | 77 | | |
43 | 78 | | |
| |||
0 commit comments