Skip to content

Commit

Permalink
Add test count (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
halindrome authored and jgraham committed Jul 20, 2016
1 parent d304b43 commit 157ef0a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runner/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label">Count of matching tests</label>
<div class="col-sm-9" id="testcount">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-success toggleStart" disabled>Start</button>
Expand Down
30 changes: 30 additions & 0 deletions runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,22 +461,35 @@ ManualUI.prototype = {
function TestControl(elem, runner) {
this.elem = elem;
this.path_input = this.elem.querySelector(".path");
this.path_input.addEventListener("change", function() {
this.set_counts();
}.bind(this), false);
this.use_regex_input = this.elem.querySelector("#use_regex");
this.use_regex_input.addEventListener("change", function() {
this.set_counts();
}.bind(this), false);
this.pause_button = this.elem.querySelector("button.togglePause");
this.start_button = this.elem.querySelector("button.toggleStart");
this.type_checkboxes = Array.prototype.slice.call(
this.elem.querySelectorAll("input[type=checkbox].test-type"));
this.type_checkboxes.forEach(function(elem) {
elem.addEventListener("change", function() {
this.set_counts();
}.bind(this),
false);
elem.addEventListener("click", function() {
this.start_button.disabled = this.get_test_types().length < 1;
}.bind(this),
false);
}.bind(this));

this.timeout_input = this.elem.querySelector(".timeout_multiplier");
this.render_checkbox = this.elem.querySelector(".render");
this.testcount_area = this.elem.querySelector("#testcount");
this.runner = runner;
this.runner.done_callbacks.push(this.on_done.bind(this));
this.set_start();
this.set_counts();
}

TestControl.prototype = {
Expand Down Expand Up @@ -530,6 +543,21 @@ TestControl.prototype = {

},

set_counts: function() {
if (this.runner.manifest_loading) {
setTimeout(function() {
this.set_counts();
}.bind(this), 1000);
return;
}
var path = this.get_path();
var test_types = this.get_test_types();
var use_regex = this.get_use_regex();
var iterator = new ManifestIterator(this.runner.manifest, path, test_types, use_regex);
var count = iterator.count();
this.testcount_area.textContent = count;
},

get_path: function() {
return this.path_input.value;
},
Expand Down Expand Up @@ -622,6 +650,7 @@ function Runner(manifest_path) {
this.results = new Results(this);

this.start_after_manifest_load = false;
this.manifest_loading = true;
this.manifest.load(this.manifest_loaded.bind(this));
}

Expand All @@ -637,6 +666,7 @@ Runner.prototype = {
},

manifest_loaded: function() {
this.manifest_loading = false;
if (this.start_after_manifest_load) {
this.do_start();
}
Expand Down

0 comments on commit 157ef0a

Please sign in to comment.