[ostree/wip/libsysroot: 2/9] tests: Add a simple test-sysroot.js that covers OSTree.Sysroot
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree/wip/libsysroot: 2/9] tests: Add a simple test-sysroot.js that covers OSTree.Sysroot
- Date: Thu, 3 Oct 2013 23:24:37 +0000 (UTC)
commit 650aab7628168e2a08b5342ff274ea62fac40490
Author: Colin Walters <walters verbum org>
Date: Wed Oct 2 19:47:38 2013 -0400
tests: Add a simple test-sysroot.js that covers OSTree.Sysroot
This will be more interesting as a test case user of the API.
Makefile-tests.am | 9 ++++---
tests/test-sysroot.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 4 deletions(-)
---
diff --git a/Makefile-tests.am b/Makefile-tests.am
index c012141..bfc84e4 100644
--- a/Makefile-tests.am
+++ b/Makefile-tests.am
@@ -57,7 +57,7 @@ gpginsttest_DATA = tests/gpghome/secring.gpg \
%.test: tests/%.js Makefile
$(AM_V_GEN) (echo '[Test]' > $ tmp; \
- echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $ tmp; \
+ echo 'Exec=env TESTDATADIR=$(pkglibexecdir)/installed-tests
$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $ tmp; \
echo 'Type=session' >> $ tmp; \
mv $ tmp $@)
@@ -65,9 +65,10 @@ testmetadir = $(datadir)/installed-tests/$(PACKAGE)
testmeta_DATA = $(testfiles:=.test)
if BUILDOPT_GJS
-insttest_SCRIPTS += tests/test-core.js
-testmeta_DATA += test-core.test
+insttest_SCRIPTS += tests/test-core.js \
+ tests/test-sysroot.js \
+ $(NULL)
+testmeta_DATA += test-core.test test-sysroot.test
endif
-
endif
diff --git a/tests/test-sysroot.js b/tests/test-sysroot.js
new file mode 100644
index 0000000..ef1f26b
--- /dev/null
+++ b/tests/test-sysroot.js
@@ -0,0 +1,53 @@
+#!/usr/bin/env gjs
+//
+// Copyright (C) 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 OSTree = imports.gi.OSTree;
+
+function assertEquals(a, b) {
+ if (a != b)
+ throw new Error("assertion failed " + JSON.stringify(a) + " == " + JSON.stringify(b));
+}
+
+function libtestExec(shellCode) {
+ let testdatadir = GLib.getenv("TESTDATADIR");
+ let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh'])
+ let cmdline = 'bash -c ' + GLib.shell_quote('. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode);
+ print("shellcode=" +cmdline);
+ let [,stdout,stderr,estatus] = GLib.spawn_command_line_sync(cmdline);
+ print(stderr);
+ GLib.spawn_check_exit_status(estatus);
+}
+
+libtestExec('setup_os_repository archive-z2 syslinux');
+
+let upstreamRepo = OSTree.Repo.new(Gio.File.new_for_path('testos-repo'));
+upstreamRepo.open(null);
+
+let [,rev] = upstreamRepo.resolve_rev('testos/buildmaster/x86_64-runtime', false);
+
+print("testos => " + rev);
+
+let sysroot = OSTree.Sysroot.new(Gio.File.new_for_path('sysroot'));
+sysroot.load(null);
+let deployments = sysroot.get_deployments();
+assertEquals(deployments.length, 0);
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]