// Rewrite Package in the JSON output to be pkg:variant. For sharded
// variants, pkg.TestName is already unambiguous, so we don't need to
// rewrite the Package field.
- if len(opts.pkgs) != 0 {
- panic("cannot combine multiple packages with variants")
- }
+ //
// We only want to process JSON on the child's stdout. Ideally if
// stdout==stderr, we would also use the same testJSONFilter for
// cmd.Stdout and cmd.Stderr in order to keep the underlying
// Should never happen.
panic(fmt.Sprintf("failed to round-trip JSON %q: %s", string(line), err))
}
- data = append(data, '\n')
+ // Copy any trailing text. We expect at most a "\n" here, but
+ // there could be other text and we want to feed that through.
+ extra, _ := io.ReadAll(dec.Buffered())
+ data = append(data, extra...)
f.w.Write(data)
return
}
const want = `unexpected text
{"Package":"abc:variant"}
more text
-{"Package":"abc:variant"}
+{"Package":"abc:variant"}trailing text
{not json}
`
- // Note that currently we won't round-trip trailing text after a valid JSON
- // line. That might be a mistake.
checkJSONFilter(t, in, want)
}