From b53f51db60f7411ccd243f315982dd49f5d1b5dc Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Wed, 31 Jan 2024 04:40:15 +0000 Subject: [PATCH] Move on-target-tests back to the workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s no obvious reason to keep on-target-tests excluded from the workspace. Plus, this simplifies significantly the github workflows. --- .github/workflows/build_and_test.yml | 36 ++++--------------- .github/workflows/clippy.yml | 7 ++-- .github/workflows/rustfmt.yml | 3 -- Cargo.toml | 22 ++++++++---- on-target-tests/.cargo/config.toml | 14 -------- on-target-tests/Cargo.toml | 22 +----------- on-target-tests/README.md | 2 +- on-target-tests/build.rs | 3 ++ .../run_tests.bat => run_tests.bat | 2 +- on-target-tests/run_tests.sh => run_tests.sh | 2 +- 10 files changed, 30 insertions(+), 83 deletions(-) delete mode 100644 on-target-tests/.cargo/config.toml create mode 100644 on-target-tests/build.rs rename on-target-tests/run_tests.bat => run_tests.bat (78%) rename on-target-tests/run_tests.sh => run_tests.sh (83%) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 27c6f820e..09e025eb1 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -16,20 +16,8 @@ jobs: version: "=0.5.28" - name: Build rp2040-hal's workspace (without the examples) run: cargo hack build --optional-deps --each-feature - examples-builds: - name: Build rp2040-hal's examples - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - target: thumbv6m-none-eabi - - name: Install cargo-hack - uses: baptiste0928/cargo-install@v2 - with: - crate: cargo-hack - version: "=0.5.28" - - name: Build workspace + - run: cargo clean + - name: Build rp2040-hal's workspace (with the examples) run: cargo hack build --examples --optional-deps --each-feature tests: name: Execute host-runable tests @@ -45,13 +33,13 @@ jobs: crate: cargo-hack version: "=0.5.28" - name: Test - run: cargo hack test -p rp2040-hal --tests --target x86_64-unknown-linux-gnu --optional-deps --each-feature --features critical-section-impl + run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --tests --features critical-section-impl - name: Test docs - run: cargo hack test -p rp2040-hal --doc --target x86_64-unknown-linux-gnu --optional-deps --each-feature --features critical-section-impl + run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --doc --features critical-section-impl - name: Test macros - run: cargo hack test -p rp2040-hal-macros --tests --target x86_64-unknown-linux-gnu --optional-deps --each-feature + run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --tests --each-feature - name: Test macro docs - run: cargo hack test -p rp2040-hal-macros --doc --target x86_64-unknown-linux-gnu --optional-deps --each-feature + run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --doc --each-feature - name: Clean run: cargo clean udeps: @@ -93,15 +81,3 @@ jobs: run: cargo update -p regex --precise 1.9.3 - name: Verifiy MSRV run: cargo hack build --examples --optional-deps --each-feature - on-target-build: - name: Build on-target-tests - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - target: thumbv6m-none-eabi - - name: Build on-target-tests - run: | - cd on-target-tests - cargo test --no-run diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index d227e9d0b..3483dd414 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -12,8 +12,5 @@ jobs: with: target: thumbv6m-none-eabi components: clippy - - run: cargo clippy --workspace --examples -- -Dwarnings - - run: cargo clippy --workspace --examples --all-features -- -Dwarnings - - run: | - cd on-target-tests - cargo clippy -- -Dwarnings + - run: cargo clippy --workspace --examples + - run: cargo clippy --workspace --examples --all-features diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 9ef1e399b..9d7b8065b 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -13,6 +13,3 @@ jobs: target: thumbv6m-none-eabi components: rustfmt - run: cargo fmt -- --check - - run: | - cd on-target-tests - cargo fmt -- --check diff --git a/Cargo.toml b/Cargo.toml index 8fe6a686e..17b93a079 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,23 @@ [workspace] resolver = "2" -members = [ - "rp2040-hal", - "rp2040-hal-macros", -] -exclude = [ - "on-target-tests" -] +members = ["rp2040-hal", "rp2040-hal-macros", "on-target-tests"] +exclude = [] [patch.'https://github.com/rp-rs/rp-hal.git'] rp2040-hal = { path = "./rp2040-hal" } [patch.crates-io] rp2040-hal = { path = "./rp2040-hal" } + +# Those profiles are only used for `on-target-tests` compilation +[profile.dev] +codegen-units = 1 +incremental = false +lto = 'fat' +opt-level = 's' + +[profile.test] +codegen-units = 1 +incremental = false +lto = 'fat' +opt-level = 's' diff --git a/on-target-tests/.cargo/config.toml b/on-target-tests/.cargo/config.toml deleted file mode 100644 index 483113497..000000000 --- a/on-target-tests/.cargo/config.toml +++ /dev/null @@ -1,14 +0,0 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -# we need probe-run to run target tests -# note: this will be overridden by the top-level config.toml -runner = "probe-rs run --chip RP2040" - -rustflags = [ - "-C", "link-arg=-Tdefmt.x", -] - -[build] -target = "thumbv6m-none-eabi" - -[env] -DEFMT_LOG = "trace" diff --git a/on-target-tests/Cargo.toml b/on-target-tests/Cargo.toml index 4fa4f3b5f..c65ed72b0 100644 --- a/on-target-tests/Cargo.toml +++ b/on-target-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2021" -name = "rp2040-hal-on-target-tests" +name = "on-target-tests" version = "0.1.0" publish = false @@ -47,23 +47,3 @@ fugit = "0.3.6" rp2040-boot2 = "0.3.0" critical-section = "1.0.0" - -[features] -default = ['defmt-trace'] -defmt-trace = [] -defmt-debug = [] -defmt-info = [] -defmt-warn = [] -defmt-error = [] - -[profile.dev] -codegen-units = 1 -incremental = false -lto = 'fat' -opt-level = 's' - -[profile.test] -codegen-units = 1 -incremental = false -lto = 'fat' -opt-level = 's' diff --git a/on-target-tests/README.md b/on-target-tests/README.md index c02152050..6e7e8d9ef 100644 --- a/on-target-tests/README.md +++ b/on-target-tests/README.md @@ -19,7 +19,7 @@ run_tests.bat To run a specific test (to make developing tests faster) ```system -CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test --test my_new_test -- --chip rp2040 +CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test -p on-target-tests --test my_new_test -- --chip rp2040 ``` ## Prerequisites diff --git a/on-target-tests/build.rs b/on-target-tests/build.rs new file mode 100644 index 000000000..e0ff2ef0d --- /dev/null +++ b/on-target-tests/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-arg-tests=-Tdefmt.x"); +} diff --git a/on-target-tests/run_tests.bat b/run_tests.bat similarity index 78% rename from on-target-tests/run_tests.bat rename to run_tests.bat index f8fcfa61d..afe938520 100755 --- a/on-target-tests/run_tests.bat +++ b/run_tests.bat @@ -3,4 +3,4 @@ @SET "CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER=probe-rs run" -cargo test --no-fail-fast -- --chip rp2040 +cargo test -p on-target-tests --no-fail-fast -- --chip rp2040 diff --git a/on-target-tests/run_tests.sh b/run_tests.sh similarity index 83% rename from on-target-tests/run_tests.sh rename to run_tests.sh index 326e7992b..92b3402af 100755 --- a/on-target-tests/run_tests.sh +++ b/run_tests.sh @@ -3,4 +3,4 @@ # Keep running tests even if one of them fails # We need to specify probe-rs as our runner via environment variables here # to control build since we aren't able to override them in config.toml -CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test --no-fail-fast -- --chip rp2040 +CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test -p on-target-tests --no-fail-fast -- --chip rp2040