-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/wit-bindgen-wrpc: adds -v flag for enabling stderr output
This commit adds a `--verbose`/`-v` for enable output to stderr for the `wit-bindgen-wrpc` binary Fixes #214 Signed-off-by: Victor Adossi <[email protected]>
- Loading branch information
1 parent
c7ba768
commit 43a8b7f
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wit-bindgen-go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"testing" | ||
) | ||
|
||
// TestSimpleGenVerbosity ensures that a basic generation case honors the verbose flag | ||
func TestSimpleGenVerbosity(t *testing.T) { | ||
var stdout bytes.Buffer | ||
var stderr bytes.Buffer | ||
cmd := makeCmd() | ||
cmd.Writer = &stdout | ||
cmd.ErrWriter = &stderr | ||
|
||
args := []string{ | ||
"wit-bindgen-go", | ||
"generate", | ||
"--world", | ||
"http-fetch-simple", | ||
"--dry-run", | ||
"../../testdata/codegen/simple-http.wit", | ||
} | ||
|
||
// Run the app without verbose | ||
cmd.Run(context.Background(), args) | ||
if stderr.Len() != 0 { | ||
t.Errorf("output was written to stderr despite lack of --verbose") | ||
} | ||
|
||
stdout.Reset() | ||
stderr.Reset() | ||
|
||
// Run the app WITH verbose | ||
cmd.Run(context.Background(), append(args, "--verbose")) | ||
if stderr.Len() == 0 { | ||
t.Errorf("no output was written to stderr when --verbose was used") | ||
} | ||
} |