зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
describe how to debug for contributors (#17)
Этот коммит содержится в:
@@ -35,6 +35,35 @@ cargo fmt -- --check
|
||||
|
||||
If you use [cargo-watch][], `cargo watch-check` alias is useful to run checks automatically on writing to a file.
|
||||
|
||||
## Print debug
|
||||
|
||||
Since this crate uses stdout, `println!` is not available for debugging. Instead, stderr through [`eprintln!`][eprintln]
|
||||
or [`dbg!`][dbg] are useful.
|
||||
|
||||
At first, add prints where you want to debug:
|
||||
|
||||
```rust
|
||||
eprintln!("some value is {:?}", some_value);
|
||||
dbg!(&some_value);
|
||||
```
|
||||
|
||||
Then redirect stderr to some file:
|
||||
|
||||
```sh
|
||||
cargo run -- --example minimal 2>debug.txt
|
||||
```
|
||||
|
||||
Then the debug prints are output to the `debug.txt` file. If timing is important or you want to see the output in real-time,
|
||||
printing the file content with `tail` command would be useful.
|
||||
|
||||
```sh
|
||||
# In a terminal, reproduce the issue
|
||||
cargo run -- --example minimal 2>debug.txt
|
||||
|
||||
# In another terminal, run `tail` command to monitor the content
|
||||
tail -F debug.txt
|
||||
```
|
||||
|
||||
## Running a fuzzer
|
||||
|
||||
To run fuzzing tests, [cargo-fuzz][] is necessary.
|
||||
@@ -61,3 +90,5 @@ See [README in bench/](./bench/README.md) for more details.
|
||||
[cargo-watch]: https://crates.io/crates/cargo-watch
|
||||
[cargo-fuzz]: https://github.com/rust-fuzz/cargo-fuzz
|
||||
[criterion]: https://github.com/bheisler/criterion.rs
|
||||
[eprintln]: https://doc.rust-lang.org/std/macro.eprintln.html
|
||||
[dbg]: https://doc.rust-lang.org/std/macro.dbg.html
|
||||
|
||||
Ссылка в новой задаче
Block a user