Skip to content

Commit 9d00328

Browse files
committed
doc(cookbook): add specific case shell_output stderr
Document the specific case, where your program writes an error to stderr that needs to be checked in a test (e.g., using `assert_match` and `shell_output`): * #5149
1 parent d40eb43 commit 9d00328

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/Formula-Cookbook.md

+8
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ test do
334334
end
335335
```
336336

337+
* If your program writes to sterr, you can [redirect sterr to stdout for assertions with `shell_output`](https://github.com/Homebrew/brew/issues/5149). For example:
338+
339+
```ruby
340+
test do
341+
assert_match "Output on stderr", shell_output("#{bin}/formula-program 2>&1", 2)
342+
end
343+
```
344+
337345
### Manuals
338346

339347
Homebrew expects to find manual pages in `#{prefix}/share/man/...`, and not in `#{prefix}/man/...`.

0 commit comments

Comments
 (0)