|
From: Andre R. <and...@us...> - 2006-02-18 10:07:14
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/suites/fUnit/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14468/engine Modified Files: Tag: fUnit_Suite-branch runTestSuite Log Message: Default to storing test results in temp table rather than in user table. Index: runTestSuite =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/suites/fUnit/engine/Attic/runTestSuite,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** runTestSuite 22 Aug 2005 00:41:37 -0000 1.1.2.1 --- runTestSuite 18 Feb 2006 10:07:10 -0000 1.1.2.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:suites.fUnit.engine.runTestSuite ! on runTestSuite (suiteAdr, resultsTableAdr = @user.fUnitResults, recursive = 0, testCaseToRun = nil, displayTestResults = false, allowErrorsOut = false) { ÇResponsible for running the test suite and generating the results table. Parameter "recursive" indicates if this is a recursive call to runTestSuite, in which case we should not initialize the results table. ÇallowErrorsOut indicates if we should catch the errors, or allow the scriptError to propogate all the way out to the user for debugging purposes. on isTestSuite(adr) { return fUnit.engine.isTestSuite(adr)}; on isTestCase(adr) { return fUnit.engine.isTestCase(adr)}; suiteAdr = isTestSuite(suiteAdr); if not suiteAdr { // validate this is a suite scriptError("Can't run tests on " + suiteAdr + " because it is not a test suite.")}; if not recursive { // initialize results table fUnit.engine.initializeResultsTable(resultsTableAdr); if displayTestResults { edit(resultsTableAdr)}}; local (testCases = {}, testSuites = {}, setup, teardown, name = nameOf(suiteAdr^), description = "", adr, testSuite, testCase, setupResults); bundle { // scan the suite table for tests, suites, and constants bundle { // scan for the constant names if defined(suiteAdr^.setup) { setup = @suiteAdr^.setup}; if defined(suiteAdr^.teardown) { teardown = @suiteAdr^.teardown}; if defined(suiteAdr^.name) { name = suiteAdr^.name}; if defined(suiteAdr^.description) { description = suiteAdr^.description}}; if testCaseToRun { // add this test case only testCases = testCases + testCaseToRun} else { // collect test cases and suites for adr in suiteAdr { testSuite = isTestSuite(adr); if testSuite { testSuites = testSuites + testSuite}; testCase = isTestCase(adr); if testCase { testCases = testCases + testCase}}}}; bundle { // run this test suite for testCase in testCases { if setup { // run setup if it exists try { // to run setup setupResults = setup^()} else { scriptError("Can't run test suite \"" + name + "\" because the setup script failed while trying to run \"" + nameOf(testCase^) + "\" with the following error: " + tryError)}} else { setupResults = null}; local (error = nil); msg ("Running case " + nameOf(testCase^) + " in " + name); script.unCompile(testCase); // paranoia new(nil, @fUnit.contextForTests.stackDump); local (parms = {}); if setupResults { parms = parms + setupResults}; if allowErrorsOut { // run test case with requested error handling callScript(testCase, parms, @fUnit.contextForTests)} else { try { callScript(testCase, parms, @fUnit.contextForTests)} else { error = tryError}}; if !error { // record result table.uniqueName("pass", @resultsTableAdr^.passed, 5)^ = nameOf(testCase^)} else { if error beginsWith "[aborted]" { // test was aborted error = string.replace(error, "[aborted]", ""); local (abortTblAdr = table.uniqueName("aborted", @resultsTableAdr^.aborted, 5)); new (tableType, abortTblAdr); abortTblAdr^.name = nameOf(testCase^); abortTblAdr^.message = error} else { // actual failure local (errorTblAdr = table.uniqueName("failed", @resultsTableAdr^.failed, 5)); new (tableType, errorTblAdr); errorTblAdr^.name = nameOf(testCase^); errorTblAdr^.suite = name; errorTblAdr^.error = error; if (defined(fUnit.contextForTests.stackDump) && typeOf(fUnit.contextForTests.stackDump) == tableType) { errorTblAdr^.stackDump = fUnit.contextForTests.stackDump}}}; if teardown { // run teardown if it exists try { teardown^(setupResults)} else { scriptError("Can't continue to run test suite \"" + name + "\" because the teardown script failed after running \"" + nameOf(testCase^) + "\" with the following error: " + tryError)}}}}; bundle { // run the child test suites for suite in testSuites { fUnit.engine.runTestSuite(suite, resultsTableAdr, 1)}}; bundle { //cleanup if defined(fUnit.contextForTests.stackDump) { delete(@fUnit.contextForTests.stackDump)}; bundle { // remove any stray temp tables created by fUnit.getTempTable local (tempname, templist = {}); for tempname in @temp { if nameOf(tempname^) beginsWith "fUnit" { templist = templist + tempname}}; for tempname in templist { delete(tempname)}}}; return resultsTableAdr}; // for the TestRunner to process and display runTestSuite(@fUnit.testGlobalSuite, displayTestResults: true) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:suites.fUnit.engine.runTestSuite ! on runTestSuite (suiteAdr, resultsTableAdr = @temp.resultsfUnit, recursive = 0, testCaseToRun = nil, displayTestResults = false, allowErrorsOut = false) { ÇResponsible for running the test suite and generating the results table. Parameter "recursive" indicates if this is a recursive call to runTestSuite, in which case we should not initialize the results table. ÇallowErrorsOut indicates if we should catch the errors, or allow the scriptError to propogate all the way out to the user for debugging purposes. on isTestSuite(adr) { return fUnit.engine.isTestSuite(adr)}; on isTestCase(adr) { return fUnit.engine.isTestCase(adr)}; suiteAdr = isTestSuite(suiteAdr); if not suiteAdr { // validate this is a suite scriptError("Can't run tests on " + suiteAdr + " because it is not a test suite.")}; if not recursive { // initialize results table fUnit.engine.initializeResultsTable(resultsTableAdr); if displayTestResults { edit(resultsTableAdr)}}; local (testCases = {}, testSuites = {}, setup, teardown, name = nameOf(suiteAdr^), description = "", adr, testSuite, testCase, setupResults); bundle { // scan the suite table for tests, suites, and constants bundle { // scan for the constant names if defined(suiteAdr^.setup) { setup = @suiteAdr^.setup}; if defined(suiteAdr^.teardown) { teardown = @suiteAdr^.teardown}; if defined(suiteAdr^.name) { name = suiteAdr^.name}; if defined(suiteAdr^.description) { description = suiteAdr^.description}}; if testCaseToRun { // add this test case only testCases = testCases + testCaseToRun} else { // collect test cases and suites for adr in suiteAdr { testSuite = isTestSuite(adr); if testSuite { testSuites = testSuites + testSuite}; testCase = isTestCase(adr); if testCase { testCases = testCases + testCase}}}}; bundle { // run this test suite for testCase in testCases { if setup { // run setup if it exists try { // to run setup setupResults = setup^()} else { scriptError("Can't run test suite \"" + name + "\" because the setup script failed while trying to run \"" + nameOf(testCase^) + "\" with the following error: " + tryError)}} else { setupResults = null}; local (error = nil); msg ("Running case " + nameOf(testCase^) + " in " + name); script.unCompile(testCase); // paranoia new(nil, @fUnit.contextForTests.stackDump); local (parms = {}); if setupResults { parms = parms + setupResults}; if allowErrorsOut { // run test case with requested error handling callScript(testCase, parms, @fUnit.contextForTests)} else { try { callScript(testCase, parms, @fUnit.contextForTests)} else { error = tryError}}; if !error { // record result table.uniqueName("pass", @resultsTableAdr^.passed, 5)^ = nameOf(testCase^)} else { if error beginsWith "[aborted]" { // test was aborted error = string.replace(error, "[aborted]", ""); local (abortTblAdr = table.uniqueName("aborted", @resultsTableAdr^.aborted, 5)); new (tableType, abortTblAdr); abortTblAdr^.name = nameOf(testCase^); abortTblAdr^.message = error} else { // actual failure local (errorTblAdr = table.uniqueName("failed", @resultsTableAdr^.failed, 5)); new (tableType, errorTblAdr); errorTblAdr^.name = nameOf(testCase^); errorTblAdr^.suite = name; errorTblAdr^.error = error; if (defined(fUnit.contextForTests.stackDump) && typeOf(fUnit.contextForTests.stackDump) == tableType) { errorTblAdr^.stackDump = fUnit.contextForTests.stackDump}}}; if teardown { // run teardown if it exists try { teardown^(setupResults)} else { scriptError("Can't continue to run test suite \"" + name + "\" because the teardown script failed after running \"" + nameOf(testCase^) + "\" with the following error: " + tryError)}}}}; bundle { // run the child test suites for suite in testSuites { fUnit.engine.runTestSuite(suite, resultsTableAdr, 1)}}; bundle { //cleanup if defined(fUnit.contextForTests.stackDump) { delete(@fUnit.contextForTests.stackDump)}; bundle { // remove any stray temp tables created by fUnit.getTempTable local (tempname, templist = {}); for tempname in @temp { if nameOf(tempname^) beginsWith "fUnit" { templist = templist + tempname}}; for tempname in templist { delete(tempname)}}}; return resultsTableAdr}; // for the TestRunner to process and display runTestSuite(@fUnit.testGlobalSuite, displayTestResults: true) \ No newline at end of file |