diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-03 16:11:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-03 16:11:26 +0800 |
| commit | 4e3da52d02512967c6795d4a565a1dfe31131378 (patch) | |
| tree | d1035211d2e75df78c2fe8248833acdc4725f6d5 /src/tools | |
| parent | 427c5487493fbd5e96e81b7d3ba54784e0805df7 (diff) | |
| parent | 00bbda16a72eab1cf3418f9021329915eddb267c (diff) | |
| download | rust-4e3da52d02512967c6795d4a565a1dfe31131378.tar.gz rust-4e3da52d02512967c6795d4a565a1dfe31131378.zip | |
Rollup merge of #50302 - GuillaumeGomez:add-query-search-order-check, r=QuietMisdreavus
Add query search order check Fixes #50180. r? @QuietMisdreavus
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/rustdoc-js/tester.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 6992f2ba123..1c79443dedf 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -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; } } } |
