Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query search order check #50302

Merged
merged 1 commit into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/test/rustdoc-js/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-order

const QUERY = '[';

const EXPECTED = {
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-js/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const QUERY = 'String';
const EXPECTED = {
'others': [
{ 'path': 'std::string', 'name': 'String' },
{ 'path': 'std::ffi', 'name': 'OsString' },
{ 'path': 'std::ffi', 'name': 'CString' },
{ 'path': 'std::ffi', 'name': 'OsString' },
],
'in_args': [
{ 'path': 'std::str', 'name': 'eq' },
Expand Down
18 changes: 12 additions & 6 deletions src/tools/rustdoc-js/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function loadContent(content) {
var Module = module.constructor;
var m = new Module();
m._compile(content, "tmp.js");
m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1;
return m.exports;
}

Expand Down Expand Up @@ -130,10 +131,10 @@ function lookForEntry(entry, data) {
}
}
if (allGood === true) {
return true;
return i;
}
}
return false;
return null;
}

function main(argv) {
Expand Down Expand Up @@ -177,6 +178,7 @@ function main(argv) {
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
const expected = loadedFile.EXPECTED;
const query = loadedFile.QUERY;
const ignore_order = loadedFile.ignore_order;
var results = loaded.execSearch(loaded.getQuery(query), index);
process.stdout.write('Checking "' + file + '" ... ');
var error_text = [];
Expand All @@ -189,13 +191,17 @@ function main(argv) {
break;
}
var entry = expected[key];
var found = false;
var prev_pos = 0;
for (var i = 0; i < entry.length; ++i) {
if (lookForEntry(entry[i], results[key]) === true) {
found = true;
} else {
var entry_pos = lookForEntry(entry[i], results[key]);
if (entry_pos === null) {
error_text.push("==> Result not found in '" + key + "': '" +
JSON.stringify(entry[i]) + "'");
} else if (entry_pos < prev_pos && ignore_order === false) {
error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " +
" before '" + JSON.stringify(results[key][entry_pos]) + "'");
} else {
prev_pos = entry_pos;
}
}
}
Expand Down