xultestrunner 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -1,7 +1,7 @@
1
1
  [App]
2
2
  Name=XULTestRunner
3
- Version=0.3.0
4
- BuildID=aac9a8db-3c4c-43a3-84a8-cb1979f87657
3
+ Version=0.4.0
4
+ BuildID=7724d840-1a29-4939-a796-ad00546a110e
5
5
  ID=XULTestRunner@conflagrationjs.org
6
6
  Vendor=Conflagration JS
7
7
 
@@ -1 +1 @@
1
- content xultestrunner file:content/
1
+ content xultestrunner content/
@@ -0,0 +1,110 @@
1
+ XPCOMCore({scope: this});
2
+
3
+ function XULTestRunner(argv, outputWindow) {
4
+ this.options = {};
5
+ this.argv = argv.concat([]);
6
+ this.outputWindow = outputWindow;
7
+ // FIXME - CurWorkD is busted because we get called from LaunchServices on a Mac, I guess.
8
+ // so use whatever ENV['PWD'] happens to be instead.
9
+ this.curDir = new XPCBuiltins.nsILocalFile($ENV.get('PWD'));
10
+ }
11
+
12
+ // TODO - add real at exit hooks into XPCOMCore
13
+ XULTestRunner.atExit = function() {};
14
+
15
+ // TODO - add some kind of optionparser class to
16
+ // XPCOMCore and also figure out why I'm getting
17
+ // -foreground in argv.
18
+ // TODO - when XPCOMCore gets a Shell object, just
19
+ // use glob and allow for specifying a test pattern
20
+ // rather than a test file or a test dir
21
+ // TODO - also this falls all over itself when handling
22
+ // absolute vs. relative paths. wee.
23
+ XULTestRunner.prototype = {
24
+ testFileMatcher: /_test\.js$/,
25
+
26
+ run: function() {
27
+ this._parseArgv();
28
+ this._loadTests();
29
+ },
30
+
31
+ _loadTests: function() {
32
+ this._checkOptions();
33
+ this._addLibs();
34
+ this._requireTests();
35
+ },
36
+
37
+ _addLibs: function() {
38
+ if (!this.options.testLibs) { return true; }
39
+ var libDir = this.curDir.clone();
40
+ libDir.QueryInterface($Ci.nsILocalFile);
41
+ libDir.appendRelativePath(this.options.testLibs);
42
+ $LOAD_PATH.push(libDir.path);
43
+ },
44
+
45
+ _requireTests: function() {
46
+ var testFiles = this._collectTestFiles();
47
+ puts("Requiring tests: " + testFiles);
48
+ testFiles.forEach(function(filePath) {
49
+ load(filePath);
50
+ });
51
+ XULTestRunner.atExit();
52
+ },
53
+
54
+ _collectTestFiles: function() {
55
+ if (this.options.testFile) {
56
+ var testFile = this.curDir.clone();
57
+ testFile.QueryInterface($Ci.nsILocalFile);
58
+ testFile.appendRelativePath(this.options.testFile);
59
+ return [testFile];
60
+ } else {
61
+ var rootDir = this.curDir.clone();
62
+ rootDir.QueryInterface($Ci.nsILocalFile);
63
+ rootDir.appendRelativePath(this.options.testDir);
64
+ return this._findTestsFromDir(rootDir);
65
+ }
66
+ },
67
+
68
+ _findTestsFromDir: function(rootDir) {
69
+ var testFiles = [];
70
+ var entries = rootDir.directoryEntries;
71
+ while (entries.hasMoreElements()) {
72
+ var entry = entries.getNext().QueryInterface($Ci.nsIFile);
73
+ if (entry.isDirectory()) {
74
+ testFiles = testFiles.concat(this._findTestsFromDir(entry));
75
+ } else if (this.testFileMatcher.test(entry.path)) {
76
+ testFiles.push(entry.path);
77
+ }
78
+ }
79
+ return testFiles;
80
+ },
81
+
82
+ _checkOptions: function() {
83
+ if (this.options.testDir && this.options.testFile) {
84
+ throw("Only one of -testDir or -testFile may be specified.");
85
+ } else if (!this.options.testDir && !this.options.testFile) {
86
+ throw("-testDir or -testFile must be specified.");
87
+ }
88
+ },
89
+
90
+ // TODO - refactor this shitty while/switch loop
91
+ _parseArgv: function() {
92
+ var arg = null;
93
+ while (arg = this.argv.shift()) {
94
+ switch (arg)
95
+ {
96
+ case "-testDir":
97
+ this.options.testDir = this.argv.shift();
98
+ break;
99
+ case "-testFile":
100
+ this.options.testFile = this.argv.shift();
101
+ break;
102
+ case "-testLibs":
103
+ this.options.testLibs = this.argv.shift();
104
+ break;
105
+ default:
106
+ puts("Got unknown argument: " + arg);
107
+ }
108
+ } // while
109
+ }
110
+ }
@@ -1,6 +1,18 @@
1
1
  <?xml version="1.0"?>
2
2
  <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
3
3
 
4
- <window id="main" title="My App" width="300" height="300" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
5
- <caption label="Hello World from Xultestrunner"/>
4
+ <window id="main" title="XUL Test Runner" width="800" height="600" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
5
+ <script type="text/javascript" src="../scripts/xul_test_runner.js" />
6
+ <script type="text/javascript">
7
+ try {
8
+ var testRunner = new XULTestRunner($ARGV, this);
9
+ testRunner.run();
10
+ } catch (e) {
11
+ puts("Got an exception while running tests: " + e);
12
+ }
13
+
14
+ // TODO - move some of this into XPCOMCore
15
+ var appStartup = $Cc["@mozilla.org/toolkit/app-startup;1"].getService($Ci.nsIAppStartup);
16
+ appStartup.quit($Ci.nsIAppStartup.eForceQuit);
17
+ </script>
6
18
  </window>
@@ -1,5 +1,5 @@
1
1
  pref("toolkit.defaultChromeURI", "chrome://xultestrunner/content/xul/main_window.xul");
2
- pref("toolkit.defaultChromeFeatures", "chrome,menubar,resizable");
2
+ pref("toolkit.defaultChromeFeatures", "chrome,menubar,status,resizable");
3
3
  pref("javascript.options.showInConsole", true);
4
4
  // TODO - only disable caching in development mode.
5
5
  pref("nglayout.debug.disable_xul_cache", true);
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>English</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>stub_runner</string>
9
+ <key>CFBundleGetInfoString</key>
10
+ <string>XULTestRunner 0.4.0 © 2009 Conflagration JS</string>
11
+ <key>CFBundleIconFile</key>
12
+ <string>xultestrunner</string>
13
+ <key>CFBundleIdentifier</key>
14
+ <string>org.conflagrationjs.xultestrunner</string>
15
+ <key>CFBundleInfoDictionaryVersion</key>
16
+ <string>6.0</string>
17
+ <key>CFBundleName</key>
18
+ <string>XULTestRunner</string>
19
+ <key>CFBundlePackageType</key>
20
+ <string>APPL</string>
21
+ <key>CFBundleShortVersionString</key>
22
+ <string>0.4.0</string>
23
+ <key>CFBundleSignature</key>
24
+ <string>XPCC</string>
25
+ <key>CFBundleVersion</key>
26
+ <string>0.4.0</string>
27
+ <key>CGDisableCoalescedUpdates</key>
28
+ <true/>
29
+ <key>NSAppleScriptEnabled</key>
30
+ <true/>
31
+ </dict>
32
+ </plist>
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xultestrunner}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gabriel Gironda"]
12
- s.date = %q{2009-10-11}
12
+ s.date = %q{2009-10-18}
13
13
  s.default_executable = %q{xultest}
14
14
  s.description = %q{XUL based test runner for running your JS unit tests.}
15
15
  s.email = %q{contact@gironda.org}
@@ -31,9 +31,16 @@ Gem::Specification.new do |s|
31
31
  "test/xultestrunner_test.rb",
32
32
  "xpcomcore/app/application.ini",
33
33
  "xpcomcore/app/chrome/chrome.manifest",
34
+ "xpcomcore/app/chrome/content/scripts/xul_test_runner.js",
34
35
  "xpcomcore/app/chrome/content/xul/main_window.xul",
36
+ "xpcomcore/app/chrome/icons/default/default.png",
35
37
  "xpcomcore/app/components/bootstrapper.js",
36
38
  "xpcomcore/app/defaults/preferences/prefs.js",
39
+ "xpcomcore/stub_runners/XULTestRunner.app/Contents/Info.plist",
40
+ "xpcomcore/stub_runners/XULTestRunner.app/Contents/MacOS/stub_runner",
41
+ "xpcomcore/stub_runners/XULTestRunner.app/Contents/PkgInfo",
42
+ "xpcomcore/stub_runners/XULTestRunner.app/Contents/Resources/.gitignore",
43
+ "xpcomcore/stub_runners/XULTestRunner.app/Contents/Resources/xultestrunner.icns",
37
44
  "xultestrunner.gemspec"
38
45
  ]
39
46
  s.homepage = %q{http://github.com/gabrielg/xultestrunner}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xultestrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Gironda
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-11 00:00:00 -05:00
12
+ date: 2009-10-18 00:00:00 -05:00
13
13
  default_executable: xultest
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -44,9 +44,16 @@ files:
44
44
  - test/xultestrunner_test.rb
45
45
  - xpcomcore/app/application.ini
46
46
  - xpcomcore/app/chrome/chrome.manifest
47
+ - xpcomcore/app/chrome/content/scripts/xul_test_runner.js
47
48
  - xpcomcore/app/chrome/content/xul/main_window.xul
49
+ - xpcomcore/app/chrome/icons/default/default.png
48
50
  - xpcomcore/app/components/bootstrapper.js
49
51
  - xpcomcore/app/defaults/preferences/prefs.js
52
+ - xpcomcore/stub_runners/XULTestRunner.app/Contents/Info.plist
53
+ - xpcomcore/stub_runners/XULTestRunner.app/Contents/MacOS/stub_runner
54
+ - xpcomcore/stub_runners/XULTestRunner.app/Contents/PkgInfo
55
+ - xpcomcore/stub_runners/XULTestRunner.app/Contents/Resources/.gitignore
56
+ - xpcomcore/stub_runners/XULTestRunner.app/Contents/Resources/xultestrunner.icns
50
57
  - xultestrunner.gemspec
51
58
  has_rdoc: true
52
59
  homepage: http://github.com/gabrielg/xultestrunner