[IMP] phantom tests
- phantomjs more verbose - revert to dumber console.log relay, dont try to be smart, just display it - json is only optionally parsed for errors stack dumps bzr revid: al@openerp.com-20140316160634-hh7br4mbg01xcrpk
This commit is contained in:
parent
0772c99bcb
commit
eac5185731
|
@ -212,7 +212,8 @@ class HttpCase(TransactionCase):
|
||||||
# OSError, and no errno/strerror/filename, only a pair of
|
# OSError, and no errno/strerror/filename, only a pair of
|
||||||
# unnamed arguments (matching errno and strerror)
|
# unnamed arguments (matching errno and strerror)
|
||||||
err, _ = e.args
|
err, _ = e.args
|
||||||
if err == errno.EINTR: continue
|
if err == errno.EINTR:
|
||||||
|
continue
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if ready:
|
if ready:
|
||||||
|
@ -224,24 +225,24 @@ class HttpCase(TransactionCase):
|
||||||
# process lines
|
# process lines
|
||||||
if '\n' in buf:
|
if '\n' in buf:
|
||||||
line, buf = buf.split('\n', 1)
|
line, buf = buf.split('\n', 1)
|
||||||
|
|
||||||
line = str(line)
|
line = str(line)
|
||||||
if 'CoreText' in line:
|
|
||||||
continue
|
# relay everything from console.log, even 'ok' or 'error...' lines
|
||||||
|
_logger.debug("phantomjs: %s", line)
|
||||||
|
|
||||||
if line == "ok":
|
if line == "ok":
|
||||||
break
|
break
|
||||||
if line.startswith("error"):
|
if line.startswith("error"):
|
||||||
line_ = line[6:]
|
line_ = self.line[6:]
|
||||||
try: line_ = json.loads(line_)
|
# when error occurs the execution stack may be sent as as JSON
|
||||||
except ValueError: pass
|
try:
|
||||||
|
line_ = json.loads(line_)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
self.fail(line_ or "phantomjs test failed")
|
self.fail(line_ or "phantomjs test failed")
|
||||||
|
|
||||||
try: line = json.loads(line)
|
|
||||||
except ValueError: pass
|
|
||||||
_logger.info("phantomjs: %s", line)
|
|
||||||
|
|
||||||
def phantom_run(self, cmd, timeout):
|
def phantom_run(self, cmd, timeout):
|
||||||
_logger.debug('executing `%s`', ' '.join(cmd))
|
_logger.debug('phantom_run executing %s', ' '.join(cmd))
|
||||||
try:
|
try:
|
||||||
phantom = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
phantom = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -252,6 +253,7 @@ class HttpCase(TransactionCase):
|
||||||
# kill phantomjs if phantom.exit() wasn't called in the test
|
# kill phantomjs if phantom.exit() wasn't called in the test
|
||||||
if phantom.poll() is None:
|
if phantom.poll() is None:
|
||||||
phantom.terminate()
|
phantom.terminate()
|
||||||
|
_logger.debug("phantom_run execution finished")
|
||||||
|
|
||||||
def phantom_jsfile(self, jsfile, timeout=30, **kw):
|
def phantom_jsfile(self, jsfile, timeout=30, **kw):
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -113,20 +113,22 @@ function PhantomTest() {
|
||||||
console.log('loaded', url, status);
|
console.log('loaded', url, status);
|
||||||
// process ready
|
// process ready
|
||||||
waitFor(function() {
|
waitFor(function() {
|
||||||
console.log("waiting for: calling page evaluate");
|
console.log("PhantomTest.run: wait for condition: " + ready);
|
||||||
return self.page.evaluate(function (ready) {
|
return self.page.evaluate(function (ready) {
|
||||||
console.log("waiting for", ready);
|
|
||||||
var r = false;
|
var r = false;
|
||||||
try {
|
try {
|
||||||
console.log("waiting for: page evaluating ", ready);
|
console.log("page.evaluate eval expr:", ready);
|
||||||
r = !!eval(ready);
|
r = !!eval(ready);
|
||||||
} catch(ex) { }
|
} catch(ex) {
|
||||||
console.log("waiting for: returning from page evaluate");
|
}
|
||||||
|
console.log("page.evaluate eval result:", r);
|
||||||
return r;
|
return r;
|
||||||
}, ready);
|
}, ready);
|
||||||
// run test
|
// run test
|
||||||
}, function() {
|
}, function() {
|
||||||
|
console.log("PhantomTest.run: condition statified, executing: " + code);
|
||||||
self.page.evaluate(function (code) { return eval(code); }, code);
|
self.page.evaluate(function (code) { return eval(code); }, code);
|
||||||
|
console.log("PhantomTest.run: execution launched, waiting for console.log('ok')...");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue