From f4bf550bf69514895a1eac99f81bedd2ec496d86 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 3 Nov 2015 19:02:03 +0400 Subject: [PATCH] fix flaky predict_echo_test --- plugins/c9.ide.terminal/predict_echo_test.js | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/plugins/c9.ide.terminal/predict_echo_test.js b/plugins/c9.ide.terminal/predict_echo_test.js index 335d84f7..80be08fe 100644 --- a/plugins/c9.ide.terminal/predict_echo_test.js +++ b/plugins/c9.ide.terminal/predict_echo_test.js @@ -100,12 +100,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse return tab.pane.aml.getPage("editor::" + tab.editorType).$ext; }); - predictor.on("mispredict", function(e) { - console.error("MISPREDICTED", e) - delete e.session; - throw new Error("MISPREDICTED: " + JSON.stringify(e)); - }); - describe('terminal.predict_echo', function() { this.timeout(30000); @@ -145,13 +139,25 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse afterPrompt(function() { setTimeout(init); }); function init() { + afterPrompt(function() { setTimeout(start); }); // Make sure we have a prompt with a dollar for tests - afterPrompt(function() { done() }); - editor.ace.onTextInput("PS1='. $ '\n"); - //editor.ace.onTextInput("ssh lennart\n"); - //editor.ace.onTextInput("ssh ubuntu@ci.c9.io\n"); + // 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? + editor.ace.onTextInput("PS1='. $ ';" + + "tmux setw automatic-rename off;" + + "printf '\\x1b]0;predict echo\\x07'\n"); + // editor.ace.onTextInput("ssh lennart\n"); + // editor.ace.onTextInput("ssh ubuntu@ci.c9.io\n"); } }); + function start() { + predictor.on("mispredict", function(e) { + console.error("MISPREDICTED", e) + delete e.session; + throw new Error("MISPREDICTED: " + JSON.stringify(e)); + }); + setTimeout(done) + } } function peek(offset) { @@ -528,7 +534,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse afterPredict(":", function() { afterPrompt(done); send("\r"); - }) + }); sendAll("echo".split(""), function() { send(INPUT_BACKSPACE); send(INPUT_BACKSPACE);