Skip to content

Commit

Permalink
Only request human output for non-result in the JSON UI. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Oct 4, 2024
1 parent f893664 commit 94eee76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ui.toit
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ class JsonPrinter extends HumanPrinterBase:
needs-structured --kind/int -> bool:
return kind == Ui.RESULT

wants-human --kind/int -> bool:
return kind != Ui.RESULT

print_ str/string:
print-on-stderr_ str

Expand Down
7 changes: 7 additions & 0 deletions tests/ui-test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,10 @@ test-json:
ui.emit --error "some error"
expect-equals "Error: some error\n" printer.stderr
printer.reset

expect ui.wants-structured // By default the kind is "Ui.RESULT".
expect (ui.wants-structured --kind=Ui.RESULT)
expect-not (ui.wants-structured --kind=Ui.INFO)
expect-not ui.wants-human // By default the kind is "Ui.RESULT".
expect-not (ui.wants-human --kind=Ui.RESULT)
expect (ui.wants-human --kind=Ui.INFO)

0 comments on commit 94eee76

Please sign in to comment.