From 7746981679e36f2138b3f2008e472933a98c6a76 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 4 May 2015 15:06:46 -0700 Subject: 1259 - better failure messages for mu scenarios --- cpp/050scenario.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cpp/050scenario.cc b/cpp/050scenario.cc index 80778c39..07279d39 100644 --- a/cpp/050scenario.cc +++ b/cpp/050scenario.cc @@ -92,8 +92,11 @@ for (index_t i = 0; i < Scenarios.size(); ++i) { if (Passed) cerr << "."; } +:(before "End Globals") +const scenario* Current_scenario = NULL; :(code) void run_mu_scenario(const scenario& s) { + Current_scenario = &s; bool not_already_inside_test = !Trace_stream; if (not_already_inside_test) { Trace_file = s.name; @@ -110,6 +113,7 @@ void run_mu_scenario(const scenario& s) { Trace_stream = NULL; Trace_file = ""; } + Current_scenario = NULL; } //:: The special instructions we want to support inside scenarios. @@ -203,8 +207,14 @@ void check_memory(const string& s) { if (locations_checked.find(address) != locations_checked.end()) raise << "duplicate expectation for location " << address << '\n'; trace("run") << "checking location " << address; - if (Memory[address] != value) - raise << "expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n'; + if (Memory[address] != value) { + if (Current_scenario) + raise << "\nF - " << Current_scenario->name << ": expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n'; + else + raise << "expected location " << address << " to contain " << value << " but saw " << Memory[address] << '\n'; + Passed = false; + return; + } locations_checked.insert(address); } } -- cgit 1.4.1-2-gfad0