[Pkg-javascript-commits] [pdf.js] 14/141: Better test process	killing for Windows
    David Prévot 
    taffit at moszumanska.debian.org
       
    Sat Apr 19 22:40:25 UTC 2014
    
    
  
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit d7174582c057c6ee5bcacafaa3d46a738aeacfda
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Wed Apr 2 08:02:40 2014 -0500
    Better test process killing for Windows
---
 test/webbrowser.js | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/test/webbrowser.js b/test/webbrowser.js
index ea7fff8..68bb71e 100644
--- a/test/webbrowser.js
+++ b/test/webbrowser.js
@@ -64,17 +64,30 @@ WebBrowser.prototype = {
   startProcess: function (url) {
     var args = this.buildArguments(url);
     var proc = spawn(this.path, args);
-    proc.on('close', function (code) {
+    proc.on('exit', function (code) {
       this.finished = true;
-      if (this.callback) {
-        this.callback.call(null, code);
-      }
-      this.cleanup();
+      // trying to wait for process to shutdown (for Windows sake)
+      setTimeout(function () {
+        this.cleanup();
+        if (this.callback) {
+          this.callback.call(null, code);
+        }
+      }.bind(this), 500);
     }.bind(this));
     return proc;
   },
   cleanup: function () {
-    testUtils.removeDirSync(this.tmpDir);
+    try {
+      testUtils.removeDirSync(this.tmpDir);
+    } catch (e) {
+      console.error('Unable to cleanup after the process: ' + e);
+      try {
+        if (this.process) {
+          this.process.kill('SIGKILL');
+        }
+      } catch (e) {}
+    }
+    this.process = null;
   },
   stop: function (callback) {
     if (this.finished) {
@@ -85,8 +98,7 @@ WebBrowser.prototype = {
       this.callback = callback;
     }
 
-    this.process.kill();
-    this.process = null;
+    this.process.kill('SIGTERM');
   }
 };
 
-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
    
    
More information about the Pkg-javascript-commits
mailing list