[gnome-desktop-testing/wip/manual: 5/5] Use GSubprocess for forking off test processes



commit fdb87a47895c7c942f794a7bd71a39dd5b7c3342
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 25 20:08:49 2013 -0400

    Use GSubprocess for forking off test processes

 src/gnome-desktop-testing-runner.js |   41 ++++++++++++++++------------------
 1 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/src/gnome-desktop-testing-runner.js b/src/gnome-desktop-testing-runner.js
index 8fcd4a6..a85eeba 100755
--- a/src/gnome-desktop-testing-runner.js
+++ b/src/gnome-desktop-testing-runner.js
@@ -43,7 +43,6 @@ function runTestsInDirectory(file) {
            throw e;
     }
     let info;
-    let loop = GLib.MainLoop.new(null, true);
     let testSuccess = true;
     while (dirEnum != null && (info = dirEnum.next_file(cancellable)) != null) {
         let name = info.get_name();
@@ -57,32 +56,30 @@ function runTestsInDirectory(file) {
         let execKey = kdata.get_string('Test', 'Exec');
         if (!execKey)
            throw new Error("Missing Exec key in " + childPath);
-        let [success, testArgv] = GLib.shell_parse_argv(execKey);
+        let [, testArgv] = GLib.shell_parse_argv(execKey);
         print("Running test: " + childPath);
 
-        let pid;
-        [success,pid] = GLib.spawn_async(null, testArgv, null,
-                                        GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.SEARCH_PATH, 
null);
+        let proc = GSystem.Subprocess.new_simple_argv(testArgv,
+                                                      GSystem.SubprocessStreamDisposition.INHERIT,
+                                                      GSystem.SubprocessStreamDisposition.INHERIT,
+                                                      cancellable);
+        let [, estatus] = proc.wait_sync(cancellable);
         let errmsg = null;
         let skipped = false;
-        GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function(pid, estatus) {
-           try {
-               GLib.spawn_check_exit_status(estatus);
-           } catch (e) {
-               if (e.domain == GLib.spawn_exit_error_quark() &&
-                   e.code == TEST_SKIP_ECODE) {
-                   print("Skipping test " + childPath);
-                   nSkippedTests++;
-                   skipped = true;
-               } else {
-                   errmsg = e.message;
-                   testSuccess = false;
-               }
-           } finally {
-               loop.quit();
+       try {
+           GLib.spawn_check_exit_status(estatus);
+       } catch (e) {
+           if (e.domain == GLib.spawn_exit_error_quark() &&
+               e.code == TEST_SKIP_ECODE) {
+               print("Skipping test " + childPath);
+               nSkippedTests++;
+               skipped = true;
+           } else {
+               errmsg = e.message;
+               testSuccess = false;
            }
-        }, null);
-        loop.run();
+        }
+
         if (!testSuccess) {
            GSystem.log_structured("Test " + childPath + " failed: " + errmsg,
                                    ["MESSAGE_ID=" + TESTS_FAILED_MSGID]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]