A virtual jailed shell environment for Go apps backed by an io/fs#FS.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(truecmd): cover GNU-compatible exit-0 behavior

Adds the previously missing test file for the true coreutil.
Asserts nil error (exit 0) with empty stdout/stderr
regardless of arguments, matching GNU coreutils.

Refs: docs/posix2018/CONFORMANCE.md
Assisted-by: Claude Opus 4.7 via Claude Code
Signed-off-by: Xe Iaso <me@xeiaso.net>

Xe Iaso 2d39fa25 3f2e2fc0

+46
+46
command/internal/truecmd/truecmd_test.go
··· 1 + package truecmd 2 + 3 + import ( 4 + "bytes" 5 + "context" 6 + "testing" 7 + 8 + "tangled.org/xeiaso.net/kefka/command" 9 + ) 10 + 11 + func run(t *testing.T, args []string) (string, string, error) { 12 + t.Helper() 13 + var stdout, stderr bytes.Buffer 14 + ec := &command.ExecContext{ 15 + Stdout: &stdout, 16 + Stderr: &stderr, 17 + } 18 + err := Impl{}.Exec(context.Background(), ec, args) 19 + return stdout.String(), stderr.String(), err 20 + } 21 + 22 + func TestTrue(t *testing.T) { 23 + tests := []struct { 24 + name string 25 + args []string 26 + }{ 27 + {name: "no args", args: nil}, 28 + {name: "ignored args", args: []string{"foo", "bar", "baz"}}, 29 + {name: "looks-like-flag args", args: []string{"--help", "-x"}}, 30 + } 31 + 32 + for _, tt := range tests { 33 + t.Run(tt.name, func(t *testing.T) { 34 + stdout, stderr, err := run(t, tt.args) 35 + if err != nil { 36 + t.Fatalf("unexpected error: %v", err) 37 + } 38 + if stdout != "" { 39 + t.Errorf("stdout = %q, want empty", stdout) 40 + } 41 + if stderr != "" { 42 + t.Errorf("stderr = %q, want empty", stderr) 43 + } 44 + }) 45 + } 46 + }