Skip to content

Commit 3469629

Browse files
committed
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.
1 parent 69ac491 commit 3469629

File tree

8 files changed

+90
-6
lines changed

8 files changed

+90
-6
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ jobs:
4141
toolchain: ${{ matrix.rust }}
4242
- uses: Swatinem/rust-cache@v2
4343
- name: Build Debug
44-
run: cargo test --no-run
44+
run: cargo test --all --no-run
4545
- name: Test Debug
46-
run: cargo test
46+
run: cargo test --all
4747
- name: Build Release
48-
run: cargo test --no-run --release
48+
run: cargo test --all --no-run --release
4949
- name: Test Release
50-
run: cargo test --release
50+
run: cargo test --all --release
5151
msrv:
5252
name: "Check MSRV: 1.65.0"
5353
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"tests/single-panic",
44
"tests/custom-panic",
5+
"tests/name-collision",
56
]
67
resolver = "2"
78

tests/custom-panic/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn debug() {
2929
.assert()
3030
.stderr_matches(
3131
"\
32-
thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/custom-panic/src/main.rs:12:3
32+
thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/custom-panic/src/main.rs:12:5
3333
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3434
",
3535
)

tests/name-collision/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "name-collision-test"
3+
version = "0.1.0"
4+
authors = ["Human Panic Authors <human-panic-crate@example.com>"]
5+
edition = "2018"
6+
7+
[package.metadata.release]
8+
release = false
9+
10+
[dependencies]
11+
human-panic = { path = "../.." }
12+
13+
[dev-dependencies]
14+
snapbox = { version = "0.4.11", features = ["cmd"] }

tests/name-collision/src/main.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use human_panic::setup_panic;
2+
3+
#[derive(Debug, PartialEq)]
4+
struct Metadata {
5+
test: bool,
6+
}
7+
8+
mod panic {
9+
pub fn what() {}
10+
}
11+
12+
fn main() {
13+
panic::what();
14+
let prev = Metadata { test: true };
15+
16+
setup_panic!();
17+
18+
let next = Metadata { test: false };
19+
20+
assert_ne!(prev, next);
21+
panic::what();
22+
23+
println!("A normal log message");
24+
panic!("OMG EVERYTHING IS ON FIRE!!!");
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[test]
2+
#[cfg_attr(debug_assertions, ignore)]
3+
fn release() {
4+
snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("name-collision-test"))
5+
.assert()
6+
.stderr_matches(
7+
"\
8+
Well, this is embarrassing.
9+
10+
name-collision-test had a problem and crashed. To help us diagnose the problem you can send us a crash report.
11+
12+
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.
13+
14+
- Authors: Human Panic Authors <human-panic-crate@example.com>
15+
16+
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.
17+
18+
Thank you kindly!
19+
",
20+
)
21+
.code(101);
22+
}
23+
24+
#[test]
25+
#[cfg_attr(not(debug_assertions), ignore)]
26+
fn debug() {
27+
snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("name-collision-test"))
28+
.assert()
29+
.stderr_matches(
30+
"\
31+
thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/name-collision/src/main.rs:24:5
32+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
33+
",
34+
)
35+
.code(101);
36+
}

tests/single-panic/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn debug() {
2828
.assert()
2929
.stderr_matches(
3030
"\
31-
thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/single-panic/src/main.rs:7:3
31+
thread 'main' panicked at 'OMG EVERYTHING IS ON FIRE!!!', tests/single-panic/src/main.rs:7:5
3232
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3333
",
3434
)

0 commit comments

Comments
 (0)