[IMP] tests: group phantomjs the log to have one python log by javascript log

This commit is contained in:
Christophe Matthieu
2015-07-10 17:00:16 +02:00
parent 175d42c978
commit c811ba8345
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -297,8 +297,12 @@ class HttpCase(TransactionCase):
buf.append(s)
# process lines
if '\n' in buf:
line, buf = buf.split('\n', 1)
if '\n' in buf and (not buf.startswith('<phantomLog>') or '</phantomLog>' in buf):
if buf.startswith('<phantomLog>'):
line = buf[12:buf.index('</phantomLog>')]
buf = bytearray()
else:
line, buf = buf.split('\n', 1)
line = str(line)
# relay everything from console.log, even 'ok' or 'error...' lines
+2 -2
View File
@@ -57,7 +57,7 @@ function PhantomTest() {
phantom.exit(1);
};
this.page.onConsoleMessage = function(message) {
console.log(message);
console.log('<phantomLog>'+message+'</phantomLog>');
};
this.page.onLoadFinished = function(status) {
if (status === "success") {
@@ -92,7 +92,7 @@ function PhantomTest() {
var message = ("Timeout\nhref: " + window.location.href +
"\nreferrer: " + document.referrer +
"\n\n" + (document.body && document.body.innerHTML)).replace(/[^a-z0-9\s~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "*");
console.log('error', message);
console.log('<phantomLog>error ' + message + '</phantomLog>');
phantom.exit(1);
});
}, self.timeout);