From f18366fe3935fbfb501c5c9a07f91691fc04d936 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Tue, 17 Apr 2018 16:19:58 +0200 Subject: [PATCH 01/13] Carrying over metadata from first macro call to properly include metadata in crash dumps. --- src/lib.rs | 21 ++++++++++++++------- src/report.rs | 6 +++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7fe92c1..aa91ed7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ use report::{Method, Report}; use failure::Error as FailError; use std::io::{Result as IoResult, Write}; -use std::path::{Path, PathBuf}; use std::panic::PanicInfo; +use std::path::{Path, PathBuf}; use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; /// A convenient metadata struct that describes a crate @@ -41,8 +41,8 @@ macro_rules! setup_panic { }; panic::set_hook(Box::new(move |info: &PanicInfo| { - let file_path = - handle_dump(info).expect("human-panic: dumping logs to disk failed"); + let file_path = handle_dump(&meta, info) + .expect("human-panic: dumping logs to disk failed"); print_msg(&file_path, &meta) .expect("human-panic: printing error message to console failed"); @@ -55,8 +55,12 @@ pub fn print_msg>( file_path: P, meta: &Metadata, ) -> IoResult<()> { - let (_version, name, authors, homepage) = - (meta.version, meta.name, meta.authors, meta.homepage); + let (_version, name, authors, homepage) = ( + meta.version, + meta.name, + meta.authors, + meta.homepage, + ); let stderr = BufferWriter::stderr(ColorChoice::Auto); let mut buffer = stderr.buffer(); @@ -97,7 +101,10 @@ pub fn print_msg>( } /// Utility function which will handle dumping information to disk -pub fn handle_dump(panic_info: &PanicInfo) -> Result { +pub fn handle_dump( + meta: &Metadata, + panic_info: &PanicInfo, +) -> Result { let mut expl = String::new(); let payload = panic_info.payload().downcast_ref::<&str>(); @@ -114,6 +121,6 @@ pub fn handle_dump(panic_info: &PanicInfo) -> Result { None => expl.push_str("Panic location uknown.\n"), } - let report = Report::new(Method::Panic, expl); + let report = Report::new(meta.name, meta.version, Method::Panic, expl); report.persist() } diff --git a/src/report.rs b/src/report.rs index d49db9f..a7b42a9 100644 --- a/src/report.rs +++ b/src/report.rs @@ -26,7 +26,7 @@ pub struct Report { impl Report { /// Create a new instance. - pub fn new(method: Method, explanation: String) -> Self { + pub fn new>(name: S, version: S, method: Method, explanation: String) -> Self { let operating_system = if cfg!(windows) { "windows".to_string() } else { @@ -35,8 +35,8 @@ impl Report { }; Self { - crate_version: env!("CARGO_PKG_VERSION").to_string(), - name: env!("CARGO_PKG_NAME").to_string(), + crate_version: version.into(), + name: name.into(), operating_system, method, explanation, From 25bc94d0def9229c6bfaf9bfead3503638b2a800 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Tue, 17 Apr 2018 16:26:36 +0200 Subject: [PATCH 02/13] Cleaning up formatting --- src/lib.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aa91ed7..9ce6df0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ use report::{Method, Report}; use failure::Error as FailError; use std::io::{Result as IoResult, Write}; -use std::panic::PanicInfo; use std::path::{Path, PathBuf}; +use std::panic::PanicInfo; use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; /// A convenient metadata struct that describes a crate @@ -55,12 +55,8 @@ pub fn print_msg>( file_path: P, meta: &Metadata, ) -> IoResult<()> { - let (_version, name, authors, homepage) = ( - meta.version, - meta.name, - meta.authors, - meta.homepage, - ); + let (_version, name, authors, homepage) = + (meta.version, meta.name, meta.authors, meta.homepage); let stderr = BufferWriter::stderr(ColorChoice::Auto); let mut buffer = stderr.buffer(); @@ -101,10 +97,7 @@ pub fn print_msg>( } /// Utility function which will handle dumping information to disk -pub fn handle_dump( - meta: &Metadata, - panic_info: &PanicInfo, -) -> Result { +pub fn handle_dump(meta: &Metadata, panic_info: &PanicInfo) -> Result { let mut expl = String::new(); let payload = panic_info.payload().downcast_ref::<&str>(); From 9af2799302555b9995552550805533bb408cb0c3 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Tue, 17 Apr 2018 16:37:23 +0200 Subject: [PATCH 03/13] =?UTF-8?q?Running=20cargo=20fmt=20(woops=20?= =?UTF-8?q?=F0=9F=98=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib.rs | 15 +++++++++++---- src/report.rs | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9ce6df0..aa91ed7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ use report::{Method, Report}; use failure::Error as FailError; use std::io::{Result as IoResult, Write}; -use std::path::{Path, PathBuf}; use std::panic::PanicInfo; +use std::path::{Path, PathBuf}; use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; /// A convenient metadata struct that describes a crate @@ -55,8 +55,12 @@ pub fn print_msg>( file_path: P, meta: &Metadata, ) -> IoResult<()> { - let (_version, name, authors, homepage) = - (meta.version, meta.name, meta.authors, meta.homepage); + let (_version, name, authors, homepage) = ( + meta.version, + meta.name, + meta.authors, + meta.homepage, + ); let stderr = BufferWriter::stderr(ColorChoice::Auto); let mut buffer = stderr.buffer(); @@ -97,7 +101,10 @@ pub fn print_msg>( } /// Utility function which will handle dumping information to disk -pub fn handle_dump(meta: &Metadata, panic_info: &PanicInfo) -> Result { +pub fn handle_dump( + meta: &Metadata, + panic_info: &PanicInfo, +) -> Result { let mut expl = String::new(); let payload = panic_info.payload().downcast_ref::<&str>(); diff --git a/src/report.rs b/src/report.rs index a7b42a9..7173b1f 100644 --- a/src/report.rs +++ b/src/report.rs @@ -26,7 +26,12 @@ pub struct Report { impl Report { /// Create a new instance. - pub fn new>(name: S, version: S, method: Method, explanation: String) -> Self { + pub fn new>( + name: S, + version: S, + method: Method, + explanation: String, + ) -> Self { let operating_system = if cfg!(windows) { "windows".to_string() } else { From 92cd808b2115486e72d9932571f7393d2e5f4931 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Tue, 17 Apr 2018 16:58:25 +0200 Subject: [PATCH 04/13] Changing function types --- src/lib.rs | 2 +- src/report.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aa91ed7..2a4b0c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -121,6 +121,6 @@ pub fn handle_dump( None => expl.push_str("Panic location uknown.\n"), } - let report = Report::new(meta.name, meta.version, Method::Panic, expl); + let report = Report::new(&meta.name, &meta.version, Method::Panic, expl); report.persist() } diff --git a/src/report.rs b/src/report.rs index 7173b1f..f9c0fd3 100644 --- a/src/report.rs +++ b/src/report.rs @@ -26,9 +26,9 @@ pub struct Report { impl Report { /// Create a new instance. - pub fn new>( - name: S, - version: S, + pub fn new( + name: &str, + version: &str, method: Method, explanation: String, ) -> Self { @@ -40,8 +40,8 @@ impl Report { }; Self { - crate_version: version.into(), - name: name.into(), + crate_version: version.to_string(), + name: name.to_string(), operating_system, method, explanation, From f5cc70a44689ee159767fa7d6485f7849433fa40 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Tue, 17 Apr 2018 17:02:47 +0200 Subject: [PATCH 05/13] Fixing the formatting --- src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2a4b0c8..b7a4b7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,12 +55,8 @@ pub fn print_msg>( file_path: P, meta: &Metadata, ) -> IoResult<()> { - let (_version, name, authors, homepage) = ( - meta.version, - meta.name, - meta.authors, - meta.homepage, - ); + let (_version, name, authors, homepage) = + (meta.version, meta.name, meta.authors, meta.homepage); let stderr = BufferWriter::stderr(ColorChoice::Auto); let mut buffer = stderr.buffer(); From fafb46b31249365421edfc1b50749f793504c8cc Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Wed, 18 Apr 2018 19:51:48 +0200 Subject: [PATCH 06/13] Half finished state --- src/report.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.rs b/src/report.rs index f9c0fd3..701cbe2 100644 --- a/src/report.rs +++ b/src/report.rs @@ -10,7 +10,7 @@ use self::uuid::Uuid; use std::{env, fs::File, io::Write, path::Path, path::PathBuf}; /// Method of failure. -#[derive(Debug, Serialize)] +#[derive(Debug, Serialize, Clone)] pub enum Method { Panic, } From fc8b97ada7859065504a3fa4ff42ec94d3f0dac7 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Wed, 18 Apr 2018 19:56:39 +0200 Subject: [PATCH 07/13] Making Method derive Copy --- src/report.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.rs b/src/report.rs index 701cbe2..d2ef441 100644 --- a/src/report.rs +++ b/src/report.rs @@ -10,7 +10,7 @@ use self::uuid::Uuid; use std::{env, fs::File, io::Write, path::Path, path::PathBuf}; /// Method of failure. -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Serialize, Clone, Copy)] pub enum Method { Panic, } From 45cabffa48aae811aaf11d0d4cf270c549d58e2f Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 19 Apr 2018 16:46:10 +0200 Subject: [PATCH 08/13] Add some simple integration test & infrastructure Turns this repository into a cargo workspaces and adds a sub-crate with the wonderful name 'simple-human-panic-test' that lives in the new `tests/` directory. This should be of no consequence to the actual crate itself or its deployment to crates.io, but allows us to easily test how human-panic works when in an external crate. Especially, we can set up the sub-crate `Cargo.toml` files in a way that we can easily test that human-panic's output does not cause panics in humans. For that, I've also added a simple integration test to the `simple` test crate. It uses assert_cli to run the crate's main binary and assert its output contains certain strings (as well as that it exits with a panic- typical exit code). By the way: One benefit of using cargo workspaces is that sub-crates share a lock file and a `target/` directory. So, we can add lots of test crates without worrying of having to recompile dependencies all the time. You can easily run the tests across all sub-crates with `cargo test --all`. In general, most cargo subcommands support `--all`, and I've added it in a few places in the CI config. --- .travis.yml | 8 +- Cargo.lock | 203 ++++++++++++++++++ Cargo.toml | 5 + tests/simple/Cargo.toml | 10 + examples/panic.rs => tests/simple/src/main.rs | 0 tests/simple/tests/integration.rs | 14 ++ 6 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 tests/simple/Cargo.toml rename examples/panic.rs => tests/simple/src/main.rs (100%) create mode 100644 tests/simple/tests/integration.rs diff --git a/.travis.yml b/.travis.yml index 3b67724..ae6e449 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,23 +4,23 @@ rust: - beta script: | cargo build --verbose && - cargo test --verbose + cargo test --verbose --all matrix: # additional tests include: - rust: nightly script: | - cargo test --features nightly + cargo test --all --features nightly - rust: nightly-2018-04-15 env: CLIPPY_VERS="0.0.194" before_script: | [[ "$(cargo +nightly-2018-04-15 clippy --version)" != "$CLIPPY_VERS" ]] && \ cargo +nightly-2018-04-15 install clippy --vers "$CLIPPY_VERS" --force || true script: | - cargo +nightly-2018-04-15 clippy -- -D warnings + cargo +nightly-2018-04-15 clippy --all -- -D warnings - rust: 1.25.0 # `stable`: Locking down for consistent behavior env: RUSTFMT=yes_please install: - rustup component add rustfmt-preview script: - - cargo fmt -- --write-mode=diff + - cargo fmt --all -- --write-mode=diff cache: cargo diff --git a/Cargo.lock b/Cargo.lock index 9366a96..e161894 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,6 +6,19 @@ dependencies = [ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "assert_cli" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "skeptic 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "backtrace" version = "0.3.6" @@ -27,11 +40,33 @@ dependencies = [ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bitflags" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bytecount" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cargo_metadata" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.10" @@ -42,6 +77,37 @@ name = "cfg-if" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "colored" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "difference" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "dtoa" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "environment" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "error-chain" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.1" @@ -75,6 +141,11 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "glob" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "human-panic" version = "0.4.1-alpha0" @@ -90,6 +161,25 @@ dependencies = [ "uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "itoa" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lazy_static" version = "1.0.0" @@ -108,6 +198,11 @@ dependencies = [ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num-traits" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "os_type" version = "2.0.0" @@ -124,6 +219,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pulldown-cmark" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quote" version = "0.3.15" @@ -180,6 +283,29 @@ name = "rustc-demangle" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "same-file" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde" version = "1.0.38" @@ -205,6 +331,40 @@ dependencies = [ "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_json" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "simple-human-panic-test" +version = "0.1.0" +dependencies = [ + "assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "human-panic 0.4.1-alpha0", +] + +[[package]] +name = "skeptic" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytecount 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "0.11.11" @@ -318,6 +478,21 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "walkdir" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.3.4" @@ -327,6 +502,11 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -347,20 +527,35 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" +"checksum assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72342c21057a3cb5f7c2d849bf7999a83795434dd36d74fa8c24680581bd1930" "checksum backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe525f66f42d207968308ee86bc2dd60aa5fab535b22e616323a173d097d8e" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" +"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" +"checksum bytecount 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af27422163679dea46a1a7239dffff64d3dcdc3ba5fe9c49c789fbfe0eb949de" +"checksum cargo_metadata 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f56ec3e469bca7c276f2eea015aa05c5e381356febdbb0683c2580189604537" "checksum cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8b9d2900f78631a5876dc5d6c9033ede027253efcd33dd36b1309fc6cab97ee0" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc" +"checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" +"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee" +"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +"checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dee092fcdf725aee04dd7da1d21debff559237d49ef1cb3e69bcb8ece44c7364" "checksum os_type 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "081f0539f57611638feee0d72fe98ad0b685e99da117be6b254bd1dfd7421609" "checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118" +"checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" @@ -368,9 +563,14 @@ dependencies = [ "checksum regex-syntax 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bd90079345f4a4c3409214734ae220fd773c6f2e8a543d07370c6c1c369cfbfb" "checksum remove_dir_all 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfc5b3ce5d5ea144bb04ebd093a9e14e9765bcfec866aecda9b6dec43b3d1e24" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" +"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" +"checksum semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "4c36359ac1a823e00db02a243376ced650f088dc1f6259bbf828e4668e3c7399" "checksum serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "f0477feff739386f5bca8e13fa43d96a4e834904d538f503906c8179f9205f50" "checksum serde_derive_internals 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d30c4596450fd7bbda79ef15559683f9a79ac0193ea819db90000d7e1cae794" +"checksum serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7bf1cbb1387028a13739cb018ee0d9b3db534f22ca3c84a5904f7eadfde14e75" +"checksum skeptic 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c8431f8fca168e2db4be547bd8329eac70d095dff1444fee4b0fa0fabc7df75a" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" @@ -386,7 +586,10 @@ dependencies = [ "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8630752f979f1b6b87c49830a5e3784082545de63920d59fbaac252474319447" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index e4aac10..5df5c5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,8 @@ backtrace = "0.3" [features] nightly = [] + +[workspace] +members = [ + "tests/simple", +] diff --git a/tests/simple/Cargo.toml b/tests/simple/Cargo.toml new file mode 100644 index 0000000..3c62003 --- /dev/null +++ b/tests/simple/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "simple-human-panic-test" +version = "0.1.0" +authors = ["Human Panic Authors "] + +[dependencies] +human-panic = { path = "../.." } + +[dev-dependencies] +assert_cli = "0.5.4" diff --git a/examples/panic.rs b/tests/simple/src/main.rs similarity index 100% rename from examples/panic.rs rename to tests/simple/src/main.rs diff --git a/tests/simple/tests/integration.rs b/tests/simple/tests/integration.rs new file mode 100644 index 0000000..bb5aed1 --- /dev/null +++ b/tests/simple/tests/integration.rs @@ -0,0 +1,14 @@ +extern crate assert_cli; + +#[test] +fn integration() { + assert_cli::Assert::main_binary() + .stderr() + .contains("simple-human-panic-test") + .stderr() + .contains("Human Panic Authors") + .stderr() + .contains("human-panic-crate@example.com") + .fails_with(101) + .unwrap(); +} From 1785e49403bbedc2918ef16227a4bfd6391fb29b Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 19 Apr 2018 16:46:42 +0200 Subject: [PATCH 09/13] Add editorconfig file for great ~~justice~~ formatting --- .editorconfig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3c1f41b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,25 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.rs] +indent_style = space +indent_size = 4 + +[*.toml] +indent_style = space +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false From ee8f742d28262e55250cc338b31c8c04a1b7ba98 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 19 Apr 2018 18:05:34 +0200 Subject: [PATCH 10/13] Rename simple test to single-panic --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- tests/{simple => single-panic}/Cargo.toml | 2 +- tests/{simple => single-panic}/src/main.rs | 0 tests/{simple => single-panic}/tests/integration.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename tests/{simple => single-panic}/Cargo.toml (84%) rename tests/{simple => single-panic}/src/main.rs (100%) rename tests/{simple => single-panic}/tests/integration.rs (86%) diff --git a/Cargo.lock b/Cargo.lock index e161894..808ebc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -343,7 +343,7 @@ dependencies = [ ] [[package]] -name = "simple-human-panic-test" +name = "single-panic-test" version = "0.1.0" dependencies = [ "assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5df5c5b..16051a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/yoshuawuyts/human-panic" homepage = "https://github.com/yoshuawuyts/human-panic" documentation = "https://docs.rs/human-panic" description = "Panic messages for humans" -authors = ["Yoshua Wuyts ", +authors = ["Yoshua Wuyts ", "Pascal Hertleif ", "Katharina Fey "] readme = "README.md" @@ -30,5 +30,5 @@ nightly = [] [workspace] members = [ - "tests/simple", + "tests/single-panic", ] diff --git a/tests/simple/Cargo.toml b/tests/single-panic/Cargo.toml similarity index 84% rename from tests/simple/Cargo.toml rename to tests/single-panic/Cargo.toml index 3c62003..00e3516 100644 --- a/tests/simple/Cargo.toml +++ b/tests/single-panic/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "simple-human-panic-test" +name = "single-panic-test" version = "0.1.0" authors = ["Human Panic Authors "] diff --git a/tests/simple/src/main.rs b/tests/single-panic/src/main.rs similarity index 100% rename from tests/simple/src/main.rs rename to tests/single-panic/src/main.rs diff --git a/tests/simple/tests/integration.rs b/tests/single-panic/tests/integration.rs similarity index 86% rename from tests/simple/tests/integration.rs rename to tests/single-panic/tests/integration.rs index bb5aed1..b242e22 100644 --- a/tests/simple/tests/integration.rs +++ b/tests/single-panic/tests/integration.rs @@ -4,7 +4,7 @@ extern crate assert_cli; fn integration() { assert_cli::Assert::main_binary() .stderr() - .contains("simple-human-panic-test") + .contains("single-panic-test") .stderr() .contains("Human Panic Authors") .stderr() From d409416abc3daf2a655a5bcc678f4adb276e86d9 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Thu, 19 Apr 2018 19:56:57 +0200 Subject: [PATCH 11/13] Adding an example of a dump file so people know what data to expect --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 74fd532..2c35b44 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,49 @@ We take privacy seriously, and do not perform any automated error collection. In Thank you kindly! ``` +The error dump file generated by `human-panic` contains the following fields. + +``` +name = 'single-panic-test' +operating_system = 'unix:Unknown' +crate_version = '0.1.0' +explanation = ''' +Cause: OMG EVERYTHING IS ON FIRE!!!. Panic occurred in file 'tests/single-panic/src/main.rs' at line 8 +''' +method = 'Panic' +backtrace = ''' +stack backtrace: + 0: 0x55fa0ed4c1b4 - backtrace::backtrace::libunwind::trace::h69e50feca54bfb84 + at /home/spacekookie/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.6/src/backtrace/libunwind.rs:53 + - backtrace::backtrace::trace::h42967341e0b01ccc + at /home/spacekookie/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.6/src/backtrace/mod.rs:42 + + # ... + + 8: 0x55fa0ebaac8d - single_panic_test::main::h56a3d326bcecfc36 + at tests/single-panic/src/main.rs:8 + 9: 0x55fa0ebaae91 - std::rt::lang_start::{{closure}}::h09d28d8540038bf8 + at /checkout/src/libstd/rt.rs:74 + 10: 0x55fa0ed732f7 - std::rt::lang_start_internal::{{closure}}::h2e4baf0a27c956a3 + at libstd/rt.rs:59 + - std::panicking::try::do_call::h73f98ed0647c7274 + at libstd/panicking.rs:305 + 11: 0x55fa0ed8551e - __rust_maybe_catch_panic + at libpanic_unwind/lib.rs:101 + 12: 0x55fa0ed6f7f5 - std::panicking::try::h18fbb145180d4cd9 + at libstd/panicking.rs:284 + - std::panic::catch_unwind::hc4b6a212a30b4bc5 + at libstd/panic.rs:361 + - std::rt::lang_start_internal::h8b001b4244930d51 + at libstd/rt.rs:58 + 13: 0x55fa0ebaae71 - std::rt::lang_start::h1b1de624209f414a + at /checkout/src/libstd/rt.rs:74 + 14: 0x55fa0ebaacbd - main + 15: 0x7f9946132f29 - __libc_start_main + 16: 0x55fa0eba9b79 - _start + 17: 0x0 - ''' +``` + ## Usage ```rust no_run From 6c3932f4a9b471c26b2460c58ae856002b2dc545 Mon Sep 17 00:00:00 2001 From: Katharina Sabel Date: Thu, 19 Apr 2018 20:15:15 +0200 Subject: [PATCH 12/13] Oh clippy my clippy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c35b44..f02685b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Thank you kindly! The error dump file generated by `human-panic` contains the following fields. -``` +```norun name = 'single-panic-test' operating_system = 'unix:Unknown' crate_version = '0.1.0' From 8b0ae5bd57283615543296dd0857f59c0ec6626c Mon Sep 17 00:00:00 2001 From: Katharina Date: Fri, 20 Apr 2018 11:28:49 +0200 Subject: [PATCH 13/13] Changing highlighting type to toml --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f02685b..86976ad 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Thank you kindly! The error dump file generated by `human-panic` contains the following fields. -```norun +```toml name = 'single-panic-test' operating_system = 'unix:Unknown' crate_version = '0.1.0'