mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Error logs
This commit is contained in:
		
							parent
							
								
									b12507c55e
								
							
						
					
					
						commit
						d6d8951baf
					
				| @ -253,15 +253,15 @@ void ImportTest::importTransaction(json_spirit::mObject const& o_tr) | ||||
| 	importTransaction(o_tr, m_transaction); | ||||
| } | ||||
| 
 | ||||
| void ImportTest::compareStates(State const& _stateExpect, State const& _statePost, AccountMaskMap const _expectedStateOptions, WhenError _throw) | ||||
| int ImportTest::compareStates(State const& _stateExpect, State const& _statePost, AccountMaskMap const _expectedStateOptions, WhenError _throw) | ||||
| { | ||||
| 	#define CHECK(a,b)						\ | ||||
| 		{									\ | ||||
| 			if (_throw == WhenError::Throw) \ | ||||
| 			{								\ | ||||
| 				TBOOST_CHECK(a);			\ | ||||
| 				TBOOST_CHECK_MESSAGE(a, b);	\ | ||||
| 				if (!a)						\ | ||||
| 					std::cerr << b << std::endl;\ | ||||
| 					return 1;				\ | ||||
| 			}								\ | ||||
| 			else							\ | ||||
| 				{TBOOST_WARN_MESSAGE(a,b);}	\ | ||||
| @ -313,20 +313,26 @@ void ImportTest::compareStates(State const& _stateExpect, State const& _statePos | ||||
| 						"Check State: " << a.first <<  ": incorrect code '" << toHex(_statePost.code(a.first)) << "', expected '" << toHex(_stateExpect.code(a.first)) << "'"); | ||||
| 		} | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| void ImportTest::exportTest(bytes const& _output) | ||||
| int ImportTest::exportTest(bytes const& _output) | ||||
| { | ||||
| 	// export output
 | ||||
| 
 | ||||
| 	m_testObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add); | ||||
| 	int err = 0; | ||||
| 	// export output	
 | ||||
| 	m_TestObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add); | ||||
| 
 | ||||
| 	// compare expected output with post output
 | ||||
| 	if (m_testObject.count("expectOut") > 0) | ||||
| 	{ | ||||
| 		std::string warning = "Check State: Error! Unexpected output: " + m_testObject["out"].get_str() + " Expected: " + m_testObject["expectOut"].get_str(); | ||||
| 		if (Options::get().checkState) | ||||
| 			{TBOOST_CHECK_MESSAGE((m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()), warning);} | ||||
| 		{ | ||||
| 			bool statement = (m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()); | ||||
| 			TBOOST_CHECK_MESSAGE(statement, warning); | ||||
| 			if (!statement) | ||||
| 				err = 1; | ||||
| 		} | ||||
| 		else | ||||
| 			TBOOST_WARN_MESSAGE((m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()), warning); | ||||
| 
 | ||||
| @ -354,6 +360,7 @@ void ImportTest::exportTest(bytes const& _output) | ||||
| 	m_testObject["pre"] = fillJsonWithState(m_statePre); | ||||
| 	m_testObject["env"] = makeAllFieldsHex(m_testObject["env"].get_obj()); | ||||
| 	m_testObject["transaction"] = makeAllFieldsHex(m_testObject["transaction"].get_obj()); | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| json_spirit::mObject fillJsonWithTransaction(Transaction _txn) | ||||
| @ -570,7 +577,10 @@ void userDefinedTest(std::function<void(json_spirit::mValue&, bool)> doTests) | ||||
| 
 | ||||
| 	auto& filename = Options::get().singleTestFile; | ||||
| 	auto& testname = Options::get().singleTestName; | ||||
| 	VerbosityHolder sentinel(12); | ||||
| 
 | ||||
| 	if (g_logVerbosity != -1) | ||||
| 		VerbosityHolder sentinel(12); | ||||
| 
 | ||||
| 	try | ||||
| 	{ | ||||
| 		cnote << "Testing user defined test: " << filename; | ||||
| @ -635,7 +645,7 @@ void executeTests(const string& _name, const string& _testPathAppendix, const bo | ||||
| 
 | ||||
| 	try | ||||
| 	{ | ||||
| 		std::cout << "TEST " << _name << ":\n"; | ||||
| 		cnote << "TEST " << _name << ":"; | ||||
| 		json_spirit::mValue v; | ||||
| 		string s = asString(dev::contents(testPath + "/" + _name + ".json")); | ||||
| 		TBOOST_REQUIRE_MESSAGE((s.length() > 0), "Contents of " + testPath + "/" + _name + ".json is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?"); | ||||
| @ -779,16 +789,16 @@ Options::Options() | ||||
| 			fulloutput = true; | ||||
| 		else if (arg == "--verbosity" && i + 1 < argc) | ||||
| 		{ | ||||
| 			static std::ostringstream strCout; | ||||
| 			std::string depthLevel = std::string{argv[i + 1]}; | ||||
| 			if (depthLevel == "0") | ||||
| 			static std::ostringstream strCout; //static string to redirect logs to
 | ||||
| 			std::string indentLevel = std::string{argv[i + 1]}; | ||||
| 			if (indentLevel == "0") | ||||
| 			{ | ||||
| 				logVerbosity = Verbosity::None; | ||||
| 				std::cout.rdbuf( strCout.rdbuf() ); | ||||
| 				std::cerr.rdbuf( strCout.rdbuf() ); | ||||
| 				std::cout.rdbuf(strCout.rdbuf()); | ||||
| 				std::cerr.rdbuf(strCout.rdbuf()); | ||||
| 			} | ||||
| 			else | ||||
| 			if (depthLevel == "1") | ||||
| 			if (indentLevel == "1") | ||||
| 				logVerbosity = Verbosity::NiceReport; | ||||
| 			else | ||||
| 				logVerbosity = Verbosity::Full; | ||||
| @ -797,7 +807,7 @@ Options::Options() | ||||
| 
 | ||||
| 	//Default option
 | ||||
| 	if (logVerbosity == Verbosity::NiceReport) | ||||
| 		g_logVerbosity = -1;	//disable cnote but not the cerr
 | ||||
| 		g_logVerbosity = -1;	//disable cnote but leave cerr and cout
 | ||||
| } | ||||
| 
 | ||||
| Options const& Options::get() | ||||
|  | ||||
| @ -22,7 +22,6 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include <functional> | ||||
| 
 | ||||
| #include <boost/test/unit_test.hpp> | ||||
| #include <boost/filesystem.hpp> | ||||
| 
 | ||||
| @ -143,8 +142,8 @@ public: | ||||
| 	static json_spirit::mObject& makeAllFieldsHex(json_spirit::mObject& _o); | ||||
| 
 | ||||
| 	bytes executeTest(); | ||||
| 	void exportTest(bytes const& _output); | ||||
| 	static void compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw); | ||||
| 	int exportTest(bytes const& _output); | ||||
| 	static int compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw); | ||||
| 
 | ||||
| 	eth::State m_statePre; | ||||
| 	eth::State m_statePost; | ||||
|  | ||||
| @ -24,5 +24,62 @@ | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||
| #define BOOST_DISABLE_WIN32 //disables SEH warning
 | ||||
| #define BOOST_TEST_NO_MAIN | ||||
| #include <boost/test/included/unit_test.hpp> | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| #include <test/TestHelper.h> | ||||
| using namespace boost::unit_test; | ||||
| 
 | ||||
| //Custom Boost Initialization
 | ||||
| test_suite* init_func( int argc, char* argv[] ) | ||||
| { | ||||
| 	if (argc == 0) | ||||
| 		argv[1]=(char*)"a"; | ||||
| 
 | ||||
| 	dev::test::Options::get(); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| //Custom Boost Unit Test Main
 | ||||
| int main( int argc, char* argv[] ) | ||||
| { | ||||
| 	try { | ||||
| 		framework::init( init_func, argc, argv ); | ||||
| 
 | ||||
| 		if( !runtime_config::test_to_run().is_empty() ) { | ||||
| 			test_case_filter filter( runtime_config::test_to_run() ); | ||||
| 
 | ||||
| 			traverse_test_tree( framework::master_test_suite().p_id, filter ); | ||||
| 		} | ||||
| 
 | ||||
| 		framework::run(); | ||||
| 
 | ||||
| 		results_reporter::make_report(); | ||||
| 
 | ||||
| 		return runtime_config::no_result_code() | ||||
| 					? boost::exit_success | ||||
| 					: results_collector.results( framework::master_test_suite().p_id ).result_code(); | ||||
| 	} | ||||
| 	catch( framework::nothing_to_test const& ) { | ||||
| 		return boost::exit_success; | ||||
| 	} | ||||
| 	catch( framework::internal_error const& ex ) { | ||||
| 		results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl; | ||||
| 
 | ||||
| 		return boost::exit_exception_failure; | ||||
| 	} | ||||
| 	catch( framework::setup_error const& ex ) { | ||||
| 		results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl; | ||||
| 
 | ||||
| 		return boost::exit_exception_failure; | ||||
| 	} | ||||
| 	catch( ... ) { | ||||
| 		results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl; | ||||
| 
 | ||||
| 		return boost::exit_exception_failure; | ||||
| 	} | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| @ -44,7 +44,9 @@ class ExecutionFramework | ||||
| public: | ||||
| 	ExecutionFramework() | ||||
| 	{ | ||||
| 		g_logVerbosity = 0; | ||||
| 		if (g_logVerbosity != -1) | ||||
| 			g_logVerbosity = 0; | ||||
| 		m_state.resetCurrent(); | ||||
| 	} | ||||
| 
 | ||||
| 	bytes const& compileAndRunWithoutCheck( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user