From: Andrew K. <aja...@us...> - 2005-12-07 17:57:56
|
Update of /cvsroot/aaf/AAF/Utilities/AAFAnalyzer/AAFAnalyzer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23012/AAFAnalyzer Modified Files: AAFAnalyzerMain.cpp Log Message: Added verbose output option and error codes. Index: AAFAnalyzerMain.cpp =================================================================== RCS file: /cvsroot/aaf/AAF/Utilities/AAFAnalyzer/AAFAnalyzer/AAFAnalyzerMain.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AAFAnalyzerMain.cpp 1 Dec 2005 19:18:19 -0000 1.19 --- AAFAnalyzerMain.cpp 7 Dec 2005 17:57:45 -0000 1.20 *************** *** 121,125 **** } ! void OutputResultMsgs(shared_ptr<const TestResult> res, unsigned int level) { wcout << LevelToIndent(level) << "Name: " << res->GetName() << endl; --- 121,125 ---- } ! void OutputVerboseResultMsgs(shared_ptr<const TestResult> res, unsigned int level) { wcout << LevelToIndent(level) << "Name: " << res->GetName() << endl; *************** *** 163,167 **** TestResult::SubtestResultVector subResults = res->GetSubtestResults(); for (unsigned int i = 0; i < subResults.size(); i++) { ! OutputResultMsgs(subResults.at(i), level + 1); } } --- 163,167 ---- TestResult::SubtestResultVector subResults = res->GetSubtestResults(); for (unsigned int i = 0; i < subResults.size(); i++) { ! OutputVerboseResultMsgs(subResults.at(i), level + 1); } } *************** *** 169,172 **** --- 169,201 ---- } + void OutputSimpleResultMsgs( shared_ptr<const TestResult> res ) + { + + Requirement::RequirementMap::const_iterator iter; + + const Requirement::RequirementMap& failures = res->GetRequirements( TestResult::FAIL ); + for ( iter = failures.begin(); iter != failures.end(); iter++ ) + { + shared_ptr<const Requirement> req = iter->second; + wcout << req->GetId() << L": \"" << req->GetName() << L"\" caused a failure." << endl; + wcout << L"Description: " << req->GetDescription() << endl; + wcout << L"See " << req->GetDocument() << L"(" << req->GetVersion() + << L") Section " << req->GetSection() << endl; + wcout << endl; + } + + const Requirement::RequirementMap& warnings = res->GetRequirements( TestResult::WARN ); + for ( iter = warnings.begin(); iter != warnings.end(); iter++ ) + { + shared_ptr<const Requirement> req = iter->second; + wcout << req->GetId() << L": \"" << req->GetName() << L"\" caused a warning." << endl; + wcout << L"Description: " << req->GetDescription() << endl; + wcout << L"See " << req->GetDocument() << L"(" << req->GetVersion() + << L") Section " << req->GetSection() << endl; + wcout << endl; + } + + } + void RegisterTests() { *************** *** 232,235 **** --- 261,265 ---- os << "-allreqs: Output all loaded requirements" << endl; os << "-coverage: Output all requirements covered by the test suite." << endl; + os << "-verbose: Output details of how warnings and failures were discovered." << endl; return os; }; *************** *** 246,249 **** --- 276,281 ---- using namespace aafanalyzer; + int regressionTestModifier = 1; + try { *************** *** 265,268 **** --- 297,311 ---- // Allow test to register with unregistered requirements pair<bool, int> unsafeRegistryArg = args.get ( "-uncheckedrequirements" ); + + // Show verbose output + pair<bool, int> verboseOutput = args.get( "-verbose" ); + + // Undocumented parameter used to return 0 when the regression tests run + // even if there are failures + pair<bool, int> regressionTest = args.get( "-regressiontest" ); + if ( regressionTest.first ) + { + regressionTestModifier = 0; + } // Filename is the second last argument. *************** *** 272,276 **** pair<bool, const char*> requirementsFile = args.get( argc-1, 2 ); ! int numFlags = dumpArg.first + allReqsArg.first + coverageArg.first + unsafeRegistryArg.first; bool runTests; --- 315,321 ---- pair<bool, const char*> requirementsFile = args.get( argc-1, 2 ); ! int numFlags = dumpArg.first + allReqsArg.first + coverageArg.first + ! unsafeRegistryArg.first + verboseOutput.first + ! regressionTest.first; bool runTests; *************** *** 317,320 **** --- 362,366 ---- if ( !runTests && !coverageArg.first ) { + //No tests were run so report a success. return 0; } *************** *** 337,340 **** --- 383,387 ---- if ( !runTests ) { + //No tests were run so report a success. return 0; } *************** *** 376,381 **** } ! spResult->SetResult(spResult->GetAggregateResult()); ! OutputResultMsgs(spResult, 0); } catch ( const Usage& ex ) --- 423,453 ---- } ! spResult->SetResult(spResult->GetAggregateResult()); ! if ( verboseOutput.first ) ! { ! OutputVerboseResultMsgs(spResult, 0); ! } ! else ! { ! OutputSimpleResultMsgs( spResult ); ! } ! ! TestResult::Result exitCode = spResult->GetResult(); ! if ( exitCode == TestResult::FAIL ) ! { ! //Failures occured ! return 1 * regressionTestModifier; ! } ! else if ( exitCode == TestResult::WARN ) ! { ! //Warnings, but no failures occured ! return 2 * regressionTestModifier; ! } ! else ! { ! //All tests passed ! return 0; ! } ! } catch ( const Usage& ex ) *************** *** 424,427 **** } ! return 0; } --- 496,500 ---- } ! //An exception occured and all tests were not run. ! return 3 * regressionTestModifier; } |