From fb5ccf80fe83653018794562bfc105d6914384ae Mon Sep 17 00:00:00 2001 From: Josh Driver Date: Fri, 18 Nov 2016 21:01:19 +1030 Subject: Warn when a #[should_panic] test has an unexpected message --- src/test/run-fail/test-should-panic-bad-message.rs | 19 +++++++++++++++++++ src/test/run-fail/test-should-panic-no-message.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/test/run-fail/test-should-panic-bad-message.rs create mode 100644 src/test/run-fail/test-should-panic-no-message.rs (limited to 'src/test/run-fail') diff --git a/src/test/run-fail/test-should-panic-bad-message.rs b/src/test/run-fail/test-should-panic-bad-message.rs new file mode 100644 index 00000000000..7186672b404 --- /dev/null +++ b/src/test/run-fail/test-should-panic-bad-message.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +// error-pattern:panicked at 'bar' +// check-stdout +#[test] +#[should_panic(expected = "foo")] +pub fn test_bar() { + panic!("bar") +} diff --git a/src/test/run-fail/test-should-panic-no-message.rs b/src/test/run-fail/test-should-panic-no-message.rs new file mode 100644 index 00000000000..50dc2aed8e9 --- /dev/null +++ b/src/test/run-fail/test-should-panic-no-message.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +// error-pattern:panicked at 'explicit panic' +// check-stdout +#[test] +#[should_panic(expected = "foo")] +pub fn test_explicit() { + panic!() +} -- cgit 1.4.1-3-g733a5