diff --git a/.clippy.toml b/.clippy.toml index 68e430e..027eef4 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,5 +1,5 @@ -msrv = "1.74" # 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..c184420 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', + '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 1591e85..6f80f01 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -42,14 +42,18 @@ labels: color: '#c2e0c6' description: "Help wanted!" -branches: - - name: master - 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: master +# 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 442e637..35b3da8 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: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 351716f..504d777 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,21 +14,27 @@ 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] 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: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest", "macos-14"] rust: ["stable"] continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} @@ -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.74" + name: "Check MSRV" runs-on: ubuntu-latest steps: - name: Checkout repository @@ -57,14 +60,11 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.74" # 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 lockfile: runs-on: ubuntu-latest steps: @@ -76,7 +76,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 +86,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: stable + toolchain: "1.76" # STABLE - uses: Swatinem/rust-cache@v2 - name: Check documentation env: @@ -101,9 +101,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.76" # STABLE components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Check formatting @@ -119,13 +117,13 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.74" # MSRV + toolchain: "1.76" # 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 @@ -140,3 +138,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 b2e94d4..3d04055 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,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml index 3828a4d..17da987 100644 --- a/.github/workflows/rust-next.yml +++ b/.github/workflows/rust-next.yml @@ -12,12 +12,16 @@ env: CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: test: name: Test strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest", "macos-latest", "macos-14"] rust: ["stable", "beta"] include: - os: ubuntu-latest @@ -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 + - uses: taiki-e/install-action@cargo-hack - name: Update dependencues 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/Cargo.lock b/Cargo.lock index fca4ee1..bf536a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "automod" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -85,6 +96,7 @@ name = "escargot" version = "0.5.10" dependencies = [ "assert_fs", + "automod", "log", "once_cell", "serde", @@ -235,18 +247,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -318,7 +330,7 @@ checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.105", ] [[package]] @@ -343,6 +355,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.3.0" diff --git a/Cargo.toml b/Cargo.toml index f8b416c..b031598 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,7 @@ -[package] -name = "escargot" -version = "0.5.10" -description = "Cargo API written in Paris" -authors = ["Ed Page "] -repository = "https://github.com/crate-ci/escargot.git" -homepage = "https://github.com/crate-ci/escargot" -documentation = "http://docs.rs/escargot/" -readme = "README.md" -categories = ["development-tools::build-utils"] -keywords = ["cargo", "packaging"] +[workspace] +resolver = "2" + +[workspace.package] license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.74" # MSRV @@ -23,6 +16,89 @@ include = [ "examples/**/*" ] +[workspace.lints.rust] +rust_2018_idioms = "warn" +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" +items_after_statements = "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" +match_wildcard_for_single_variants = "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" +same_functions_in_if_condition = "warn" +self_named_module_files = "warn" +semicolon_if_nothing_returned = "warn" +single_match_else = "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" +verbose_file_reads = "warn" +wildcard_imports = "warn" +zero_sized_map_values = "warn" + +[package] +name = "escargot" +version = "0.5.10" +description = "Cargo API written in Paris" +repository = "https://github.com/crate-ci/escargot.git" +homepage = "https://github.com/crate-ci/escargot" +categories = ["development-tools::build-utils"] +keywords = ["cargo", "packaging"] +license.workspace = true +edition.workspace = true +rust-version.workspace = true +include.workspace = true + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] @@ -36,15 +112,6 @@ pre-release-replacements = [ {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/crate-ci/escargot/compare/{{tag_name}}...HEAD", exactly=1}, ] -[dependencies] -serde = { version = "1.0.113", features = ["derive"] } -serde_json = "1.0" -once_cell = "1.2.0" -log = "0.4.4" - -[dev-dependencies] -assert_fs = "1.1" - [features] # Upcoming features in cargo. cargo_unstable = [] @@ -56,3 +123,16 @@ strict_unstable = [] # This is for when using `escargot` in tests and you want logged output to # instead be printed because no logger is configured. print = [] + +[dependencies] +serde = { version = "1.0.113", features = ["derive"] } +serde_json = "1.0" +once_cell = "1.2.0" +log = "0.4.4" + +[dev-dependencies] +assert_fs = "1.1" +automod = "1.0.14" + +[lints] +workspace = true diff --git a/src/build.rs b/src/build.rs index 15f36f8..ea5ad96 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,10 +1,10 @@ -use std::ffi::{self, OsStr}; +use std::ffi::OsStr; use std::process; use crate::cargo::Cargo; use crate::cargo::CURRENT_TARGET; -use crate::error::*; -use crate::msg::*; +use crate::error::{CargoError, CargoResult}; +use crate::msg::CommandMessages; use crate::run::CargoRun; #[cfg(feature = "test_unstable")] use crate::test::CargoTest; @@ -22,7 +22,7 @@ use crate::test::CargoTest; /// .bin("bin") /// .current_release() /// .current_target() -/// .manifest_path("tests/fixtures/bin/Cargo.toml") +/// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); @@ -47,7 +47,7 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .bin("bin") - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); @@ -77,12 +77,12 @@ impl CargoBuild { /// escargot::CargoBuild::new() /// .package("bin") /// .bin("bin") - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); /// ``` - pub fn package>(self, name: S) -> Self { + pub fn package>(self, name: S) -> Self { self.arg("--package").arg(name) } @@ -97,7 +97,7 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .bins() - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); @@ -118,12 +118,12 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .bin("bin") - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); /// ``` - pub fn bin>(mut self, name: S) -> Self { + pub fn bin>(mut self, name: S) -> Self { self.bin = true; self.arg("--bin").arg(name) } @@ -139,7 +139,7 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .examples() - /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/example/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); @@ -160,12 +160,12 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .example("example_fixture") - /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/example/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); /// ``` - pub fn example>(mut self, name: S) -> Self { + pub fn example>(mut self, name: S) -> Self { self.example = true; self.arg("--example").arg(name) } @@ -181,7 +181,7 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .tests() - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); @@ -201,17 +201,17 @@ impl CargoBuild { /// let temp = assert_fs::TempDir::new().unwrap(); /// escargot::CargoBuild::new() /// .test("test") - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .exec() /// .unwrap(); /// ``` - pub fn test>(self, name: S) -> Self { + pub fn test>(self, name: S) -> Self { self.arg("--test").arg(name) } /// Path to Cargo.toml - pub fn manifest_path>(self, path: S) -> Self { + pub fn manifest_path>(self, path: S) -> Self { self.arg("--manifest-path").arg(path) } @@ -253,7 +253,7 @@ impl CargoBuild { } /// Build for the target triplet. - pub fn target>(self, triplet: S) -> Self { + pub fn target>(self, triplet: S) -> Self { self.arg("--target").arg(triplet) } @@ -263,7 +263,7 @@ impl CargoBuild { } /// Directory for all generated artifacts - pub fn target_dir>(self, dir: S) -> Self { + pub fn target_dir>(self, dir: S) -> Self { self.arg("--target-dir").arg(dir) } @@ -278,14 +278,14 @@ impl CargoBuild { } /// Space-separated list of features to activate - pub fn features>(self, features: S) -> Self { + pub fn features>(self, features: S) -> Self { self.arg("--features").arg(features) } /// Manually pass an argument that is unsupported. /// /// Caution: Passing in `--` can throw off the API. - pub fn arg>(mut self, arg: S) -> Self { + pub fn arg>(mut self, arg: S) -> Self { self.cmd.arg(arg); self } @@ -293,7 +293,7 @@ impl CargoBuild { /// Manually pass arguments that are unsupported. /// /// Caution: Passing in `--` can throw off the API. - pub fn args, S: AsRef>(mut self, args: I) -> Self { + pub fn args, S: AsRef>(mut self, args: I) -> Self { self.cmd.args(args); self } @@ -316,7 +316,7 @@ impl CargoBuild { /// .bin("bin") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap(); @@ -342,7 +342,7 @@ impl CargoBuild { /// .test("test") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .run_tests().unwrap() /// .next().unwrap().unwrap(); diff --git a/src/format/mod.rs b/src/format/mod.rs index 9c96861..c121b38 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -230,6 +230,7 @@ pub(crate) fn log_message(msg: &Message<'_>) { } #[cfg(feature = "print")] +#[allow(clippy::print_stderr)] pub(crate) fn log_message(msg: &Message<'_>) { match msg { Message::BuildFinished(ref finished) => { diff --git a/src/lib.rs b/src/lib.rs index dd65591..984e830 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,7 +36,10 @@ //! .unwrap(); //! ``` +#![allow(clippy::self_named_module_files)] // false positive #![warn(missing_docs)] +#![warn(clippy::print_stderr)] +#![warn(clippy::print_stdout)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] #[macro_use] diff --git a/src/msg.rs b/src/msg.rs index b54a1d4..79cf5cf 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -3,7 +3,7 @@ use std::io::BufRead; use std::io::Read; use std::process; -use crate::error::*; +use crate::error::{CargoError, CargoResult, ErrorKind}; use crate::format; /// Messages returned from a cargo sub-command. diff --git a/src/run.rs b/src/run.rs index e8aed96..f9b9978 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,9 +1,9 @@ use std::path; use std::process; -use crate::error::*; +use crate::error::{CargoError, CargoResult, ErrorKind}; use crate::format; -use crate::msg::*; +use crate::msg::CommandMessages; /// The `run` subcommand (emulated). /// @@ -26,7 +26,7 @@ use crate::msg::*; /// .bin("bin") /// .current_release() /// .current_target() -/// .manifest_path("tests/fixtures/bin/Cargo.toml") +/// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap(); @@ -68,7 +68,7 @@ impl CargoRun { /// .bin("bin") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap(); @@ -81,7 +81,7 @@ impl CargoRun { /// .example("example_fixture") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/example/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap(); @@ -103,7 +103,7 @@ impl CargoRun { /// .bin("bin") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/bin/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap() @@ -122,7 +122,7 @@ impl CargoRun { /// .example("example_fixture") /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/example/Cargo.toml") /// .target_dir(temp.path()) /// .run() /// .unwrap() @@ -143,7 +143,7 @@ fn extract_bin<'a>(msg: &'a format::Message<'_>, desired_kind: &str) -> Option<& && art.target.crate_types == ["bin"] && art.target.kind == [desired_kind] { - Some(art.filenames.get(0).expect("files must exist")) + Some(art.filenames.first().expect("files must exist")) } else { None } diff --git a/src/test.rs b/src/test.rs index 5aebacf..c11ab1a 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1,9 +1,9 @@ use std::path; use std::process; -use crate::error::*; +use crate::error::{CargoError, CargoResult}; use crate::format; -use crate::msg::*; +use crate::msg::CommandMessages; /// The `test` subcommand (emulated). /// @@ -28,7 +28,7 @@ use crate::msg::*; /// let temp = assert_fs::TempDir::new().unwrap(); /// let run = escargot::CargoBuild::new() /// .test("test") -/// .manifest_path("tests/fixtures/test/Cargo.toml") +/// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .run_tests().unwrap() /// .next().unwrap().unwrap(); @@ -64,7 +64,7 @@ impl CargoTest { /// .tests() /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .run_tests() /// .unwrap() @@ -93,7 +93,7 @@ impl CargoTest { /// .tests() /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .run_tests() /// .unwrap() @@ -122,7 +122,7 @@ impl CargoTest { /// .tests() /// .current_release() /// .current_target() - /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .manifest_path("tests/testsuite/fixtures/test/Cargo.toml") /// .target_dir(temp.path()) /// .run_tests() /// .unwrap() @@ -154,13 +154,13 @@ fn extract_bin(msg: &format::Message<'_>) -> Option { if art.profile.test { let bin_path = art .filenames - .get(0) + .first() .expect("files must exist") .to_path_buf(); let kind = art .target .kind - .get(0) + .first() .expect("kind must exist") .as_ref() .to_owned(); diff --git a/tests/build.rs b/tests/testsuite/build.rs similarity index 90% rename from tests/build.rs rename to tests/testsuite/build.rs index d5e03a2..520785d 100644 --- a/tests/build.rs +++ b/tests/testsuite/build.rs @@ -2,7 +2,7 @@ fn test_fixture(name: &str) { let temp = assert_fs::TempDir::new().unwrap(); let msgs = escargot::CargoBuild::new() - .manifest_path(format!("tests/fixtures/{}/Cargo.toml", name)) + .manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name)) .current_release() .current_target() .target_dir(temp.path()) @@ -51,7 +51,7 @@ fn test_dependency() { #[test] fn test_error() { let msgs: Vec<_> = escargot::CargoBuild::new() - .manifest_path("tests/fixtures/error/Cargo.toml") + .manifest_path("tests/testsuite/fixtures/error/Cargo.toml") .current_release() .current_target() .exec() diff --git a/tests/fixtures/bin/Cargo.toml b/tests/testsuite/fixtures/bin/Cargo.toml similarity index 89% rename from tests/fixtures/bin/Cargo.toml rename to tests/testsuite/fixtures/bin/Cargo.toml index c6c4eca..093f2c8 100644 --- a/tests/fixtures/bin/Cargo.toml +++ b/tests/testsuite/fixtures/bin/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "bin" version = "0.1.0" diff --git a/tests/fixtures/bin/src/main.rs b/tests/testsuite/fixtures/bin/src/main.rs similarity index 100% rename from tests/fixtures/bin/src/main.rs rename to tests/testsuite/fixtures/bin/src/main.rs diff --git a/tests/fixtures/bin_lib/Cargo.toml b/tests/testsuite/fixtures/bin_lib/Cargo.toml similarity index 90% rename from tests/fixtures/bin_lib/Cargo.toml rename to tests/testsuite/fixtures/bin_lib/Cargo.toml index 410ae62..f2e661b 100644 --- a/tests/fixtures/bin_lib/Cargo.toml +++ b/tests/testsuite/fixtures/bin_lib/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "bin_lib" version = "0.1.0" diff --git a/tests/fixtures/bin_lib/src/lib.rs b/tests/testsuite/fixtures/bin_lib/src/lib.rs similarity index 100% rename from tests/fixtures/bin_lib/src/lib.rs rename to tests/testsuite/fixtures/bin_lib/src/lib.rs diff --git a/tests/fixtures/bin_lib/src/main.rs b/tests/testsuite/fixtures/bin_lib/src/main.rs similarity index 100% rename from tests/fixtures/bin_lib/src/main.rs rename to tests/testsuite/fixtures/bin_lib/src/main.rs diff --git a/tests/fixtures/dep/Cargo.toml b/tests/testsuite/fixtures/dep/Cargo.toml similarity index 91% rename from tests/fixtures/dep/Cargo.toml rename to tests/testsuite/fixtures/dep/Cargo.toml index 9ae907e..ebf68d2 100644 --- a/tests/fixtures/dep/Cargo.toml +++ b/tests/testsuite/fixtures/dep/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "dep" version = "0.1.0" diff --git a/tests/fixtures/dep/src/lib.rs b/tests/testsuite/fixtures/dep/src/lib.rs similarity index 100% rename from tests/fixtures/dep/src/lib.rs rename to tests/testsuite/fixtures/dep/src/lib.rs diff --git a/tests/fixtures/error/Cargo.toml b/tests/testsuite/fixtures/error/Cargo.toml similarity index 90% rename from tests/fixtures/error/Cargo.toml rename to tests/testsuite/fixtures/error/Cargo.toml index fdcef76..966853b 100644 --- a/tests/fixtures/error/Cargo.toml +++ b/tests/testsuite/fixtures/error/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "error" version = "0.1.0" diff --git a/tests/fixtures/error/src/lib.rs b/tests/testsuite/fixtures/error/src/lib.rs similarity index 100% rename from tests/fixtures/error/src/lib.rs rename to tests/testsuite/fixtures/error/src/lib.rs diff --git a/tests/fixtures/error/src/main.rs b/tests/testsuite/fixtures/error/src/main.rs similarity index 100% rename from tests/fixtures/error/src/main.rs rename to tests/testsuite/fixtures/error/src/main.rs diff --git a/tests/fixtures/example/Cargo.toml b/tests/testsuite/fixtures/example/Cargo.toml similarity index 88% rename from tests/fixtures/example/Cargo.toml rename to tests/testsuite/fixtures/example/Cargo.toml index e9ace7d..213b7be 100644 --- a/tests/fixtures/example/Cargo.toml +++ b/tests/testsuite/fixtures/example/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "example" version = "0.1.0" diff --git a/tests/fixtures/example/examples/example_fixture.rs b/tests/testsuite/fixtures/example/examples/example_fixture.rs similarity index 100% rename from tests/fixtures/example/examples/example_fixture.rs rename to tests/testsuite/fixtures/example/examples/example_fixture.rs diff --git a/tests/fixtures/example/src/lib.rs b/tests/testsuite/fixtures/example/src/lib.rs similarity index 100% rename from tests/fixtures/example/src/lib.rs rename to tests/testsuite/fixtures/example/src/lib.rs diff --git a/tests/fixtures/lib/Cargo.toml b/tests/testsuite/fixtures/lib/Cargo.toml similarity index 89% rename from tests/fixtures/lib/Cargo.toml rename to tests/testsuite/fixtures/lib/Cargo.toml index 4292e6c..554f2ea 100644 --- a/tests/fixtures/lib/Cargo.toml +++ b/tests/testsuite/fixtures/lib/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "lib" version = "0.1.0" diff --git a/tests/fixtures/lib/src/lib.rs b/tests/testsuite/fixtures/lib/src/lib.rs similarity index 100% rename from tests/fixtures/lib/src/lib.rs rename to tests/testsuite/fixtures/lib/src/lib.rs diff --git a/tests/fixtures/script/Cargo.toml b/tests/testsuite/fixtures/script/Cargo.toml similarity index 90% rename from tests/fixtures/script/Cargo.toml rename to tests/testsuite/fixtures/script/Cargo.toml index 3c1e443..34dbafb 100644 --- a/tests/fixtures/script/Cargo.toml +++ b/tests/testsuite/fixtures/script/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "script" version = "0.1.0" diff --git a/tests/fixtures/script/build.rs b/tests/testsuite/fixtures/script/build.rs similarity index 100% rename from tests/fixtures/script/build.rs rename to tests/testsuite/fixtures/script/build.rs diff --git a/tests/fixtures/script/src/lib.rs b/tests/testsuite/fixtures/script/src/lib.rs similarity index 100% rename from tests/fixtures/script/src/lib.rs rename to tests/testsuite/fixtures/script/src/lib.rs diff --git a/tests/fixtures/test/Cargo.toml b/tests/testsuite/fixtures/test/Cargo.toml similarity index 89% rename from tests/fixtures/test/Cargo.toml rename to tests/testsuite/fixtures/test/Cargo.toml index 272ef4a..425b6e6 100644 --- a/tests/fixtures/test/Cargo.toml +++ b/tests/testsuite/fixtures/test/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "test_fixture" version = "0.1.0" diff --git a/tests/fixtures/test/src/lib.rs b/tests/testsuite/fixtures/test/src/lib.rs similarity index 100% rename from tests/fixtures/test/src/lib.rs rename to tests/testsuite/fixtures/test/src/lib.rs diff --git a/tests/fixtures/test/src/main.rs b/tests/testsuite/fixtures/test/src/main.rs similarity index 100% rename from tests/fixtures/test/src/main.rs rename to tests/testsuite/fixtures/test/src/main.rs diff --git a/tests/fixtures/test/tests/test.rs b/tests/testsuite/fixtures/test/tests/test.rs similarity index 100% rename from tests/fixtures/test/tests/test.rs rename to tests/testsuite/fixtures/test/tests/test.rs diff --git a/tests/fixtures/warn/Cargo.toml b/tests/testsuite/fixtures/warn/Cargo.toml similarity index 89% rename from tests/fixtures/warn/Cargo.toml rename to tests/testsuite/fixtures/warn/Cargo.toml index 2c31429..c0413fc 100644 --- a/tests/fixtures/warn/Cargo.toml +++ b/tests/testsuite/fixtures/warn/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "warn" version = "0.1.0" diff --git a/tests/fixtures/warn/src/lib.rs b/tests/testsuite/fixtures/warn/src/lib.rs similarity index 100% rename from tests/fixtures/warn/src/lib.rs rename to tests/testsuite/fixtures/warn/src/lib.rs diff --git a/tests/fixtures/warn/src/main.rs b/tests/testsuite/fixtures/warn/src/main.rs similarity index 100% rename from tests/fixtures/warn/src/main.rs rename to tests/testsuite/fixtures/warn/src/main.rs diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs new file mode 100644 index 0000000..4441374 --- /dev/null +++ b/tests/testsuite/main.rs @@ -0,0 +1 @@ +automod::dir!("tests/testsuite"); diff --git a/tests/run.rs b/tests/testsuite/run.rs similarity index 81% rename from tests/run.rs rename to tests/testsuite/run.rs index cef927a..af6c002 100644 --- a/tests/run.rs +++ b/tests/testsuite/run.rs @@ -2,7 +2,7 @@ fn test_fixture(name: &str) { let temp = assert_fs::TempDir::new().unwrap(); let cmd = escargot::CargoBuild::new() - .manifest_path(format!("tests/fixtures/{}/Cargo.toml", name)) + .manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name)) .current_release() .current_target() .target_dir(temp.path()) @@ -25,7 +25,7 @@ fn test_warn() { #[test] fn test_error() { let result = escargot::CargoBuild::new() - .manifest_path("tests/fixtures/error/Cargo.toml") + .manifest_path("tests/testsuite/fixtures/error/Cargo.toml") .current_release() .current_target() .run();