]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Fix race condition in test runner
authorSolly Ross <sross@redhat.com>
Tue, 3 Jun 2014 21:42:28 +0000 (17:42 -0400)
committerSolly Ross <sross@redhat.com>
Tue, 3 Jun 2014 21:42:28 +0000 (17:42 -0400)
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.

tests/run_from_console.casper.js
tests/run_from_console.js

index 63b6b20dc46fa9fcf7c5aab7fc24c506a36c24b1..7cb4b7c5ad057dc75a125a85d7be6b145d406e21 100644 (file)
@@ -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
         };
index 06b40917afea260ef6370a22e16f9f08e05f4058..84ebd10a0e363b8fe7a3f0a840f6dffb3a90f7c6 100755 (executable)
@@ -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'));