Skip to content

Commit 03f8aae

Browse files
committed
Make the tester accurately report total test count
Even when a subset is selected.
1 parent a2ad87f commit 03f8aae

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

test/driver.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ function runTests(callback) {
4848
}
4949
if (debug.length < 1) {
5050
debug = null;
51-
} else {
52-
if (totalTests > debug.length) {
53-
totalTests = debug.length;
54-
}
5551
}
5652
}
5753
var totalTime = 0;
@@ -67,19 +63,15 @@ function runTests(callback) {
6763
// Remove from array for reporting incorrect tests later
6864
debug.splice(debugIndex, 1);
6965
} else {
70-
var wildcardName = test.name.split("_").shift() + "_*";
66+
var wildcardName = test.name.split("_")[0] + "_*";
7167
debugIndex = indexOf(debug, wildcardName);
7268
if (debugIndex !== -1) {
7369
// Remove from array for reporting incorrect tests later
7470
debug.splice(debugIndex, 1);
7571
debugUsed.push(wildcardName);
7672
} else {
7773
debugIndex = indexOf(debugUsed, wildcardName);
78-
if (debugIndex !== -1) {
79-
totalTests++;
80-
} else {
81-
return step(i + 1);
82-
}
74+
if (debugIndex == -1) return step(i + 1);
8375
}
8476
}
8577
}
@@ -132,3 +124,15 @@ function eqPos(a, b, msg) {
132124
function is(a, msg) {
133125
if (!a) throw new Failure(label("assertion failed", msg));
134126
}
127+
128+
function countTests() {
129+
if (!debug) return tests.length;
130+
var sum = 0;
131+
for (var i = 0; i < tests.length; ++i) {
132+
var name = tests[i].name;
133+
if (indexOf(debug, name) != -1 ||
134+
indexOf(debug, name.split("_")[0] + "_*") != -1)
135+
++sum;
136+
}
137+
return sum;
138+
}

test/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h1>CodeMirror: Test Suite</h1>
107107
bad = "";
108108
verbose = false;
109109
debugUsed = Array();
110-
totalTests = tests.length;
110+
totalTests = countTests();
111111
progressTotal.nodeValue = " of " + totalTests;
112112
progressRan.nodeValue = count;
113113
output.innerHTML = '';
@@ -141,8 +141,6 @@ <h1>CodeMirror: Test Suite</h1>
141141
var message = "???";
142142
if (type != "done") ++count;
143143
progress.style.width = (count * (progress.parentNode.clientWidth - 2) / totalTests) + "px";
144-
progressTotal.nodeValue = " of " + totalTests +
145-
(debugUsed.length && type != "done" ? "+" : "");
146144
progressRan.nodeValue = count;
147145
if (type == "ok") {
148146
message = "Test '" + name + "' succeeded";

0 commit comments

Comments
 (0)