Only report mispredictions during tests

pull/449/head
Lennart Kats 2017-07-05 14:42:38 +00:00
rodzic a734df504e
commit 7284374f93
1 zmienionych plików z 10 dodań i 9 usunięć

Wyświetl plik

@ -139,7 +139,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
setTimeout(init); setTimeout(init);
function init() { function init() {
afterPrompt(function() { setTimeout(start); }); afterPrompt(function() { setTimeout(callback); });
// Make sure we have a prompt with a dollar for tests // Make sure we have a prompt with a dollar for tests
// And terminal won't send rename commands in the middle of the test // And terminal won't send rename commands in the middle of the test
// TODO: do we need to handle rename sequence in predict_echo instead? // TODO: do we need to handle rename sequence in predict_echo instead?
@ -150,14 +150,12 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
// editor.ace.onTextInput("ssh ubuntu@ci.c9.io\n"); // editor.ace.onTextInput("ssh ubuntu@ci.c9.io\n");
} }
}); });
function start() { }
predictor.on("mispredict", function(e) {
function reportMispredict(e) {
console.error("MISPREDICTED", e); console.error("MISPREDICTED", e);
delete e.session; delete e.session;
throw new Error("MISPREDICTED: " + JSON.stringify(e)); throw new Error("MISPREDICTED: " + JSON.stringify(e));
});
setTimeout(done);
}
} }
function peek(offset) { function peek(offset) {
@ -213,9 +211,12 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
describe("predict_echo", function() { describe("predict_echo", function() {
beforeEach(function(done) { beforeEach(function(done) {
predictor.off("mispredict", reportMispredict);
afterPredict("*", function() { afterPredict("*", function() {
afterPrompt(function() { afterPrompt(function() {
session.$predictor.state = 0; session.$predictor.state = 0;
predictor.on("mispredict", reportMispredict);
done(); done();
}); });
send("\r"); send("\r");