Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Test fix for #109, run in full in CI #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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