Skip to content

Commit

Permalink
Allow/fix non_fmt_panic in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Feb 2, 2021
1 parent 91a9866 commit 535f487
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 35 deletions.
12 changes: 6 additions & 6 deletions library/term/src/terminfo/parm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ fn test_comparison_ops() {
for &(op, bs) in v.iter() {
let s = format!("%{{1}}%{{2}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[0]]);
let s = format!("%{{1}}%{{1}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[1]]);
let s = format!("%{{2}}%{{1}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[2]]);
}
}
Expand All @@ -95,13 +95,13 @@ fn test_conditionals() {
let mut vars = Variables::new();
let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m";
let res = expand(s, &[Number(1)], &mut vars);
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::<Vec<_>>());
let res = expand(s, &[Number(8)], &mut vars);
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::<Vec<_>>());
let res = expand(s, &[Number(42)], &mut vars);
assert!(res.is_ok(), res.unwrap_err());
assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::<Vec<_>>());
}

Expand Down
2 changes: 1 addition & 1 deletion library/test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn test_should_panic_bad_message() {
fn test_should_panic_non_string_message_type() {
use crate::tests::TrFailedMsg;
fn f() {
panic!(1i32);
std::panic::panic_any(1i32);
}
let expected = "foobar";
let failed_msg = format!(
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui-fulldeps/issue-15149.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn test() {
.output().unwrap();

assert!(child_output.status.success(),
format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
str::from_utf8(&child_output.stdout).unwrap(),
str::from_utf8(&child_output.stderr).unwrap()));
"child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
str::from_utf8(&child_output.stdout).unwrap(),
str::from_utf8(&child_output.stderr).unwrap());
}
1 change: 1 addition & 0 deletions src/test/ui/consts/const-eval/const_panic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(const_panic)]
#![allow(non_fmt_panic)]
#![crate_type = "lib"]

const MSG: &str = "hello";
Expand Down
40 changes: 20 additions & 20 deletions src/test/ui/consts/const-eval/const_panic.stderr
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
error: any use of this value will cause an error
--> $DIR/const_panic.rs:6:15
--> $DIR/const_panic.rs:7:15
|
LL | const Z: () = std::panic!("cheese");
| --------------^^^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
|
= note: `#[deny(const_err)]` on by default
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:9:16
--> $DIR/const_panic.rs:10:16
|
LL | const Z2: () = std::panic!();
| ---------------^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:12:15
--> $DIR/const_panic.rs:13:15
|
LL | const Y: () = std::unreachable!();
| --------------^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:15:15
--> $DIR/const_panic.rs:16:15
|
LL | const X: () = std::unimplemented!();
| --------------^^^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:18:15
--> $DIR/const_panic.rs:19:15
|
LL | const W: () = std::panic!(MSG);
| --------------^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:21:20
--> $DIR/const_panic.rs:22:20
|
LL | const Z_CORE: () = core::panic!("cheese");
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:21:20
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:24:21
--> $DIR/const_panic.rs:25:21
|
LL | const Z2_CORE: () = core::panic!();
| --------------------^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:24:21
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:27:20
--> $DIR/const_panic.rs:28:20
|
LL | const Y_CORE: () = core::unreachable!();
| -------------------^^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:27:20
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:30:20
--> $DIR/const_panic.rs:31:20
|
LL | const X_CORE: () = core::unimplemented!();
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:30:20
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
--> $DIR/const_panic.rs:33:20
--> $DIR/const_panic.rs:34:20
|
LL | const W_CORE: () = core::panic!(MSG);
| -------------------^^^^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:33:20
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/drop/dynamic-drop-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Allocator {
self.cur_ops.set(self.cur_ops.get() + 1);

if self.cur_ops.get() == self.failing_op {
panic!(InjectedFailure);
panic::panic_any(InjectedFailure);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/drop/dynamic-drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Allocator {
self.cur_ops.set(self.cur_ops.get() + 1);

if self.cur_ops.get() == self.failing_op {
panic!(InjectedFailure);
panic::panic_any(InjectedFailure);
}

let mut data = self.data.borrow_mut();
Expand All @@ -67,7 +67,7 @@ impl<'a> Drop for Ptr<'a> {
self.1.cur_ops.set(self.1.cur_ops.get() + 1);

if self.1.cur_ops.get() == self.1.failing_op {
panic!(InjectedFailure);
panic::panic_any(InjectedFailure);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/macros/assert-macro-owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// error-pattern:panicked at 'test-assert-owned'
// ignore-emscripten no processes

#![allow(non_fmt_panic)]

fn main() {
assert!(false, "test-assert-owned".to_string());
}
2 changes: 1 addition & 1 deletion src/test/ui/mir/mir_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() {
assert_eq!(get(), vec![0, 2, 3, 1]);

let _ = std::panic::catch_unwind(|| {
(d(4), &d(5), d(6), &d(7), panic!(InjectedFailure));
(d(4), &d(5), d(6), &d(7), panic::panic_any(InjectedFailure));
});

// here, the temporaries (5/7) live until the end of the
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/panics/explicit-panic-msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_assignments)]
#![allow(unused_variables)]
#![allow(non_fmt_panic)]

// run-fail
// error-pattern:wooooo
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/panics/panic-macro-any-wrapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// error-pattern:panicked at 'Box<Any>'
// ignore-emscripten no processes

#![allow(non_fmt_panic)]

fn main() {
panic!(Box::new(612_i64));
}
1 change: 1 addition & 0 deletions src/test/ui/panics/panic-macro-any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ignore-emscripten no processes

#![feature(box_syntax)]
#![allow(non_fmt_panic)]

fn main() {
panic!(box 413 as Box<dyn std::any::Any + Send>);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/panics/while-panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ignore-emscripten no processes

fn main() {
panic!({
panic!("{}", {
while true {
panic!("giraffe")
}
Expand Down

0 comments on commit 535f487

Please sign in to comment.