Add query search order check
This commit is contained in:
parent
ff65726ebf
commit
00bbda16a7
@ -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 = {
|
||||
|
@ -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' },
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -130,10 +131,10 @@ function lookForEntry(entry, data) {
|
||||
}
|
||||
}
|
||||
if (allGood === true) {
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
@ -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 = [];
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user