From 0b4c9ae6edc817a2e9bf98deeb8605f4eb593fc5 Mon Sep 17 00:00:00 2001 From: Claudia Meadows Date: Tue, 13 Jun 2023 08:03:28 -0700 Subject: [PATCH] chore: Test fix for #109, run tests in full in CI The other tests only needed modified to fix a column number. The action was mysteriously only running one of the tests - I've fixed that. This should help prevent regressions for #109 and possibly others. I've verified they also failed prior to that patch. --- .github/workflows/ci.yml | 8 ++--- Cargo.lock | 8 +++++ Cargo.toml | 1 + tests/custom-panic/tests/integration.rs | 2 +- tests/name-collision/Cargo.toml | 14 +++++++++ tests/name-collision/src/main.rs | 25 ++++++++++++++++ tests/name-collision/tests/integration.rs | 36 +++++++++++++++++++++++ tests/single-panic/tests/integration.rs | 2 +- 8 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 tests/name-collision/Cargo.toml create mode 100644 tests/name-collision/src/main.rs create mode 100644 tests/name-collision/tests/integration.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20526e5..4b96f5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,13 +41,13 @@ jobs: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - name: Build Debug - run: cargo test --no-run + run: cargo test --all --no-run - name: Test Debug - run: cargo test + run: cargo test --all - name: Build Release - run: cargo test --no-run --release + run: cargo test --all --no-run --release - name: Test Release - run: cargo test --release + run: cargo test --all --release msrv: name: "Check MSRV: 1.65.0" runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 3e788eb..9b597b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,6 +251,14 @@ dependencies = [ "adler", ] +[[package]] +name = "name-collision-test" +version = "0.1.0" +dependencies = [ + "human-panic", + "snapbox", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index 5672c08..7080568 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "tests/single-panic", "tests/custom-panic", + "tests/name-collision", ] resolver = "2" diff --git a/tests/custom-panic/tests/integration.rs b/tests/custom-panic/tests/integration.rs index 7c24a4d..f668f59 100644 --- a/tests/custom-panic/tests/integration.rs +++ b/tests/custom-panic/tests/integration.rs @@ -29,7 +29,7 @@ fn debug() { .assert() .stderr_matches( "\ -thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/custom-panic/src/main.rs:12:3 +thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/custom-panic/src/main.rs:12:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ", ) diff --git a/tests/name-collision/Cargo.toml b/tests/name-collision/Cargo.toml new file mode 100644 index 0000000..65e808f --- /dev/null +++ b/tests/name-collision/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "name-collision-test" +version = "0.1.0" +authors = ["Human Panic Authors "] +edition = "2018" + +[package.metadata.release] +release = false + +[dependencies] +human-panic = { path = "../.." } + +[dev-dependencies] +snapbox = { version = "0.4.11", features = ["cmd"] } diff --git a/tests/name-collision/src/main.rs b/tests/name-collision/src/main.rs new file mode 100644 index 0000000..db7d277 --- /dev/null +++ b/tests/name-collision/src/main.rs @@ -0,0 +1,25 @@ +use human_panic::setup_panic; + +#[derive(Debug, PartialEq)] +struct Metadata { + test: bool, +} + +mod panic { + pub fn what() {} +} + +fn main() { + panic::what(); + let prev = Metadata { test: true }; + + setup_panic!(); + + let next = Metadata { test: false }; + + assert_ne!(prev, next); + panic::what(); + + println!("A normal log message"); + panic!("OMG EVERYTHING IS ON FIRE!!!"); +} diff --git a/tests/name-collision/tests/integration.rs b/tests/name-collision/tests/integration.rs new file mode 100644 index 0000000..c41288b --- /dev/null +++ b/tests/name-collision/tests/integration.rs @@ -0,0 +1,36 @@ +#[test] +#[cfg_attr(debug_assertions, ignore)] +fn release() { + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("name-collision-test")) + .assert() + .stderr_matches( + "\ +Well, this is embarrassing. + +name-collision-test had a problem and crashed. To help us diagnose the problem you can send us a crash report. + +We have generated a report file at \"[..].toml\". Submit an issue or email with the subject of \"name-collision-test Crash Report\" and include the report as an attachment. + +- Authors: Human Panic Authors + +We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports. + +Thank you kindly! +", + ) + .code(101); +} + +#[test] +#[cfg_attr(not(debug_assertions), ignore)] +fn debug() { + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("name-collision-test")) + .assert() + .stderr_matches( + "\ +thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/name-collision/src/main.rs:24:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +", + ) + .code(101); +} diff --git a/tests/single-panic/tests/integration.rs b/tests/single-panic/tests/integration.rs index 31cb354..6a6240d 100644 --- a/tests/single-panic/tests/integration.rs +++ b/tests/single-panic/tests/integration.rs @@ -28,7 +28,7 @@ fn debug() { .assert() .stderr_matches( "\ -thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/single-panic/src/main.rs:7:3 +thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/single-panic/src/main.rs:7:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ", )