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