Skip to content

Commit

Permalink
Fixed runner to handle references (#67)
Browse files Browse the repository at this point in the history
Fix runner to handle references and local changes
  • Loading branch information
halindrome authored and jgraham committed Jun 9, 2016
1 parent 2264642 commit bb5c527
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
1 change: 1 addition & 0 deletions runner/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ <h4 class='panel-title'>Manual Testing</h4>
<p>
<button class="btn btn-info test">Show Test</button>
<button class="btn btn-info ref">Show Reference</button>
<span class="reftestWarn"></span>
</p>
</div>
<div class="panel-footer">
Expand Down
6 changes: 6 additions & 0 deletions runner/runner.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,9 @@ td.ERROR {
animation-iteration-count: infinite;
animation-direction: alternate;
}

.reftestWarn {
color: yellow;
background: black;
padding: 8px;
}
51 changes: 44 additions & 7 deletions runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,39 @@ Manifest.prototype = {
},

by_type:function(type) {
var ret = [] ;
if (this.data.items.hasOwnProperty(type)) {
return this.data.items[type];
} else {
return [];
ret = this.data.items[type].slice(0) ;
}
// local_changes.items in manifest is an Object just as
// items is. However, the properties of local_changes.items
// are Objects and the properties of items are Arrays.
// So we need to extract any relevant local changes by iterating
// over the Object and pulling out the referenced nodes as array items.
if (this.data.hasOwnProperty("local_changes")) {
var local = this.data.local_changes ;
// add in any local items
if (local.items.hasOwnProperty(type)) {
Object.keys(local.items[type]).forEach(function(ref) {
ret.push(local.items[type][ref][0]) ;
}.bind(this));
}
// remove any items that are locally deleted but not yet committed
// note that the deleted and deleted_reftests properties of the local_changes
// object are always present, even if they are empty
if (ret.length && local.deleted.length) {
// make a hash of the deleted to speed searching
var dels = {} ;
local.deleted.forEach(function(x) { dels[x] = true; } );
for (var j = ret.length-1; j >= 0; j--) {
if ( dels[ret[j].path] || (type === "reftest" && local.deleted_reftests[ret[j].path]) ){
// we have a match
ret.splice(j, 1) ;
}
}
}
}
return ret ;
}
};

Expand All @@ -69,7 +97,7 @@ function ManifestIterator(manifest, path, test_types, use_regex) {
this.regex_pattern = path;
} else {
// Split paths by either a comma or whitespace, and ignore empty sub-strings.
this.paths = path.split(/[,\s]+/).filter(function(s) { return s.length > 0 });
this.paths = path.split(/[,\s]+/).filter(function(s) { return s.length > 0; });
}
}

Expand Down Expand Up @@ -116,9 +144,10 @@ ManifestIterator.prototype = {
type: this.test_types[this.test_types_index],
url: manifest_item.url
};
if (manifest_item.hasOwnProperty("ref_url")) {
test.ref_type = manifest_item.ref_type;
test.ref_url = manifest_item.ref_url;
if (manifest_item.hasOwnProperty("references")) {
test.ref_length = manifest_item.references.length;
test.ref_type = manifest_item.references[0][1];
test.ref_url = manifest_item.references[0][0];
}
return test;
},
Expand Down Expand Up @@ -348,6 +377,7 @@ function ManualUI(elem, runner) {
this.fail_button = this.elem.querySelector("button.fail");
this.ref_buttons = this.elem.querySelector(".reftestUI");
this.ref_type = this.ref_buttons.querySelector(".refType");
this.ref_warning = this.elem.querySelector(".reftestWarn");
this.test_button = this.ref_buttons.querySelector("button.test");
this.ref_button = this.ref_buttons.querySelector("button.ref");

Expand Down Expand Up @@ -411,6 +441,13 @@ ManualUI.prototype = {
if (test.type == "reftest") {
this.show_ref();
this.ref_type.textContent = test.ref_type === "==" ? "equal" : "unequal";
if (test.ref_length > 1) {
this.ref_warning.textContent = "WARNING: only presenting first of " + test.ref_length + " references";
this.ref_warning.style.display = "inline";
} else {
this.ref_warning.textContent = "";
this.ref_warning.style.display = "none";
}
} else {
this.hide_ref();
}
Expand Down

0 comments on commit bb5c527

Please sign in to comment.