Commit 9d9da74
authored
Introduce
* Flatten type check, fix panic message
_GlobalWriter is deprecated for GlobalWriter
* Introduce `global::with_locked_writer`
New function `global::with_locked_writer` is introduced to allow consistently capturing write output. This function is designed for use in testing output or in other non-reentrant capture cases. This blocks all threads using this function but one from executing so that a deterministic and consistent output is captured. Previously tests could be written with a thread_local writer, however there's a subtle race condition in that approach if the output relies on "paragraph" style text.
That race condition occurs because `global::set_writer` not only mutates the writer but also resets the trailing newlines count, which affects the output. This replacement for that behavior should be safer.
* Prefer public testing helper
* Update test to use `with_locked_writer
These are a doc tests, so they already run in their own processes. Now these tests don't need a tempfile, which is nice.
* Prefer error over unwrap
* Prefer expect over unwrapglobal::with_locked_writer (#43)1 parent 22662f1 commit 9d9da74
File tree
7 files changed
+387
-142
lines changed- src
- docs
7 files changed
+387
-142
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments