[gnome-desktop-testing] Rewrite test launching to use .testmeta files
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop-testing] Rewrite test launching to use .testmeta files
- Date: Thu, 25 Apr 2013 19:27:53 +0000 (UTC)
commit ed967e21209930356814af187b819a95258478d0
Author: Colin Walters <walters verbum org>
Date: Thu Apr 25 15:27:11 2013 -0400
Rewrite test launching to use .testmeta files
Per discussion https://mail.gnome.org/archives/desktop-devel-list/2013-April/msg00257.html
Makefile-tests.am | 10 +-
...n-runner.in => gnome-desktop-testing-runner.in} | 2 +-
src/gnome-desktop-testing-runner.js | 101 ++++++++++++++++++++
src/gnome-desktop-testing.desktop | 6 +
src/gnome-ostree-integration-runner.desktop | 6 -
src/gnome-ostree-integration-runner.js | 74 --------------
6 files changed, 113 insertions(+), 86 deletions(-)
---
diff --git a/Makefile-tests.am b/Makefile-tests.am
index bb3f966..c6f1a68 100644
--- a/Makefile-tests.am
+++ b/Makefile-tests.am
@@ -22,15 +22,15 @@ substitutions= \
-e s,@pkgdatadir\@,$(pkgdatadir), \
$(NULL)
-BUILT_SOURCES += gnome-ostree-integration-runner
+BUILT_SOURCES += gnome-desktop-testing-runner
-gnome-ostree-integration-runner: src/gnome-ostree-integration-runner.in Makefile
+gnome-desktop-testing-runner: src/gnome-desktop-testing-runner.in Makefile
sed $(substitutions) $< > $ tmp && mv $ tmp $@
-bin_PROGRAMS += gnome-ostree-integration-runner
+bin_PROGRAMS += gnome-desktop-testing-runner
pkgjsdir = $(pkgdatadir)/js
-pkgjs_DATA = src/gnome-ostree-integration-runner.js
+pkgjs_DATA = src/gnome-desktop-testing-runner.js
etcxdgautostartdir = $(sysconfdir)/xdg/autostart
-etcxdgautostart_DATA = src/gnome-ostree-integration-runner.desktop
+etcxdgautostart_DATA = src/gnome-desktop-testing.desktop
diff --git a/src/gnome-ostree-integration-runner.in b/src/gnome-desktop-testing-runner.in
similarity index 93%
rename from src/gnome-ostree-integration-runner.in
rename to src/gnome-desktop-testing-runner.in
index 7c73737..eb7c962 100644
--- a/src/gnome-ostree-integration-runner.in
+++ b/src/gnome-desktop-testing-runner.in
@@ -23,4 +23,4 @@ export LD_LIBRARY_PATH="@pkglibdir@/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PKGDATADIR= pkgdatadir@
export PKGLIBDIR= pkglibdir@
-exec gjs -I "${jsdir}" "${jsdir}/gnome-ostree-integration-runner.js" "$@"
+exec gjs -I "${jsdir}" "${jsdir}/gnome-desktop-testing-runner.js" "$@"
diff --git a/src/gnome-desktop-testing-runner.js b/src/gnome-desktop-testing-runner.js
new file mode 100755
index 0000000..131d197
--- /dev/null
+++ b/src/gnome-desktop-testing-runner.js
@@ -0,0 +1,101 @@
+#!/usr/bin/env gjs
+
+// Copyright (C) 2012,2013 Colin Walters <walters verbum org>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+const GSystem = imports.gi.GSystem;
+
+const TEST_SKIP_ECODE = 77;
+const TESTS_FAILED_MSGID = '0eee66bf98514369bef9868327a43cf1';
+const TESTS_SUCCESS_MSGID = '4d013788dd704743b826436c951e551d';
+
+let cancellable = null;
+let dirEnum;
+try {
+ let path = Gio.File.new_for_path('/usr/share/installed-tests');
+ dirEnum = path.enumerate_children('standard::name,standard::type',
+ Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
+ cancellable);
+} catch (e) {
+ if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
+ dirEnum = null;
+ else
+ throw e;
+}
+let info;
+let loop = GLib.MainLoop.new(null, true);
+let ntests = 0;
+let nSkippedTests = 0;
+let testSuccess = true;
+while (dirEnum != null && (info = dirEnum.next_file(cancellable)) != null) {
+ let name = info.get_name();
+ if (name.indexOf('.testmeta') < 0)
+ continue;
+ let child = dirEnum.get_child(info);
+ let childPath = child.get_path();
+
+ let kdata = GLib.KeyFile.new();
+ kdata.load_from_file(childPath, 0);
+ 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);
+ 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 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();
+ }
+ }, null);
+ loop.run();
+ if (!testSuccess) {
+ GSystem.log_structured("Test " + childPath + " failed: " + errmsg,
+ ["MESSAGE_ID=" + TESTS_FAILED_MSGID]);
+ break;
+ }
+ if (!skipped)
+ ntests += 1;
+}
+
+let rval;
+if (testSuccess) {
+ GSystem.log_structured("Ran " + ntests + " tests successfully, " + nSkippedTests + " skipped",
+ ["MESSAGE_ID=" + TESTS_SUCCESS_MSGID]);
+ rval = 0;
+} else {
+ rval = 1;
+}
+rval;
diff --git a/src/gnome-desktop-testing.desktop b/src/gnome-desktop-testing.desktop
new file mode 100644
index 0000000..b309aa4
--- /dev/null
+++ b/src/gnome-desktop-testing.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=GNOME installed tests runner
+Exec=gnome-desktop-testing-runner
+Terminal=false
+Type=Application
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]