Improve debuggability

pull/449/head
Lennart Kats 2017-07-05 14:41:01 +00:00
rodzic 726a40fb87
commit bfd5aa7f44
2 zmienionych plików z 23 dodań i 15 usunięć

Wyświetl plik

@ -160,6 +160,9 @@ define(function(require, exports, module) {
+ "%c" + predictLine, + "%c" + predictLine,
"color: lightblue"); "color: lightblue");
// DEBUG && console.log("!="
// + session.terminal.$debugCharsAt(predictStartY - session.terminal.ybase).join(""));
command.timeout = setTimeout(function panic() { command.timeout = setTimeout(function panic() {
if (!c9.has(c9.NETWORK) || !c9.connected) { if (!c9.has(c9.NETWORK) || !c9.connected) {
state = STATE_WAIT_FOR_ECHO; state = STATE_WAIT_FOR_ECHO;
@ -219,13 +222,17 @@ define(function(require, exports, module) {
pong(); pong();
var result; chopPredictions(e, predictions, function(err, results, line) {
chopPredictions(e, predictions, function(err, _result) { if (err || !results) {
result = _result; DEBUG && console.log("[predict_echo] mispredict?", e.data.replace(/\r/g, "\\r")
if (err || !result) { + "\n!=" + session.terminal.$debugCharsAt(predictStartY - session.terminal.ybase).join("")
DEBUG && console.log("[predict_echo] mispredict?", e.data.replace(/\r/g, "\\r"), + "\n<=" + nonPredictTerminal.$debugCharsAt(e.$startY).join(""));
"\n@", nonPredictTerminal.$debugCharsAt(e.$startY).join("")); emit("mispredict", {
emit("mispredict", { data: e.data, predictions: predictions, session: session }); data: e.data,
line: charsOf(line),
predictions: predictions,
session: session
});
undoPredictions(); undoPredictions();
} }
// I would try to enable predictions here, // I would try to enable predictions here,
@ -244,7 +251,7 @@ define(function(require, exports, module) {
/** /**
* Temporarily restore the unpredict terminal state to allow * Temporarily restore the unpredict terminal state to allow
* writing incoming data, including small anomalies that may * writing incoming data, including small anomalies that may
* not have been predict but still passed our sanity checks. * not have been predicted but still passed our sanity checks.
*/ */
function writePredictData(data, startX) { function writePredictData(data, startX) {
var predictTerminal = session.terminal; var predictTerminal = session.terminal;

Wyświetl plik

@ -376,8 +376,8 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
afterPredict("[", function() { afterPredict("[", function() {
afterPredict("[", function() { afterPredict("[", function() {
assert.equal(peek(-1), " "); assert.equal(peek(-1), " ");
assert.equal(peek(), "e"); assert.equal(peek(), "#");
assert.equal(peek(1), "c"); assert.equal(peek(1), "p");
afterPrompt(done); afterPrompt(done);
send("\r"); send("\r");
@ -387,16 +387,16 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
sendAll([INPUT_RIGHT]); sendAll([INPUT_RIGHT]);
}); });
sendAll(["eecho bleep", INPUT_HOME]); sendAll(["##print some chars; home; right; backspace", INPUT_HOME]);
}); });
it("supports insert with repeated characters; stress test", function loop(done, attempt) { it("supports insert with repeated characters (prxaat); stress test", function loop(done, attempt) {
this.timeout && this.timeout(60000); this.timeout && this.timeout(60000);
session.$predictor.state = 0; session.$predictor.state = 0;
if (attempt === 5) if (attempt === 5)
return done(); return done();
sendAll("echo blaat".split(""), function() { sendAll("echo praat".split(""), function() {
var sawX; var sawX;
afterPredict("t", function() { afterPredict("t", function() {
@ -405,8 +405,9 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
}); });
predictor.on("predict", function wait(e) { predictor.on("predict", function wait(e) {
sawX = sawX || e.data.match(/x/); sawX = sawX || e.data.match(/x/);
if (!sawX || e.data.match(/xaat/) || !e.data.match(/a/)) // Wait until we've seen an 'x' and then an 'a'
return; // console.log(" -", e.data, sawX)* if (!sawX || e.data.match(/xaat$/))
return console.log(" -", e.data, !!sawX);
predictor.off("predict", wait); predictor.off("predict", wait);
assert.equal(peek(), "a"); assert.equal(peek(), "a");