Skip to content

Commit

Permalink
chore: Test fix for #109, run tests in full in CI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dead-claudia committed Jun 13, 2023
1 parent 69ac491 commit 0b4c9ae
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"tests/single-panic",
"tests/custom-panic",
"tests/name-collision",
]
resolver = "2"

Expand Down
2 changes: 1 addition & 1 deletion tests/custom-panic/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
",
)
Expand Down
14 changes: 14 additions & 0 deletions tests/name-collision/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "name-collision-test"
version = "0.1.0"
authors = ["Human Panic Authors <human-panic-crate@example.com>"]
edition = "2018"

[package.metadata.release]
release = false

[dependencies]
human-panic = { path = "../.." }

[dev-dependencies]
snapbox = { version = "0.4.11", features = ["cmd"] }
25 changes: 25 additions & 0 deletions tests/name-collision/src/main.rs
Original file line number Diff line number Diff line change
@@ -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!!!");
}
36 changes: 36 additions & 0 deletions tests/name-collision/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -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 <human-panic-crate@example.com>
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);
}
2 changes: 1 addition & 1 deletion tests/single-panic/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
",
)
Expand Down

0 comments on commit 0b4c9ae

Please sign in to comment.