Add "pretty" json configuration and change default behavior to be space-efficient (#2275)

* expose underlying format options

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* remove escape html options and address PR feedback

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* incorporate PR feedback

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix cli test

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-11-20 15:29:34 +00:00
committed by GitHub
parent 7cfb5f630a
commit 1676934c63
31 changed files with 723 additions and 204 deletions
+8 -2
View File
@@ -86,7 +86,10 @@ func assertNotInOutput(data string) traitAssertion {
func assertNoStderr(tb testing.TB, _, stderr string, _ int) {
tb.Helper()
if len(stderr) > 0 {
tb.Errorf("expected stderr to be empty, but got %q", stderr)
tb.Errorf("expected stderr to be empty, but wasn't")
if showOutput != nil && *showOutput {
tb.Errorf("STDERR:%s", stderr)
}
}
}
@@ -96,7 +99,10 @@ func assertInOutput(data string) traitAssertion {
stdout = stripansi.Strip(stdout)
stderr = stripansi.Strip(stderr)
if !strings.Contains(stdout, data) && !strings.Contains(stderr, data) {
tb.Errorf("data=%q was NOT found in any output, but should have been there\nSTDOUT:%s\nSTDERR:%s", data, stdout, stderr)
tb.Errorf("data=%q was NOT found in any output, but should have been there", data)
if showOutput != nil && *showOutput {
tb.Errorf("STDOUT:%s\nSTDERR:%s", stdout, stderr)
}
}
}
}