Skip to content

Commit 4e3da52

Browse files
authored
Rollup merge of rust-lang#50302 - GuillaumeGomez:add-query-search-order-check, r=QuietMisdreavus
Add query search order check Fixes rust-lang#50180. r? @QuietMisdreavus
2 parents 427c548 + 00bbda1 commit 4e3da52

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/test/rustdoc-js/alias.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-order
12+
1113
const QUERY = '[';
1214

1315
const EXPECTED = {

src/test/rustdoc-js/basic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const QUERY = 'String';
1313
const EXPECTED = {
1414
'others': [
1515
{ 'path': 'std::string', 'name': 'String' },
16-
{ 'path': 'std::ffi', 'name': 'OsString' },
1716
{ 'path': 'std::ffi', 'name': 'CString' },
17+
{ 'path': 'std::ffi', 'name': 'OsString' },
1818
],
1919
'in_args': [
2020
{ 'path': 'std::str', 'name': 'eq' },

src/tools/rustdoc-js/tester.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function loadContent(content) {
8787
var Module = module.constructor;
8888
var m = new Module();
8989
m._compile(content, "tmp.js");
90+
m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1;
9091
return m.exports;
9192
}
9293

@@ -130,10 +131,10 @@ function lookForEntry(entry, data) {
130131
}
131132
}
132133
if (allGood === true) {
133-
return true;
134+
return i;
134135
}
135136
}
136-
return false;
137+
return null;
137138
}
138139

139140
function main(argv) {
@@ -177,6 +178,7 @@ function main(argv) {
177178
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
178179
const expected = loadedFile.EXPECTED;
179180
const query = loadedFile.QUERY;
181+
const ignore_order = loadedFile.ignore_order;
180182
var results = loaded.execSearch(loaded.getQuery(query), index);
181183
process.stdout.write('Checking "' + file + '" ... ');
182184
var error_text = [];
@@ -189,13 +191,17 @@ function main(argv) {
189191
break;
190192
}
191193
var entry = expected[key];
192-
var found = false;
194+
var prev_pos = 0;
193195
for (var i = 0; i < entry.length; ++i) {
194-
if (lookForEntry(entry[i], results[key]) === true) {
195-
found = true;
196-
} else {
196+
var entry_pos = lookForEntry(entry[i], results[key]);
197+
if (entry_pos === null) {
197198
error_text.push("==> Result not found in '" + key + "': '" +
198199
JSON.stringify(entry[i]) + "'");
200+
} else if (entry_pos < prev_pos && ignore_order === false) {
201+
error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " +
202+
" before '" + JSON.stringify(results[key][entry_pos]) + "'");
203+
} else {
204+
prev_pos = entry_pos;
199205
}
200206
}
201207
}

0 commit comments

Comments
 (0)