diff --git a/.clippy.toml b/.clippy.toml index 03dc4d3..1d4c5dc 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,5 +1,4 @@ -msrv = "1.76" # MSRV -warn-on-all-wildcard-imports = true +allow-print-in-tests = true allow-expect-in-tests = true allow-unwrap-in-tests = true allow-dbg-in-tests = true diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 1725e3e..7ab13b9 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -3,6 +3,7 @@ 'before 5am on the first day of the month', ], semanticCommits: 'enabled', + commitMessageLowerCase: 'never', configMigration: true, dependencyDashboard: true, customManagers: [ @@ -17,29 +18,28 @@ '^\\.github/workflows/rust-next.yml$', ], matchStrings: [ - 'MSRV.*?(?\\d+\\.\\d+(\\.\\d+)?)', - '(?\\d+\\.\\d+(\\.\\d+)?).*?MSRV', + 'STABLE.*?(?\\d+\\.\\d+(\\.\\d+)?)', + '(?\\d+\\.\\d+(\\.\\d+)?).*?STABLE', ], - depNameTemplate: 'rust', + depNameTemplate: 'STABLE', packageNameTemplate: 'rust-lang/rust', datasourceTemplate: 'github-releases', }, ], packageRules: [ { - commitMessageTopic: 'MSRV', + commitMessageTopic: 'Rust Stable', matchManagers: [ 'custom.regex', ], - matchPackageNames: [ - 'rust', + matchDepNames: [ + 'STABLE', ], - minimumReleaseAge: '126 days', // 3 releases * 6 weeks per release * 7 days per week - internalChecksFilter: 'strict', extractVersion: '^(?\\d+\\.\\d+)', // Drop the patch version schedule: [ '* * * * *', ], + automerge: true, }, // Goals: // - Keep version reqs low, ignoring compatible normal/build dependencies @@ -72,6 +72,7 @@ matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', + 'patch', ], enabled: false, }, @@ -99,6 +100,7 @@ matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', + 'patch', ], automerge: true, groupName: 'compatible (dev)', diff --git a/.github/settings.yml b/.github/settings.yml index de62804..e1ffdd8 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -59,14 +59,18 @@ labels: description: "Call for participation: Help is requested to fix this issue." color: '#02E10C' -branches: - - name: main - protection: - required_pull_request_reviews: null - required_conversation_resolution: true - required_status_checks: - # Required. Require branches to be up to date before merging. - strict: false - contexts: ["CI", "Lint Commits", "Spell Check with Typos"] - enforce_admins: false - restrictions: null +# This serves more as documentation. +# Branch protection API was replaced by rulesets but settings isn't updated. +# See https://github.com/repository-settings/app/issues/825 +# +# branches: +# - name: main +# protection: +# required_pull_request_reviews: null +# required_conversation_resolution: true +# required_status_checks: +# # Required. Require branches to be up to date before merging. +# strict: false +# contexts: ["CI", "Spell Check with Typos"] +# enforce_admins: false +# restrictions: null diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index ccee1fe..a94be15 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -17,6 +17,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: security_audit: permissions: @@ -43,7 +47,7 @@ jobs: - bans licenses sources steps: - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 + - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d68279..6b8a7f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,16 +14,22 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: ci: permissions: contents: none name: CI - needs: [test, msrv, docs, rustfmt, clippy] + needs: [test, msrv, lockfile, docs, rustfmt, clippy, minimal-versions] runs-on: ubuntu-latest + if: "always()" steps: - - name: Done - run: exit 0 + - name: Failed + run: exit 1 + if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')" test: name: Test strategy: @@ -40,16 +46,13 @@ jobs: with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack - name: Build - run: cargo test --no-run --workspace --all-features - - name: Default features - run: cargo test --workspace - - name: All features - run: cargo test --workspace --all-features - - name: No-default features - run: cargo test --workspace --no-default-features + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace msrv: - name: "Check MSRV: 1.76" + name: "Check MSRV" runs-on: ubuntu-latest steps: - name: Checkout repository @@ -57,14 +60,29 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.76" # MSRV + toolchain: stable - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@cargo-hack - name: Default features - run: cargo check --workspace --all-targets - - name: All features - run: cargo check --workspace --all-targets --all-features - - name: No-default features - run: cargo check --workspace --all-targets --no-default-features + run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --workspace --all-targets + minimal-versions: + name: Minimal versions + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install stable Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - name: Install nightly Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + - name: Downgrade dependencies to minimal versions + run: cargo +nightly generate-lockfile -Z minimal-versions + - name: Compile with minimal versions + run: cargo +stable check --workspace --all-features --locked lockfile: runs-on: ubuntu-latest steps: @@ -76,7 +94,7 @@ jobs: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: "Is lockfile updated?" - run: cargo fetch --locked + run: cargo update --workspace --locked docs: name: Docs runs-on: ubuntu-latest @@ -86,7 +104,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: stable + toolchain: "1.85" # STABLE - uses: Swatinem/rust-cache@v2 - name: Check documentation env: @@ -101,9 +119,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - # Not MSRV because its harder to jump between versions and people are - # more likely to have stable - toolchain: stable + toolchain: "1.85" # STABLE components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Check formatting @@ -119,16 +135,16 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.76" # MSRV + toolchain: "1.85" # STABLE components: clippy - uses: Swatinem/rust-cache@v2 - name: Install SARIF tools - run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv + run: cargo install clippy-sarif --locked - name: Install SARIF tools - run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv + run: cargo install sarif-fmt --locked - name: Check run: > - cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated + cargo clippy --workspace --all-features --all-targets --message-format=json | clippy-sarif | tee clippy-results.sarif | sarif-fmt @@ -140,3 +156,22 @@ jobs: wait-for-processing: true - name: Report status run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-tarpaulin + run: cargo install cargo-tarpaulin + - name: Gather coverage + run: cargo tarpaulin --output-dir coverage --out lcov + - name: Publish to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/committed.yml b/.github/workflows/committed.yml index 0462558..e7a50fb 100644 --- a/.github/workflows/committed.yml +++ b/.github/workflows/committed.yml @@ -11,6 +11,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: committed: name: Lint Commits diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 9551407..7b55a3d 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -12,6 +12,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: pre-commit: permissions: @@ -20,4 +24,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.0 + with: + python-version: '3.x' + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml index d8c2d25..e98386c 100644 --- a/.github/workflows/rust-next.yml +++ b/.github/workflows/rust-next.yml @@ -12,6 +12,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: test: name: Test @@ -32,12 +36,11 @@ jobs: with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - - name: Default features - run: cargo test --workspace - - name: All features - run: cargo test --workspace --all-features - - name: No-default features - run: cargo test --workspace --no-default-features + - uses: taiki-e/install-action@cargo-hack + - name: Build + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace latest: name: "Check latest dependencies" runs-on: ubuntu-latest @@ -49,11 +52,10 @@ jobs: with: toolchain: stable - uses: Swatinem/rust-cache@v2 - - name: Update dependencues + - uses: taiki-e/install-action@cargo-hack + - name: Update dependencies run: cargo update - - name: Default features - run: cargo test --workspace --all-targets - - name: All features - run: cargo test --workspace --all-targets --all-features - - name: No-default features - run: cargo test --workspace --all-targets --no-default-features + - name: Build + run: cargo test --workspace --no-run + - name: Test + run: cargo hack test --feature-powerset --workspace diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml index 12f7585..8e58d9e 100644 --- a/.github/workflows/spelling.yml +++ b/.github/workflows/spelling.yml @@ -10,6 +10,10 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: spelling: name: Spell Check with Typos diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6d618b..0db0e30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,18 +7,18 @@ appreciate any level you're willing to do. Need some new functionality to help? You can let us know by opening an [issue][new issue]. It's helpful to look through [all issues][all issues] in -case its already being talked about. +case it's already being talked about. ## Bug Reports Please let us know about what problems you run into, whether in behavior or ergonomics of API. You can do this by opening an [issue][new issue]. It's -helpful to look through [all issues][all issues] in case its already being +helpful to look through [all issues][all issues] in case it's already being talked about. ## Pull Requests -Looking for an idea? Check our [issues][issues]. If it's look more open ended, +Looking for an idea? Check our [issues][issues]. If the issue looks open ended, it is probably best to post on the issue how you are thinking of resolving the issue so you can get feedback early in the process. We want you to be successful and it can be discouraging to find out a lot of re-work is needed. @@ -29,27 +29,45 @@ to re-work some of it and the discouragement that goes along with that. ### Process -Before posting a PR, we request that the commit history get cleaned up. -However, we recommend avoiding this during the review to make it easier to -check how feedback was handled. Once the PR is ready, we'll ask you to clean up -the commit history from the review. Once you let us know this is done, we can -move forward with merging! If you are uncomfortable with these parts of git, -let us know and we can help. - -For commit messages, we use [Conventional](https://www.conventionalcommits.org) -style. If you already wrote your commits and don't feel comfortable changing -them, don't worry and go ahead and create your PR. We'll work with you on the -best route forward. You can check your branch locally with -[`committed`](https://github.com/crate-ci/committed). - As a heads up, we'll be running your PR through the following gauntlet: - warnings turned to compile errors - `cargo test` - `rustfmt` - `clippy` - `rustdoc` -- [`committed`](https://github.com/crate-ci/committed) -- [`typos`](https://github.com/crate-ci/typos) +- [`committed`](https://github.com/crate-ci/committed) as we use [Conventional](https://www.conventionalcommits.org) commit style +- [`typos`](https://github.com/crate-ci/typos) to check spelling + +Not everything can be checked automatically though. + +We request that the commit history gets cleaned up. + +We ask that commits are atomic, meaning they are complete and have a single responsibility. +A complete commit should build, pass tests, update documentation and tests, and not have dead code. + +PRs should tell a cohesive story, with refactor and test commits that keep the +fix or feature commits simple and clear. + +Specifically, we would encourage +- File renames be isolated into their own commit +- Add tests in a commit before their feature or fix, showing the current behavior (i.e. they should pass). + The diff for the feature/fix commit will then show how the behavior changed, + making the commit's intent clearer to reviewers and the community, and showing people that the + test is verifying the expected state. + - e.g. [clap#5520](https://github.com/clap-rs/clap/pull/5520) + +Note that we are talking about ideals. +We understand having a clean history requires more advanced git skills; +feel free to ask us for help! +We might even suggest where it would work to be lax. +We also understand that editing some early commits may cause a lot of churn +with merge conflicts which can make it not worth editing all of the history. + +For code organization, we recommend +- Grouping `impl` blocks next to their type (or trait) +- Grouping private items after the `pub` item that uses them. + - The intent is to help people quickly find the "relevant" details, allowing them to "dig deeper" as needed. Or put another way, the `pub` items serve as a table-of-contents. + - The exact order is fuzzy; do what makes sense ## Releasing diff --git a/Cargo.toml b/Cargo.toml index 3c02c91..b7da065 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = ["crates/*"] [workspace.package] +repository = "REPOSITORY" license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.76" # MSRV @@ -16,3 +17,72 @@ include = [ "benches/**/*", "examples/**/*" ] + +[workspace.lints.rust] +rust_2018_idioms = { level = "warn", priority = -1 } +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +bool_assert_comparison = "allow" +branches_sharing_code = "allow" +checked_conversions = "warn" +collapsible_else_if = "allow" +create_dir = "warn" +dbg_macro = "warn" +debug_assert_with_mut_call = "warn" +doc_markdown = "warn" +empty_enum = "warn" +enum_glob_use = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +float_cmp_const = "warn" +fn_params_excessive_bools = "warn" +from_iter_instead_of_collect = "warn" +if_same_then_else = "allow" +implicit_clone = "warn" +imprecise_flops = "warn" +inconsistent_struct_constructor = "warn" +inefficient_to_string = "warn" +infinite_loop = "warn" +invalid_upcast_comparisons = "warn" +large_digit_groups = "warn" +large_stack_arrays = "warn" +large_types_passed_by_value = "warn" +let_and_return = "allow" # sometimes good to name what you are returning +linkedlist = "warn" +lossy_float_literal = "warn" +macro_use_imports = "warn" +mem_forget = "warn" +mutex_integer = "warn" +needless_continue = "warn" +needless_for_each = "warn" +negative_feature_names = "warn" +path_buf_push_overwrite = "warn" +ptr_as_ptr = "warn" +rc_mutex = "warn" +redundant_feature_names = "warn" +ref_option_ref = "warn" +rest_pat_in_fully_bound_structs = "warn" +result_large_err = "allow" +same_functions_in_if_condition = "warn" +self_named_module_files = "warn" +semicolon_if_nothing_returned = "warn" +str_to_string = "warn" +string_add = "warn" +string_add_assign = "warn" +string_lit_as_bytes = "warn" +string_to_string = "warn" +todo = "warn" +trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" +verbose_file_reads = "warn" +wildcard_imports = "warn" +zero_sized_map_values = "warn" diff --git a/README.md b/README.md index 69cd74a..6fb0897 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,5 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. diff --git a/crates/lexarg-error/Cargo.toml b/crates/lexarg-error/Cargo.toml index a74a388..3614dea 100644 --- a/crates/lexarg-error/Cargo.toml +++ b/crates/lexarg-error/Cargo.toml @@ -2,8 +2,9 @@ name = "lexarg-error" version = "0.1.0" description = "Argument error type for use with lexarg" -keywords = ["args", "arguments", "cli", "parser", "getopt"] categories = ["command-line-interface"] +keywords = ["args", "arguments", "cli", "parser", "getopt"] +repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +12,7 @@ include.workspace = true [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [package.metadata.release] pre-release-replacements = [ @@ -29,3 +30,6 @@ default = [] [dev-dependencies] lexarg = { "version" = "0.1.0", path = "../lexarg" } + +[lints] +workspace = true diff --git a/crates/lexarg-error/README.md b/crates/lexarg-error/README.md index 38044a8..6a55703 100644 --- a/crates/lexarg-error/README.md +++ b/crates/lexarg-error/README.md @@ -10,8 +10,8 @@ Licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. @@ -19,7 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. [Crates.io]: https://crates.io/crates/lexarg-error diff --git a/crates/lexarg-error/src/lib.rs b/crates/lexarg-error/src/lib.rs index 49490e7..4ce37f8 100644 --- a/crates/lexarg-error/src/lib.rs +++ b/crates/lexarg-error/src/lib.rs @@ -68,8 +68,14 @@ //! ``` #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![forbid(unsafe_code)] -#![warn(missing_docs, missing_debug_implementations, elided_lifetimes_in_paths)] +#![warn(missing_debug_implementations)] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; /// `Result` /// diff --git a/crates/lexarg/Cargo.toml b/crates/lexarg/Cargo.toml index 063cd65..ee73cf0 100644 --- a/crates/lexarg/Cargo.toml +++ b/crates/lexarg/Cargo.toml @@ -2,8 +2,9 @@ name = "lexarg" version = "0.1.0" description = "Minimal, API stable CLI parser" -keywords = ["args", "arguments", "cli", "parser", "getopt"] categories = ["command-line-interface"] +keywords = ["args", "arguments", "cli", "parser", "getopt"] +repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +12,7 @@ include.workspace = true [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [package.metadata.release] pre-release-replacements = [ @@ -28,3 +29,6 @@ default = [] [dependencies] [dev-dependencies] + +[lints] +workspace = true diff --git a/crates/lexarg/README.md b/crates/lexarg/README.md index 5164ddd..a96a870 100644 --- a/crates/lexarg/README.md +++ b/crates/lexarg/README.md @@ -10,8 +10,8 @@ Licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. @@ -19,7 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. [Crates.io]: https://crates.io/crates/lexarg diff --git a/crates/lexarg/src/ext.rs b/crates/lexarg/src/ext.rs index 9830acb..0c16c71 100644 --- a/crates/lexarg/src/ext.rs +++ b/crates/lexarg/src/ext.rs @@ -2,13 +2,14 @@ use std::ffi::OsStr; pub(crate) trait OsStrExt: private::Sealed { /// Converts to a string slice. - /// The Utf8Error is guaranteed to have a valid UTF8 boundary + /// The `Utf8Error` is guaranteed to have a valid UTF8 boundary /// in its `valid_up_to()` fn try_str(&self) -> Result<&str, std::str::Utf8Error>; /// Returns `true` if the given pattern matches a sub-slice of /// this string slice. /// /// Returns `false` if it does not. + #[allow(dead_code)] fn contains(&self, needle: &str) -> bool; /// Returns the byte index of the first character of this string slice that /// matches the pattern. @@ -29,6 +30,7 @@ pub(crate) trait OsStrExt: private::Sealed { fn starts_with(&self, prefix: &str) -> bool; /// An iterator over substrings of this string slice, separated by /// characters matched by a pattern. + #[allow(dead_code)] fn split<'s, 'n>(&'s self, needle: &'n str) -> Split<'s, 'n>; /// Splits the string on the first occurrence of the specified delimiter and /// returns prefix before delimiter and suffix after delimiter. @@ -92,17 +94,18 @@ impl OsStrExt for OsStr { } mod private { - pub trait Sealed {} + pub(crate) trait Sealed {} impl Sealed for std::ffi::OsStr {} } -pub struct Split<'s, 'n> { +#[allow(dead_code)] +pub(crate) struct Split<'s, 'n> { haystack: Option<&'s OsStr>, needle: &'n str, } -impl<'s, 'n> Iterator for Split<'s, 'n> { +impl<'s> Iterator for Split<'s, '_> { type Item = &'s OsStr; fn next(&mut self) -> Option { @@ -129,10 +132,12 @@ impl<'s, 'n> Iterator for Split<'s, 'n> { /// /// `index` must be at a valid UTF-8 boundary pub(crate) unsafe fn split_at(os: &OsStr, index: usize) -> (&OsStr, &OsStr) { - let bytes = os.as_encoded_bytes(); - let (first, second) = bytes.split_at(index); - ( - OsStr::from_encoded_bytes_unchecked(first), - OsStr::from_encoded_bytes_unchecked(second), - ) + unsafe { + let bytes = os.as_encoded_bytes(); + let (first, second) = bytes.split_at(index); + ( + OsStr::from_encoded_bytes_unchecked(first), + OsStr::from_encoded_bytes_unchecked(second), + ) + } } diff --git a/crates/lexarg/src/lib.rs b/crates/lexarg/src/lib.rs index cbba8fe..6dc1052 100644 --- a/crates/lexarg/src/lib.rs +++ b/crates/lexarg/src/lib.rs @@ -65,7 +65,14 @@ //! ``` #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![warn(missing_docs, missing_debug_implementations, elided_lifetimes_in_paths)] +#![warn(missing_debug_implementations)] +#![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; mod ext; @@ -410,7 +417,7 @@ enum State<'a> { Escaped, } -impl<'a> State<'a> { +impl State<'_> { #[cfg(test)] fn has_pending(&self) -> bool { match self { @@ -448,7 +455,7 @@ fn split_nonutf8_once(b: &OsStr) -> (&str, Option<&OsStr>) { } mod private { - use super::*; + use super::OsStr; pub trait Sealed {} impl Sealed for [S; C] where S: AsRef + std::fmt::Debug {} @@ -777,7 +784,7 @@ mod tests { } permutations = new; for permutation in &permutations { - println!("Starting {:?}", permutation); + println!("Starting {permutation:?}"); let p = Parser::new(permutation); exhaust(p, vec![]); } @@ -787,7 +794,7 @@ mod tests { /// Run many sequences of methods on a Parser. fn exhaust(parser: Parser<'_>, path: Vec) { if path.len() > 100 { - panic!("Stuck in loop: {:?}", path); + panic!("Stuck in loop: {path:?}"); } if parser.has_pending() { @@ -799,7 +806,7 @@ mod tests { "{next:?} via {path:?}", ); let mut path = path.clone(); - path.push(format!("pending-next-{:?}", next)); + path.push(format!("pending-next-{next:?}")); exhaust(parser, path); } @@ -808,7 +815,7 @@ mod tests { let next = parser.flag_value(); assert!(next.is_some(), "{next:?} via {path:?}",); let mut path = path; - path.push(format!("pending-value-{:?}", next)); + path.push(format!("pending-value-{next:?}")); exhaust(parser, path); } } else { @@ -825,8 +832,8 @@ mod tests { } _ => { let mut path = path.clone(); - path.push(format!("next-{:?}", next)); - exhaust(parser, path) + path.push(format!("next-{next:?}")); + exhaust(parser, path); } } } @@ -850,7 +857,7 @@ mod tests { "{next:?} via {path:?}", ); let mut path = path; - path.push(format!("value-{:?}", next)); + path.push(format!("value-{next:?}")); exhaust(parser, path); } } diff --git a/crates/libtest2-harness/Cargo.toml b/crates/libtest2-harness/Cargo.toml index 3058c22..7a5026a 100644 --- a/crates/libtest2-harness/Cargo.toml +++ b/crates/libtest2-harness/Cargo.toml @@ -2,8 +2,9 @@ name = "libtest2-harness" version = "0.1.0" description = "An experimental replacement for the core of libtest" -keywords = ["libtest"] categories = ["development-tools::testing"] +keywords = ["libtest"] +repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +12,7 @@ include.workspace = true [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [package.metadata.release] pre-release-replacements = [ @@ -38,3 +39,6 @@ serde = { version = "1.0.160", features = ["derive"], optional = true } serde_json = { version = "1.0.96", optional = true } [dev-dependencies] + +[lints] +workspace = true diff --git a/crates/libtest2-harness/README.md b/crates/libtest2-harness/README.md index 1ad8734..0a29385 100644 --- a/crates/libtest2-harness/README.md +++ b/crates/libtest2-harness/README.md @@ -10,8 +10,8 @@ Licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. @@ -19,7 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. [Crates.io]: https://crates.io/crates/libtest2-harness diff --git a/crates/libtest2-harness/src/case.rs b/crates/libtest2-harness/src/case.rs index f37a551..7dc9e94 100644 --- a/crates/libtest2-harness/src/case.rs +++ b/crates/libtest2-harness/src/case.rs @@ -1,4 +1,4 @@ -pub use crate::*; +pub(crate) use crate::*; pub trait Case: Send + Sync + 'static { /// The name of a test diff --git a/crates/libtest2-harness/src/harness.rs b/crates/libtest2-harness/src/harness.rs index 840919c..7840ef4 100644 --- a/crates/libtest2-harness/src/harness.rs +++ b/crates/libtest2-harness/src/harness.rs @@ -1,6 +1,6 @@ use libtest_lexarg::OutputFormat; -use crate::*; +use crate::{cli, notify, shuffle, Case, RunError, RunMode, State}; pub struct Harness { raw: Vec, @@ -33,7 +33,7 @@ impl Harness { pub fn main(mut self) -> ! { let mut parser = cli::Parser::new(&self.raw); let opts = parse(&mut parser).unwrap_or_else(|err| { - eprintln!("{}", err); + eprintln!("{err}"); std::process::exit(1) }); @@ -45,11 +45,11 @@ impl Harness { .write_global(); let mut notifier = notifier(&opts).unwrap_or_else(|err| { - eprintln!("{}", err); + eprintln!("{err}"); std::process::exit(1) }); discover(&opts, &mut self.cases, notifier.as_mut()).unwrap_or_else(|err| { - eprintln!("{}", err); + eprintln!("{err}"); std::process::exit(1) }); @@ -70,7 +70,7 @@ impl Harness { const ERROR_EXIT_CODE: i32 = 101; -fn parse(parser: &mut cli::Parser) -> cli::Result { +fn parse(parser: &mut cli::Parser<'_>) -> cli::Result { let mut test_opts = libtest_lexarg::TestOptsParseState::new(); let bin = parser.bin(); @@ -194,7 +194,7 @@ fn discover( retain_cases.push(retain_case); notifier.notify(notify::Event::DiscoverCase { name: case.name().to_owned(), - mode: notify::RunMode::Test, + mode: RunMode::Test, run: retain_case, })?; } @@ -253,8 +253,8 @@ fn run( "`--test` and `-bench` are mutually exclusive", )); } - (true, false) => notify::RunMode::Test, - (false, true) => notify::RunMode::Bench, + (true, false) => RunMode::Test, + (false, true) => RunMode::Bench, (false, false) => unreachable!("libtest-lexarg` should always ensure at least one is set"), }; state.set_mode(mode); @@ -309,7 +309,7 @@ fn run( let case = remaining.pop_front().unwrap(); let name = case.name().to_owned(); - let cfg = std::thread::Builder::new().name(name.to_owned()); + let cfg = std::thread::Builder::new().name(name.clone()); let tx = tx.clone(); let case = std::sync::Arc::new(case); let case_fallback = case.clone(); @@ -402,7 +402,7 @@ fn run_case( let msg = match payload { Some(payload) => format!("test panicked: {payload}"), - None => "test panicked".to_string(), + None => "test panicked".to_owned(), }; Err(RunError::fail(msg)) }); @@ -412,7 +412,7 @@ fn run_case( let message = err.and_then(|e| e.cause().map(|c| c.to_string())); notifier.notify(notify::Event::CaseComplete { name: case.name().to_owned(), - mode: notify::RunMode::Test, + mode: RunMode::Test, status, message, elapsed_s: Some(notify::Elapsed(timer.elapsed())), diff --git a/crates/libtest2-harness/src/lib.rs b/crates/libtest2-harness/src/lib.rs index 4f76785..3308621 100644 --- a/crates/libtest2-harness/src/lib.rs +++ b/crates/libtest2-harness/src/lib.rs @@ -21,6 +21,13 @@ //! #![cfg_attr(docsrs, feature(doc_auto_cfg))] +// #![warn(clippy::print_stderr)] +// #![warn(clippy::print_stdout)] +#![allow(clippy::todo)] + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; mod case; mod harness; diff --git a/crates/libtest2-harness/src/notify/json.rs b/crates/libtest2-harness/src/notify/json.rs index 3597933..69eb9af 100644 --- a/crates/libtest2-harness/src/notify/json.rs +++ b/crates/libtest2-harness/src/notify/json.rs @@ -14,7 +14,7 @@ impl JsonNotifier { impl super::Notifier for JsonNotifier { fn notify(&mut self, event: Event) -> std::io::Result<()> { let event = serde_json::to_string(&event)?; - writeln!(self.writer, "{}", event)?; + writeln!(self.writer, "{event}")?; Ok(()) } } diff --git a/crates/libtest2-harness/src/notify/summary.rs b/crates/libtest2-harness/src/notify/summary.rs index e684c11..0de6cc8 100644 --- a/crates/libtest2-harness/src/notify/summary.rs +++ b/crates/libtest2-harness/src/notify/summary.rs @@ -59,8 +59,8 @@ impl Summary { // Print messages of all tests for (name, msg) in &self.failures { if let Some(msg) = msg { - writeln!(writer, "---- {} ----", name)?; - writeln!(writer, "{}", msg)?; + writeln!(writer, "---- {name} ----")?; + writeln!(writer, "{msg}")?; writeln!(writer)?; } } @@ -69,7 +69,7 @@ impl Summary { writeln!(writer)?; writeln!(writer, "failures:")?; for name in self.failures.keys() { - writeln!(writer, " {}", name)?; + writeln!(writer, " {name}")?; } } writeln!(writer)?; diff --git a/crates/libtest2-harness/src/shuffle.rs b/crates/libtest2-harness/src/shuffle.rs index 9dbf710..444e664 100644 --- a/crates/libtest2-harness/src/shuffle.rs +++ b/crates/libtest2-harness/src/shuffle.rs @@ -4,7 +4,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use crate::Case; -pub fn get_shuffle_seed(opts: &libtest_lexarg::TestOpts) -> Option { +pub(crate) fn get_shuffle_seed(opts: &libtest_lexarg::TestOpts) -> Option { opts.shuffle_seed.or_else(|| { opts.shuffle.then(|| { SystemTime::now() @@ -15,7 +15,7 @@ pub fn get_shuffle_seed(opts: &libtest_lexarg::TestOpts) -> Option { }) } -pub fn shuffle_tests(shuffle_seed: u64, tests: &mut [Box]) { +pub(crate) fn shuffle_tests(shuffle_seed: u64, tests: &mut [Box]) { let test_names: Vec<&str> = tests.iter().map(|test| test.name()).collect(); let test_names_hash = calculate_hash(&test_names); let mut rng = Rng::new(shuffle_seed, test_names_hash); diff --git a/crates/libtest2-harness/src/state.rs b/crates/libtest2-harness/src/state.rs index 939bba3..3253954 100644 --- a/crates/libtest2-harness/src/state.rs +++ b/crates/libtest2-harness/src/state.rs @@ -1,8 +1,8 @@ -pub use crate::*; +pub(crate) use crate::*; #[derive(Debug)] pub struct State { - mode: notify::RunMode, + mode: RunMode, run_ignored: bool, } @@ -23,7 +23,7 @@ impl State { } } - pub fn current_mode(&self) -> notify::RunMode { + pub fn current_mode(&self) -> RunMode { self.mode } } @@ -36,7 +36,7 @@ impl State { } } - pub(crate) fn set_mode(&mut self, mode: notify::RunMode) { + pub(crate) fn set_mode(&mut self, mode: RunMode) { self.mode = mode; } diff --git a/crates/libtest2-mimic/Cargo.toml b/crates/libtest2-mimic/Cargo.toml index 76e227b..632c31d 100644 --- a/crates/libtest2-mimic/Cargo.toml +++ b/crates/libtest2-mimic/Cargo.toml @@ -2,8 +2,9 @@ name = "libtest2-mimic" version = "0.1.0" description = "An experimental replacement for libtest-mimic" -keywords = ["libtest"] categories = ["development-tools::testing"] +keywords = ["libtest"] +repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +12,7 @@ include.workspace = true [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [package.metadata.release] pre-release-replacements = [ @@ -38,3 +39,6 @@ escargot = "0.5.8" once_cell = "1.19.0" pathdiff = "0.2.1" snapbox = "0.5.0" + +[lints] +workspace = true diff --git a/crates/libtest2-mimic/README.md b/crates/libtest2-mimic/README.md index 8be596a..11af8e5 100644 --- a/crates/libtest2-mimic/README.md +++ b/crates/libtest2-mimic/README.md @@ -10,8 +10,8 @@ Licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. @@ -19,7 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. [Crates.io]: https://crates.io/crates/libtest2-mimic diff --git a/crates/libtest2-mimic/src/lib.rs b/crates/libtest2-mimic/src/lib.rs index 6593641..cf568bf 100644 --- a/crates/libtest2-mimic/src/lib.rs +++ b/crates/libtest2-mimic/src/lib.rs @@ -21,6 +21,12 @@ //! #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; pub use libtest2_harness::Harness; pub use libtest2_harness::RunError; diff --git a/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs b/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs index 35eb643..38e5938 100644 --- a/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2-mimic/tests/testsuite/mixed_bag.rs @@ -101,7 +101,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -148,7 +148,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -195,7 +195,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -227,7 +227,7 @@ owl: test 8 tests "#, - ) + ); } #[test] @@ -302,7 +302,7 @@ running 2 tests test result: ok. 1 passed; 0 failed; 1 ignored; 6 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -376,7 +376,7 @@ failures: test result: FAILED. 2 passed; 2 failed; 0 ignored; 4 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -427,7 +427,7 @@ failures: test result: FAILED. 2 passed; 2 failed; 0 ignored; 4 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -498,7 +498,7 @@ failures: test result: FAILED. 4 passed; 4 failed; 0 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -569,7 +569,7 @@ failures: test result: FAILED. 4 passed; 4 failed; 0 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -610,7 +610,7 @@ failures: test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -641,7 +641,7 @@ fn list_json() { {"event":"discover-case","name":"owl","mode":"test","run":false} {"event":"discover-complete","elapsed_s":"[..]","seed":null} "#, - ) + ); } #[test] @@ -684,7 +684,7 @@ fn test_json() { [..] {"event":"suite-complete","elapsed_s":"[..]"} "#, - ) + ); } #[test] @@ -705,7 +705,7 @@ cat: test 2 tests "#, - ) + ); } #[test] @@ -732,7 +732,7 @@ fn test_junit() { "#, - ) + ); } #[test] @@ -770,7 +770,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] diff --git a/crates/libtest2-mimic/tests/testsuite/util.rs b/crates/libtest2-mimic/tests/testsuite/util.rs index b7ebdd4..993777e 100644 --- a/crates/libtest2-mimic/tests/testsuite/util.rs +++ b/crates/libtest2-mimic/tests/testsuite/util.rs @@ -70,7 +70,7 @@ fn tempdir() -> std::path::PathBuf { } mod tests { - pub fn compile_test( + pub(super) fn compile_test( manifest_path: &std::path::Path, target_name: &str, args: impl IntoIterator>, @@ -93,12 +93,12 @@ mod tests { } } - panic!("Unknown error building test {}", target_name) + panic!("Unknown error building test {target_name}") } #[allow(clippy::type_complexity)] fn decode_test_message<'m>( - message: &'m escargot::format::Message, + message: &'m escargot::format::Message<'_>, ) -> Option<(&'m str, std::path::PathBuf)> { match message { escargot::format::Message::CompilerMessage(msg) => { @@ -133,7 +133,7 @@ mod tests { } } - fn is_test_target(target: &escargot::format::Target) -> bool { + fn is_test_target(target: &escargot::format::Target<'_>) -> bool { target.crate_types == ["bin"] && target.kind == ["test"] } } diff --git a/crates/libtest2/Cargo.toml b/crates/libtest2/Cargo.toml index fa6844a..8f5644f 100644 --- a/crates/libtest2/Cargo.toml +++ b/crates/libtest2/Cargo.toml @@ -2,8 +2,9 @@ name = "libtest2" version = "0.1.0" description = "An experimental replacement for libtest" -keywords = ["libtest"] categories = ["development-tools::testing"] +keywords = ["libtest"] +repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true @@ -11,7 +12,7 @@ include.workspace = true [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [package.metadata.release] pre-release-replacements = [ @@ -38,3 +39,6 @@ escargot = "0.5.8" once_cell = "1.19.0" pathdiff = "0.2.1" snapbox = "0.5.0" + +[lints] +workspace = true diff --git a/crates/libtest2/README.md b/crates/libtest2/README.md index a20a36b..b916e63 100644 --- a/crates/libtest2/README.md +++ b/crates/libtest2/README.md @@ -10,8 +10,8 @@ Licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ) +* MIT license ([LICENSE-MIT](LICENSE-MIT) or ) at your option. @@ -19,7 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or +license, shall be dual-licensed as above, without any additional terms or conditions. [Crates.io]: https://crates.io/crates/libtest2 diff --git a/crates/libtest2/src/lib.rs b/crates/libtest2/src/lib.rs index 802886b..5c4a6a4 100644 --- a/crates/libtest2/src/lib.rs +++ b/crates/libtest2/src/lib.rs @@ -21,6 +21,12 @@ //! #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; pub use libtest2_harness::Harness; pub use libtest2_harness::RunError; diff --git a/crates/libtest2/tests/testsuite/mixed_bag.rs b/crates/libtest2/tests/testsuite/mixed_bag.rs index f2bb2bb..97a3e3d 100644 --- a/crates/libtest2/tests/testsuite/mixed_bag.rs +++ b/crates/libtest2/tests/testsuite/mixed_bag.rs @@ -108,7 +108,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -155,7 +155,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -202,7 +202,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -234,7 +234,7 @@ owl: test 8 tests "#, - ) + ); } #[test] @@ -309,7 +309,7 @@ running 2 tests test result: ok. 1 passed; 0 failed; 1 ignored; 6 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -383,7 +383,7 @@ failures: test result: FAILED. 2 passed; 2 failed; 0 ignored; 4 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -434,7 +434,7 @@ failures: test result: FAILED. 2 passed; 2 failed; 0 ignored; 4 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -505,7 +505,7 @@ failures: test result: FAILED. 4 passed; 4 failed; 0 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -576,7 +576,7 @@ failures: test result: FAILED. 4 passed; 4 failed; 0 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -617,7 +617,7 @@ failures: test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in [..]s "#, - ) + ); } #[test] @@ -648,7 +648,7 @@ fn list_json() { {"event":"discover-case","name":"owl","mode":"test","run":false} {"event":"discover-complete","elapsed_s":"[..]","seed":null} "#, - ) + ); } #[test] @@ -691,7 +691,7 @@ fn test_json() { [..] {"event":"suite-complete","elapsed_s":"[..]"} "#, - ) + ); } #[test] @@ -712,7 +712,7 @@ cat: test 2 tests "#, - ) + ); } #[test] @@ -739,7 +739,7 @@ fn test_junit() { "#, - ) + ); } #[test] @@ -777,7 +777,7 @@ failures: test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in [..]s "#, - ) + ); } #[test] diff --git a/crates/libtest2/tests/testsuite/util.rs b/crates/libtest2/tests/testsuite/util.rs index a4a81c3..158d58a 100644 --- a/crates/libtest2/tests/testsuite/util.rs +++ b/crates/libtest2/tests/testsuite/util.rs @@ -70,7 +70,7 @@ fn tempdir() -> std::path::PathBuf { } mod tests { - pub fn compile_test( + pub(super) fn compile_test( manifest_path: &std::path::Path, target_name: &str, args: impl IntoIterator>, @@ -93,12 +93,12 @@ mod tests { } } - panic!("Unknown error building test {}", target_name) + panic!("Unknown error building test {target_name}") } #[allow(clippy::type_complexity)] fn decode_test_message<'m>( - message: &'m escargot::format::Message, + message: &'m escargot::format::Message<'_>, ) -> Option<(&'m str, std::path::PathBuf)> { match message { escargot::format::Message::CompilerMessage(msg) => { @@ -133,7 +133,7 @@ mod tests { } } - fn is_test_target(target: &escargot::format::Target) -> bool { + fn is_test_target(target: &escargot::format::Target<'_>) -> bool { target.crate_types == ["bin"] && target.kind == ["test"] } } diff --git a/deny.toml b/deny.toml index 21fa937..ee5ae89 100644 --- a/deny.toml +++ b/deny.toml @@ -4,32 +4,82 @@ # * allow - No warning or error will be produced, though in some cases a note # will be +# Root options + +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +targets = [ + # The triple can be any string, but only the target triples built in to + # rustc (as of 1.40) can be checked against actual config expressions + #"x86_64-unknown-linux-musl", + # You can also specify which target_features you promise are enabled for a + # particular target. target_features are currently not validated against + # the actual valid features supported by the target architecture. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, +] +# When creating the dependency graph used as the source of truth when checks are +# executed, this field can be used to prune crates from the graph, removing them +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = false +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] -# The lint level for security vulnerabilities -vulnerability = "deny" -# The lint level for unmaintained crates -unmaintained = "warn" -# The lint level for crates that have been yanked from their source registry -yanked = "warn" -# The lint level for crates with security notices. Note that as of -# 2019-12-17 there are no security notice advisories in -# https://github.com/rustsec/advisory-db -notice = "warn" +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" +# The url(s) of the advisory databases to use +#db-urls = ["https://github.com/rustsec/advisory-db"] # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. -# -# e.g. "RUSTSEC-0000-0000", ignore = [ + #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, ] +# If this is true, then cargo deny will use the git executable to fetch advisory database. +# If this is false, then it uses a built-in git library. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true # This section is considered when running `cargo deny check licenses` # More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -unlicensed = "deny" # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. @@ -37,31 +87,14 @@ allow = [ "MIT", "MIT-0", "Apache-2.0", + "BSD-2-Clause", "BSD-3-Clause", "MPL-2.0", "Unicode-DFS-2016", "CC0-1.0", "ISC", + "OpenSSL", ] -# List of explicitly disallowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. -deny = [ -] -# Lint level for licenses considered copyleft -copyleft = "deny" -# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses -# * both - The license will be approved if it is both OSI-approved *AND* FSF -# * either - The license will be approved if it is either OSI-approved *OR* FSF -# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF -# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved -# * neither - This predicate is ignored and the default lint level is used -allow-osi-fsf-free = "neither" -# Lint level used when no other predicates are matched -# 1. License isn't in the allow or deny lists -# 2. License isn't copyleft -# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" -default = "deny" # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. @@ -72,7 +105,25 @@ confidence-threshold = 0.8 exceptions = [ # Each entry is the crate and version constraint, and its specific allow # list - #{ allow = ["Zlib"], name = "adler32", version = "*" }, + #{ allow = ["Zlib"], crate = "adler32" }, +] + +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +[[licenses.clarify]] +# The package spec the clarification applies to +crate = "ring" +# The SPDX expression for the license requirements of the crate +expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# and the crate will be checked normally, which may produce warnings or errors +# depending on the rest of your configuration +license-files = [ +# Each entry is a crate relative path, and the (opaque) hash of its contents +{ path = "LICENSE", hash = 0xbd0eed23 } ] [licenses.private] @@ -81,6 +132,12 @@ exceptions = [ # To see how to mark a crate as unpublished (to the official registry), # visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. ignore = true +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: @@ -89,7 +146,7 @@ ignore = true # Lint level for when multiple versions of the same crate are detected multiple-versions = "warn" # Lint level for when a crate version requirement is `*` -wildcards = "warn" +wildcards = "allow" # The graph highlighting used when creating dotgraphs for crates # with multiple versions # * lowest-version - The path to the lowest versioned duplicate is highlighted @@ -106,17 +163,53 @@ workspace-default-features = "allow" external-default-features = "allow" # List of crates that are allowed. Use with care! allow = [ - #{ name = "ansi_term", version = "=0.11.0" }, + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, ] # List of crates to deny deny = [ - # Each entry the name of a crate and a version range. If version is - # not specified, all versions will be matched. - #{ name = "ansi_term", version = "=0.11.0" }, - # + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, # Wrapper crates can optionally be specified to allow the crate when it # is a direct dependency of the otherwise banned crate - #{ name = "ansi_term", version = "=0.11.0", wrappers = [] }, + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#crate = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true + +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, +] +# Similarly to `skip` allows you to skip certain crates during duplicate +# detection. Unlike skip, it also includes the entire tree of transitive +# dependencies starting at the specified crate, up to a certain depth, which is +# by default infinite. +skip-tree = [ + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, ] # This section is considered when running `cargo deny check sources`. @@ -138,3 +231,7 @@ allow-git = [] [sources.allow-org] # 1 or more github.com organizations to allow git sources for github = [] +# 1 or more gitlab.com organizations to allow git sources for +gitlab = [] +# 1 or more bitbucket.org organizations to allow git sources for +bitbucket = []