Quick change to the license.
[jquery.git] / build / js / lib / Test / Harness / Director.js
1 // # $Id: Kinetic.pm 1493 2005-04-07 19:20:18Z theory $
2
3 Test.Harness.Director = function () {};
4 Test.Harness.Director.VERSION = '0.11';
5
6 Test.Harness.Director.runTests = function () {
7     var harness = new Test.Harness.Director();
8     harness.runTests.apply(harness, arguments);
9 };
10
11 Test.Harness.Director.prototype = new Test.Harness();
12 Test.Harness.Director.prototype.verbose = true;
13 Test.Harness.Director.prototype.args = {};
14
15 Test.Harness.Director.prototype.runTests = function (x_aFunctionNames) {
16     // Allow for an array or a simple list in arguments.
17     // XXX args.file isn't quite right since it's more function names, but
18     // that is still to be ironed out.
19     var functionNames = this.args.file
20       ? typeof this.args.file == 'string' ? [this.args.file] : this.args.file
21       : arguments;
22     if (!x_aFunctionNames.length) return;
23     var outfunctions = this.outFileNames(x_aFunctionNames);
24     var harness = this;
25     var start = new Date();
26     var newLineRx = /(?:\r?\n|\r)+$/;
27     var output = function (msg) { trace(msg.replace(newLineRx, '')) };
28
29     for (var x = 0; x < x_aFunctionNames.length; x++){
30         output(outfunctions[x]);
31         eval(x_aFunctionNames[x] + "()");
32         harness.outputResults(
33             Test.Builder.Test,
34             x_aFunctionNames[x],
35             output,
36             harness.args
37         );
38     }
39     harness.outputSummary(
40         output,
41         new Date() - start
42     );
43 };
44
45 Test.Harness.Director.prototype.formatFailures = function (fn) {
46     // XXX Delete once the all-text version is implemented in Test.Harness.
47     var failedStr = "Failed Test";
48     var middleStr = " Total Fail  Failed  ";
49     var listStr = "List of Failed";
50     var table = '<table style=""><tr><th>Failed Test</th><th>Total</th>'
51       + '<th>Fail</th><th>Failed</th></tr>';
52     for (var i = 0; i < this.failures.length; i++) {
53         var track = this.failures[i];
54         table += '<tr><td>' + track.fn + '</td>'
55           + '<td>' + track.total + '</td>'
56           + '<td>' + track.total - track.ok + '</td>'
57           + '<td>' + this._failList(track.failList) + '</td></tr>'
58     };
59     table += '</table>';
60     output(table);
61 };