summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolly Ross <sross@redhat.com>2014-06-03 17:42:28 -0400
committerSolly Ross <sross@redhat.com>2014-06-03 17:42:28 -0400
commit9b731d3a5811cce05001e1d8fbb0d53e2859c86b (patch)
treeb00a0b3e5140eeb23ee50369f4d381d747807dcf
parent93af721a27419e1e8496c267f96ee1f291717781 (diff)
downloadnovnc-9b731d3a5811cce05001e1d8fbb0d53e2859c86b.tar.gz
Fix race condition in test runner
Previously, there would be a case where if your tests took too long to run, the casper test runner would only report on certain tests. This has been fixed.
-rw-r--r--tests/run_from_console.casper.js5
-rwxr-xr-xtests/run_from_console.js2
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/run_from_console.casper.js b/tests/run_from_console.casper.js
index 63b6b20..7cb4b7c 100644
--- a/tests/run_from_console.casper.js
+++ b/tests/run_from_console.casper.js
@@ -26,7 +26,10 @@ var provide_emitter = function(file_paths) {
file_paths.forEach(function(file_path, path_ind) {
spooky.thenOpen('file://'+file_path);
- spooky.then([{ path_ind: path_ind }, function() {
+ spooky.waitFor(function() {
+ return this.getGlobal('__mocha_done') === true;
+ },
+ [{ path_ind: path_ind }, function() {
var res_json = {
file_ind: path_ind
};
diff --git a/tests/run_from_console.js b/tests/run_from_console.js
index 06b4091..84ebd10 100755
--- a/tests/run_from_console.js
+++ b/tests/run_from_console.js
@@ -68,7 +68,7 @@ if (program.autoInject) {
var template = {
header: "<html>\n<head>\n<meta charset='utf-8' />\n<link rel='stylesheet' href='" + path.resolve(__dirname, 'node_modules/mocha/mocha.css') + "'/>\n</head>\n<body><div id='mocha'></div>",
script_tag: function(p) { return "<script src='" + p + "'></script>"; },
- footer: "<script>\nmocha.checkLeaks();\nmocha.globals(['navigator', 'create', 'ClientUtils', '__utils__']);\nmocha.run();\n</script>\n</body>\n</html>"
+ footer: "<script>\nmocha.checkLeaks();\nmocha.globals(['navigator', 'create', 'ClientUtils', '__utils__']);\nmocha.run(function () { window.__mocha_done = true; });\n</script>\n</body>\n</html>"
};
template.header += "\n" + template.script_tag(path.resolve(__dirname, 'node_modules/chai/chai.js'));