Skip to content

Commit abc9c92

Browse files
fix: cli test assumes a network interface exists in every sandbox
A runner with no usable interface exits non-zero by design, which the non-tty test treated as a failure. It now requires a diagnostic naming the collector or the interface before it skips, so a crash or garbage output still fails. Also stops the test matrix cancelling the other platforms on the first failure.
1 parent 6365050 commit abc9c92

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333

3434
test:
3535
strategy:
36+
# Run every platform even if one fails: on a cross-platform TUI, a
37+
# fail-fast matrix hides the platform that actually broke.
38+
fail-fast: false
3639
matrix:
3740
os: [ubuntu-latest, macos-latest, windows-latest]
3841
runs-on: ${{ matrix.os }}

‎cmd/flow/cli_test.go‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,34 @@ func TestCLITiny(t *testing.T) {
216216
func TestCLINonTTYDefaultsToTiny(t *testing.T) {
217217
// No TTY and no output flag: must not block on the TUI.
218218
got := runCLI(t, 20*time.Second)
219+
219220
if got.exitCode != 0 {
220-
t.Fatalf("exit = %d, stderr: %s", got.exitCode, got.stderr)
221+
// A sandboxed runner may have no usable interface, in which case a
222+
// clean non-zero exit with a diagnostic is the correct behaviour.
223+
// Require that diagnostic to name the problem, so a crash or garbage
224+
// output still fails rather than hiding behind the skip.
225+
msg := strings.TrimSpace(got.stderr)
226+
switch {
227+
case msg == "":
228+
t.Fatalf("exit = %d with empty stderr, want a diagnostic", got.exitCode)
229+
case !strings.Contains(msg, "interface") && !strings.Contains(msg, "collector"):
230+
t.Fatalf("exit = %d with unexpected stderr %q, want a collector diagnostic",
231+
got.exitCode, msg)
232+
}
233+
t.Skipf("no usable interface here: %s", msg)
221234
}
235+
222236
line := strings.TrimSpace(got.stdout)
223237
if !strings.Contains(line, "↓") {
224-
t.Errorf("non-TTY run should print the single-line form, got %q", line)
238+
t.Errorf("non-TTY run should print the single-line form, got %q (stderr %q)",
239+
line, got.stderr)
225240
}
226-
if strings.Count(line, "\n") > 0 {
241+
if strings.Contains(line, "\n") {
227242
t.Errorf("non-TTY output should be a single line, got %q", line)
228243
}
244+
if strings.Contains(line, "\x1b[") {
245+
t.Error("non-TTY output must not contain escape codes")
246+
}
229247
}
230248

231249
func TestCLIBitsAffectsUnits(t *testing.T) {

0 commit comments

Comments
 (0)