2023-03-03 17:42:38 +00:00
# Documentation
2021-08-24 20:35:41 +00:00
The source of the documentation is available on:
2023-03-03 17:42:38 +00:00
< https: / / uutils . github . io / dev / coreutils / >
2021-08-24 20:35:41 +00:00
The documentation is updated everyday on this repository:
2023-03-03 17:42:38 +00:00
< https: / / github . com / uutils / uutils . github . io / >
2021-08-24 20:35:41 +00:00
2023-03-03 17:42:38 +00:00
## Running GNU tests
2021-08-26 09:49:45 +00:00
2021-08-26 10:00:27 +00:00
<!-- spell - checker:ignore gnulib -->
2023-03-03 17:42:38 +00:00
- Check out < https: // github . com / coreutils / coreutils > next to your fork as gnu
- Check out < https: // github . com / coreutils / gnulib > next to your fork as gnulib
2021-08-26 09:49:45 +00:00
- Rename the checkout of your fork to uutils
At the end you should have uutils, gnu and gnulib checked out next to each other.
- Run `cd uutils && ./util/build-gnu.sh && cd ..` to get everything ready (this may take a while)
2022-09-16 08:26:29 +00:00
- Finally, you can run tests with `bash uutils/util/run-gnu-test.sh <tests>` . Instead of `<tests>` insert the tests you want to run, e.g. `tests/misc/wc-proc.sh` .
2021-08-26 09:49:45 +00:00
2023-03-03 17:42:38 +00:00
## Code Coverage Report Generation
2021-03-30 06:33:24 +00:00
2021-05-31 02:55:48 +00:00
<!-- spell - checker:ignore (flags) Ccodegen Coverflow Cpanic Zinstrument Zpanic -->
2021-03-30 06:33:24 +00:00
Code coverage report can be generated using [grcov ](https://github.com/mozilla/grcov ).
### Using Nightly Rust
2022-02-03 10:03:48 +00:00
To generate [gcov-based ](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project ) coverage report
2021-03-30 06:33:24 +00:00
```bash
2023-03-03 17:42:38 +00:00
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
cargo build < options... > # e.g., --features feat_os_unix
cargo test < options... > # e.g., --features feat_os_unix test_pathchk
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/
# open target/debug/coverage/index.html in browser
2021-03-30 06:33:24 +00:00
```
2021-05-31 02:55:48 +00:00
if changes are not reflected in the report then run `cargo clean` and run the above commands.
2021-03-30 06:33:24 +00:00
### Using Stable Rust
2021-05-30 10:42:46 +00:00
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
2021-03-30 06:33:24 +00:00
then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above.
2023-03-03 17:42:38 +00:00
## pre-commit hooks
2021-03-30 19:39:24 +00:00
A configuration for `pre-commit` is provided in the repository. It allows automatically checking every git commit you make to ensure it compiles, and passes `clippy` and `rustfmt` without warnings.
To use the provided hook:
1. [Install `pre-commit` ](https://pre-commit.com/#install )
2023-03-03 17:42:38 +00:00
1. Run `pre-commit install` while in the repository directory
2021-03-30 19:39:24 +00:00
Your git commits will then automatically be checked. If a check fails, an error message will explain why, and your commit will be canceled. You can then make the suggested changes, and run `git commit ...` again.
2021-05-30 10:42:46 +00:00
2023-03-03 17:42:38 +00:00
## Using Clippy
2021-05-30 10:42:46 +00:00
The `msrv` key in the clippy configuration file `clippy.toml` is used to disable lints pertaining to newer features by specifying the minimum supported Rust version (MSRV). However, this key is only supported on `nightly` . To invoke clippy without errors, use `cargo +nightly clippy` . In order to also check tests and non-default crate features, use `cargo +nightly clippy --all-targets --all-features` .
2023-03-04 17:31:53 +00:00
## Markdown linter
We use < https: / / github . com / DavidAnson / markdownlint > to lint the Markdown files.