crucible nwsync emit and assemble printed their summary line to stdout. Callers that capture a script's stdout as a value got the summary glued onto it: pack-haks.sh does release_dir="$(...)", so all 11 emit summaries landed in $release_dir and publish-release.sh failed with "release dir not found". Neither line is a machine-readable contract, so move both to stderr, where lib.sh's own "nwsync: emitted $key" log already goes. runEmit and runAssemble no longer need the stdout writer. Fixes #81. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -458,6 +458,33 @@ func TestAssembleFailsClosedOnMissingIndex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Callers capture a script's stdout as a value: `dir="$(pack-haks.sh)"`. A
|
||||
// summary line on stdout gets glued onto that value, so both summaries belong
|
||||
// on stderr.
|
||||
func TestRunKeepsSummariesOffStdout(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "sow_top.hak")
|
||||
writeHak(t, path, map[string][]byte{"appearance.2da": []byte("2da from sow_top")})
|
||||
key := artifactKey(t, path)
|
||||
out := filepath.Join(dir, "out")
|
||||
|
||||
for _, args := range [][]string{
|
||||
{"emit", "--out", out, "--as", "sow_top.hak", key, path},
|
||||
{"assemble", "--out", out, key},
|
||||
} {
|
||||
var stdout, stderr bytes.Buffer
|
||||
if code := Run(args, &stdout, &stderr); code != exitOK {
|
||||
t.Fatalf("Run(%v) exit=%d: %s", args, code, stderr.String())
|
||||
}
|
||||
if stdout.Len() != 0 {
|
||||
t.Errorf("Run(%v) wrote to stdout: %q", args, stdout.String())
|
||||
}
|
||||
if stderr.Len() == 0 {
|
||||
t.Errorf("Run(%v) reported no summary on stderr", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunUsageErrors(t *testing.T) {
|
||||
cases := [][]string{
|
||||
nil,
|
||||
|
||||
Reference in New Issue
Block a user