From dffb12b8df2c4c186523dc8475bf523a2d306624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ulises=20Ni=C3=B1o=20Rivera?= Date: Wed, 4 Sep 2024 17:02:02 -0700 Subject: [PATCH] Print out expectation context when the assertion count does not match expectations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Ulises Niño Rivera --- src/expectations.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/expectations.rs b/src/expectations.rs index f2bf2dc..7a68209 100644 --- a/src/expectations.rs +++ b/src/expectations.rs @@ -44,14 +44,17 @@ impl ExpectHandle { pub fn assert_stage(&self) { if self.staged.expect_count > 0 { panic!( - "Error: failed to consume all expectations - total remaining: {}", - self.staged.expect_count + "Error: failed to consume all expectations - total remaining: {}\n\ + expectation context:{:?}", + self.staged.expect_count, self.staged ); } else if self.staged.expect_count < 0 { panic!( "Error: expectations failed to account for all host calls by {} \n\ - if this is intended, please use --allow-unexpected (-a) mode", - -1 * self.staged.expect_count + if this is intended, please use --allow-unexpected (-a) mode.\n\ + expectation context:{:?}", + -1 * self.staged.expect_count, + self.staged ); } }