Commit e2443534 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Vincent Pelletier

functional test : post result after each test so that we can get results even for timeout case.

parent 3cab1250
......@@ -307,7 +307,10 @@ class FunctionalTestRunner:
" to use your existing display instead of Xvfb.")
xvfb.run()
self.browser.run(self._getTestURL() , xvfb.display)
while self.getStatus() is None:
while True:
status = self.getStatus()
if status is not None and not '>ONGOING<' in status:
break
time.sleep(10)
if (time.time() - start) > float(self.timeout):
# TODO: here we could take a screenshot and display it in the report
......@@ -411,19 +414,22 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
self.runner.remote_code_url_list = self.remote_code_url_list
debug = self.foreground or os.environ.get("erp5_debug_mode")
self.runner.test(debug=debug)
error = None
try:
detail, success, failure, \
expected_failure, error_title_list = self.runner.processResult()
self.runner.test(debug=debug)
except TimeoutError, e:
error = repr(e)
self._verboseErrorLog(20)
raise
else:
# In case of failure, verbose the error_log entries in order to collect
# appropriated information to debug the system.
if self._hasActivityFailure():
error = 'Failed activities exist.'
self._verboseErrorLog(20)
detail, success, failure, \
expected_failure, error_title_list = self.runner.processResult()
self.logMessage("-" * 79)
total = success + failure + expected_failure
message_args = {"title": self.getTitle(),
......@@ -437,6 +443,7 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
self.logMessage(detail)
self.logMessage("-" * 79)
self.assertEqual([], error_title_list, '\n'.join(error_title_list))
self.assertEqual(None, error, error)
# monkey patch HTTPResponse._unauthorized so that we will not have HTTP
# authentication dialog in case of Unauthorized exception to prevent
......
......@@ -683,12 +683,15 @@ objectExtend(HtmlTestSuite.prototype, {
},
_startCurrentTestCase: function() {
if (this.currentRowInSuite > 1) {
new SeleniumTestResult(this.failed, this.getTestTable()).post(finished=false);
}
this.getCurrentRow().loadTestCase(fnBind(htmlTestRunner.startTest, htmlTestRunner));
},
_onTestSuiteComplete: function() {
this.markDone();
new SeleniumTestResult(this.failed, this.getTestTable()).post();
new SeleniumTestResult(this.failed, this.getTestTable()).post(finished=true);
},
updateSuiteWithResultOfPreviousTest: function() {
......@@ -740,7 +743,7 @@ objectExtend(SeleniumTestResult.prototype, {
this.suiteTable = suiteTable;
},
post: function () {
post: function (finished) {
if (!this.controlPanel.isAutomatedRun()) {
return;
}
......@@ -782,6 +785,7 @@ objectExtend(SeleniumTestResult.prototype, {
form.createHiddenField("selenium.revision", Selenium.revision);
form.createHiddenField("result", this.suiteFailed ? "failed" : "passed");
form.createHiddenField("finished", finished && "true" || "");
form.createHiddenField("totalTime", Math.floor((this.metrics.currentTime - this.metrics.startTime) / 1000));
form.createHiddenField("numTestPasses", this.metrics.numTestPasses);
......@@ -797,15 +801,13 @@ objectExtend(SeleniumTestResult.prototype, {
if (this.suiteTable.rows[rowNum].cells.length > 1) {
var resultCell = this.suiteTable.rows[rowNum].cells[1];
form.createHiddenField("testTable." + rowNum, resultCell.innerHTML);
// remove the resultCell, so it's not included in the suite HTML
resultCell.parentNode.removeChild(resultCell);
}
}
form.createHiddenField("numTestTotal", rowNum-1);
// Add HTML for the suite itself
form.createHiddenField("suite", this.suiteTable.parentNode.innerHTML);
// We don't use suite for our automated tests.
form.createHiddenField("suite", '');
var logMessages = [];
while (LOG.pendingMessages.length > 0) {
......@@ -824,7 +826,7 @@ objectExtend(SeleniumTestResult.prototype, {
form.submit();
}
document.body.removeChild(form);
if (this.controlPanel.closeAfterTests()) {
if (finished && this.controlPanel.closeAfterTests()) {
window.top.close();
}
},
......
......@@ -14,10 +14,15 @@
<tr>
<th align="left">Status</th>
<td>
<tal:block tal:condition="context/finished">
<span style="color: green"
tal:condition="context/passed">PASSED</span>
<span style="color: red"
tal:condition="not: context/passed">FAILED</span>
</tal:block>
<tal:block tal:condition="not: context/finished">
<span style="color: blue">ONGOING</span>
</tal:block>
</td>
</tr>
......
......@@ -317,7 +317,7 @@ class Zuite( OrderedFolder ):
testTable.<n> -- Colorized HTML of each test run
"""
completed = DateTime()
result_id = 'result_%s' % completed.strftime( '%Y%m%d_%H%M%S' )
result_id = 'result_%s' % completed.strftime( '%Y%m%d_%H%M%S.%f' )
self._setObject( result_id, ZuiteResults( result_id ) )
result = self._getOb( result_id )
rfg = REQUEST.form.get
......@@ -331,6 +331,10 @@ class Zuite( OrderedFolder ):
, rfg( 'result' ).lower() == 'passed'
)
result._updateProperty( 'finished'
, rfg( 'finished' ).lower() == 'true'
)
result._updateProperty( 'time_secs'
, float( rfg( 'totalTime', 0 ) )
)
......@@ -594,6 +598,10 @@ class ZuiteResults( Folder ):
, 'type' : 'date'
, 'mode' : 'w'
},
{ 'id' : 'finished'
, 'type' : 'boolean'
, 'mode' : 'w'
},
{ 'id' : 'passed'
, 'type' : 'boolean'
, 'mode' : 'w'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment