Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fail CDP commands on unhandled exceptions #9639

Merged
merged 3 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bots/naughty/debian-stable/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/debian-testing/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/fedora-27/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/fedora-28/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/rhel-7/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/rhel-x/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/ubuntu-1604/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 1 addition & 2 deletions bots/naughty/ubuntu-stable/9641-xtermjs-dimensions-crash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Traceback (most recent call last):
File "test/verify/check-machines", line *, in testSerialConsole
b.wait_not_present("div.terminal canvas.xterm-text-layer")
*
Error: timeout
RuntimeError: TypeError: Cannot read property 'dimensions' of undefined
3 changes: 2 additions & 1 deletion pkg/storaged/optional-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export class OptionalPanel extends React.Component {
self.setState({ just_installed: "just-installed" });
window.setTimeout(() => { self.setState({ just_installed: "just-installed faded" }); },
4000);
});
},
() => null /* ignore cancel */);
}

var heading_right = null;
Expand Down
38 changes: 36 additions & 2 deletions test/common/cdp-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ function fatal() {
}

function fail(err) {
if (typeof err === 'undefined')
err = null;
process.stdout.write(JSON.stringify({"error": err}) + '\n');
}

function success(result) {
process.stdout.write(JSON.stringify({"result": result === undefined ? null : result}) + '\n');
if (typeof result === 'undefined')
result = null;
process.stdout.write(JSON.stringify({"result": result}) + '\n');
}

/**
Expand All @@ -61,6 +65,7 @@ function success(result) {
var messages = [];
var logPromiseResolver;
var nReportedLogMessages = 0;
var unhandledExceptions = [];

function setupLogging(client) {
client.Runtime.enable();
Expand All @@ -72,6 +77,23 @@ function setupLogging(client) {
resolveLogPromise();
});

client.Runtime.exceptionThrown(info => {
let details = info.exceptionDetails;
// don't log test timeouts, they already get handled
if (details.exception && details.exception.className === "PhWaitCondTimeout")
return;

process.stderr.write(details.description || JSON.stringify(details) + "\n");

// ignore c3 crashes (https://github.com/c3js/c3/issues/2187)
if (details.exception && details.exception.description &&
details.exception.description.indexOf("TypeError: Cannot read property 'data_types' of null") >= 0 &&
details.exception.description.indexOf("/kubernetes.js") >= 0)
return;

unhandledExceptions.push(details)
});

client.Log.enable();
client.Log.entryAdded(entry => {
let msg = entry["entry"];
Expand Down Expand Up @@ -288,7 +310,19 @@ CDP.New(options)
pageLoadPromise = new Promise((resolve, reject) => { pageLoadResolve = resolve; pageLoadReject = reject; });

// run the command
eval(command).then(success, fail);
eval(command).then(reply => {
if (unhandledExceptions.length === 0) {
success(reply);
} else {
let details = unhandledExceptions[0];
let message = details.exception.message ||
details.exception.description ||
details.exception.value ||
JSON.stringify(details.exception);
fail(message.split("\n")[0]);
unhandledExceptions.length = 0;
}
}, fail);

input_buf = input_buf.slice(i+1);
}
Expand Down
8 changes: 7 additions & 1 deletion test/common/test-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ function ph_focus(sel)
ph_find(sel).focus();
}

class PhWaitCondTimeout extends Error {
constructor() {
super("condition did not become true");
}
}

function ph_wait_cond(cond, timeout) {
return new Promise((resolve, reject) => {
// poll every 100 ms for now; FIXME: poll less often and re-check on mutations using
Expand All @@ -192,7 +198,7 @@ function ph_wait_cond(cond, timeout) {
let tm = window.setTimeout( () => {
if (stepTimer)
window.clearTimeout(stepTimer);
reject("condition did not become true");
reject(new PhWaitCondTimeout());
}, timeout);
function step() {
try {
Expand Down