[FIX] phantom 1.9.2 OS X 10.9 bug
bzr revid: ddm@openerp.com-20140107114740-7d2444m2fma44v69
This commit is contained in:
@@ -77,7 +77,7 @@ class WebsiteUiSuite(unittest.TestSuite):
|
||||
self._options['db'] = tools.config.get('db_name', '')
|
||||
# TODO use correct key from tools if exists (I could not find it --ddm)
|
||||
self._options['user'] = 'admin'
|
||||
self._options['admin_password'] = tools.config.get('admin_passwd', 'admin')
|
||||
self._options['password'] = tools.config.get('admin_passwd', 'admin')
|
||||
|
||||
phantom = subprocess.Popen([
|
||||
'phantomjs',
|
||||
@@ -88,6 +88,7 @@ class WebsiteUiSuite(unittest.TestSuite):
|
||||
readable = [LineReader(phantom.stdout.fileno())]
|
||||
|
||||
try:
|
||||
output = []
|
||||
while phantom.poll() is None and readable and last_check_time < start_time + self._timeout:
|
||||
ready, _, _ = select.select(readable, [], [], 0.1)
|
||||
if not ready:
|
||||
@@ -95,12 +96,15 @@ class WebsiteUiSuite(unittest.TestSuite):
|
||||
continue
|
||||
for stream in ready:
|
||||
lines = stream.readlines()
|
||||
if lines is None:
|
||||
# EOF
|
||||
if lines is None: # EOF
|
||||
# Fixes an issue with PhantomJS 1.9.2 on OS X Mavericks
|
||||
# cf. https://github.com/ariya/phantomjs/issues/11418
|
||||
filtered_lines = [line for line in output if "CoreText performance note" not in line]
|
||||
if (filtered_lines):
|
||||
self.process(filtered_lines, result)
|
||||
readable.remove(stream)
|
||||
else:
|
||||
self.process(lines, result)
|
||||
readable.remove(stream)
|
||||
output += lines
|
||||
if last_check_time >= (start_time + self._timeout):
|
||||
result.addError(self._test, "Timeout after %s s" % (last_check_time - start_time ))
|
||||
finally:
|
||||
@@ -128,15 +132,17 @@ class WebsiteUiSuite(unittest.TestSuite):
|
||||
message = args.get('message', "")
|
||||
result.addError(self._test, message+"\n"+"\n".join(lines[1::]))
|
||||
else:
|
||||
result.addError(self._test, 'Unexpected message: "%s"' % "\n".join(lines))
|
||||
message = "\n".join(lines)
|
||||
result.addError(self._test, 'Unexpected message: "%s"' % message)
|
||||
except ValueError:
|
||||
result.addError(self._test, 'Unexpected message: "%s"' % "\n".join(lines))
|
||||
message = "\n".join(lines)
|
||||
result.addError(self._test, 'Unexpected message: "%s"' % message)
|
||||
|
||||
def full_path(filename):
|
||||
return os.path.join(os.path.join(os.path.dirname(__file__), 'ui_suite'), filename)
|
||||
|
||||
def load_tests(loader, base, _):
|
||||
base.addTest(WebsiteUiSuite(full_path('dummy_test.js'), {}))
|
||||
base.addTest(WebsiteUiSuite(full_path('simple_dom_test.js'), { 'action': 'website.action_website_homepage' }, 120.0))
|
||||
base.addTest(WebsiteUiSuite(full_path('homepage_test.js'), { 'action': 'website.action_website_homepage' }, 120.0))
|
||||
base.addTest(WebsiteUiSuite(full_path('simple_dom_test.js'), { 'action': 'website.action_website_homepage' }, 60.0))
|
||||
base.addTest(WebsiteUiSuite(full_path('homepage_test.js'), { 'action': 'website.action_website_homepage' }, 60.0))
|
||||
return base
|
||||
|
||||
@@ -2,7 +2,7 @@ var testRunner = require('./ui_test_runner.js');
|
||||
|
||||
var waitFor = testRunner.waitFor;
|
||||
|
||||
testRunner.run(function homepageTest (page) {
|
||||
testRunner.run(function homepageTest (page, timeout) {
|
||||
page.evaluate(function () { localStorage.clear(); });
|
||||
waitFor(function clientReady () {
|
||||
return page.evaluate(function () {
|
||||
@@ -31,6 +31,6 @@ testRunner.run(function homepageTest (page) {
|
||||
}, function finish () {
|
||||
console.log('{ "event": "success" }');
|
||||
phantom.exit();
|
||||
}, 90000);
|
||||
}, 20000);
|
||||
}, 4*timeout/5);
|
||||
}, timeout/5);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ var testRunner = require('./ui_test_runner.js');
|
||||
|
||||
var waitFor = testRunner.waitFor;
|
||||
|
||||
testRunner.run(function simpleDomTest (page) {
|
||||
testRunner.run(function simpleDomTest (page, timeout) {
|
||||
waitFor(function clientReady () {
|
||||
return page.evaluate(function () {
|
||||
return window.openerp && window.openerp.website;
|
||||
@@ -10,5 +10,5 @@ testRunner.run(function simpleDomTest (page) {
|
||||
}, function finish () {
|
||||
console.log('{ "event": "success" }');
|
||||
phantom.exit();
|
||||
}, 90000);
|
||||
}, timeout);
|
||||
});
|
||||
@@ -21,6 +21,9 @@ function waitFor (ready, callback, timeout, timeoutMessageCallback) {
|
||||
|
||||
function run (test) {
|
||||
var options = JSON.parse(phantom.args);
|
||||
|
||||
var timeout = options.timeout ? Math.round(parseFloat(options.timeout)*1000) : 60000;
|
||||
|
||||
var scheme = options.scheme ? options.scheme+'://' : 'http://';
|
||||
var host = options.host ? options.host : 'localhost';
|
||||
var port = options.port ? ':'+options.port : '';
|
||||
@@ -32,7 +35,7 @@ function run (test) {
|
||||
|
||||
var hashParams = [];
|
||||
if (options.user) hashParams.push('login='+options.user);
|
||||
if (options.admin_password) hashParams.push('password='+options.admin_password);
|
||||
if (options.password) hashParams.push('password='+options.password);
|
||||
if (options.action) hashParams.push('action='+options.action);
|
||||
var hash = hashParams.length > 0 ? '#'+hashParams.join('&') : '';
|
||||
|
||||
@@ -51,14 +54,14 @@ function run (test) {
|
||||
phantom.exit(1);
|
||||
};
|
||||
page.onConsoleMessage = function(message) {
|
||||
// Disabled because of the 'web_hello' addon
|
||||
/* Disabled because of the 'web_hello' addon */
|
||||
//console.log(message);
|
||||
//phantom.exit(1);
|
||||
};
|
||||
|
||||
page.onCallback = function(data) {
|
||||
if (data.event && data.event === 'start') {
|
||||
test(page);
|
||||
test(page, timeout);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user