[gjs] Allow running test cases stand-alone.
- From: Johan Bilien <jobi src gnome org>
- To: svn-commits-list gnome org
- Subject: [gjs] Allow running test cases stand-alone.
- Date: Tue, 12 May 2009 11:17:25 -0400 (EDT)
commit b43b84be6742ef6e5c0860999c3950e4e5511a1d
Author: C. Scott Ananian <cscott litl com>
Date: Fri May 1 16:11:41 2009 -0400
Allow running test cases stand-alone.
---
test/js/modules/jsUnit.js | 9 ++++++---
test/js/testEverythingBasic.js | 4 ++++
test/js/testEverythingEncapsulated.js | 4 ++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/test/js/modules/jsUnit.js b/test/js/modules/jsUnit.js
index 2292bf0..e260f22 100644
--- a/test/js/modules/jsUnit.js
+++ b/test/js/modules/jsUnit.js
@@ -449,15 +449,18 @@ function jsUnitSetOnLoad(windowRef, onloadHandler)
// GJS: entry point to run all functions named as test*, surrounded by
// calls to setUp() and tearDown()
-function gjstestRun() {
+function gjstestRun(window_, setUp, tearDown) {
var rv = 0;
var failures = [];
+ if (!window_) window_ = window;
+ if (!setUp) setUp = window_.setUp;
+ if (!tearDown) tearDown = window_.tearDown;
- for (propName in window) {
+ for (propName in window_) {
if (!propName.match(/^test\w+/))
continue;
- var testFunction = window[propName];
+ var testFunction = window_[propName];
if (typeof(testFunction) != 'function')
continue;
diff --git a/test/js/testEverythingBasic.js b/test/js/testEverythingBasic.js
index 261c967..a163222 100644
--- a/test/js/testEverythingBasic.js
+++ b/test/js/testEverythingBasic.js
@@ -1,4 +1,8 @@
const Everything = imports.gi.Everything;
+if (!('assertEquals' in this)) { /* allow running this test standalone */
+ imports.lang.copyPublicProperties(imports.jsUnit, this);
+ gjstestRun = function() { return imports.jsUnit.gjstestRun(window); };
+}
// We use Gio to have some objects that we know exist
const Gio = imports.gi.Gio;
diff --git a/test/js/testEverythingEncapsulated.js b/test/js/testEverythingEncapsulated.js
index 529a2ba..cee76de 100644
--- a/test/js/testEverythingEncapsulated.js
+++ b/test/js/testEverythingEncapsulated.js
@@ -1,4 +1,8 @@
const Everything = imports.gi.Everything;
+if (!('assertEquals' in this)) { /* allow running this test standalone */
+ imports.lang.copyPublicProperties(imports.jsUnit, this);
+ gjstestRun = function() { return imports.jsUnit.gjstestRun(window); };
+}
function testStruct() {
let struct = new Everything.TestStructA();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]