mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-07 12:33:14 +00:00
Add rustdoc-js tester should-fail option
This commit is contained in:
parent
e28502edca
commit
1fcce48451
20
src/test/rustdoc-js/keyword.js
Normal file
20
src/test/rustdoc-js/keyword.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// ignore-order
|
||||||
|
|
||||||
|
const QUERY = 'fn';
|
||||||
|
|
||||||
|
const EXPECTED = {
|
||||||
|
'others': [
|
||||||
|
{ 'path': 'std', 'name': 'fn', ty: 15 }, // 15 is for primitive types
|
||||||
|
{ 'path': 'std', 'name': 'fn', ty: 21 }, // 21 is for keywords
|
||||||
|
],
|
||||||
|
};
|
19
src/test/rustdoc-js/should-fail.js
Normal file
19
src/test/rustdoc-js/should-fail.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// should-fail
|
||||||
|
|
||||||
|
const QUERY = 'fn';
|
||||||
|
|
||||||
|
const EXPECTED = {
|
||||||
|
'others': [
|
||||||
|
{ 'path': 'std', 'name': 'fn', ty: 14 },
|
||||||
|
],
|
||||||
|
};
|
@ -164,6 +164,7 @@ function loadContent(content) {
|
|||||||
m._compile(content, "tmp.js");
|
m._compile(content, "tmp.js");
|
||||||
m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1;
|
m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1;
|
||||||
m.exports.exact_check = content.indexOf("\n// exact-check\n") !== -1;
|
m.exports.exact_check = content.indexOf("\n// exact-check\n") !== -1;
|
||||||
|
m.exports.should_fail = content.indexOf("\n// should-fail\n") !== -1;
|
||||||
return m.exports;
|
return m.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +260,7 @@ function main(argv) {
|
|||||||
const query = loadedFile.QUERY;
|
const query = loadedFile.QUERY;
|
||||||
const ignore_order = loadedFile.ignore_order;
|
const ignore_order = loadedFile.ignore_order;
|
||||||
const exact_check = loadedFile.exact_check;
|
const exact_check = loadedFile.exact_check;
|
||||||
|
const should_fail = loadedFile.should_fail;
|
||||||
var results = loaded.execSearch(loaded.getQuery(query), index);
|
var results = loaded.execSearch(loaded.getQuery(query), index);
|
||||||
process.stdout.write('Checking "' + file + '" ... ');
|
process.stdout.write('Checking "' + file + '" ... ');
|
||||||
var error_text = [];
|
var error_text = [];
|
||||||
@ -289,7 +291,11 @@ function main(argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error_text.length !== 0) {
|
if (error_text.length === 0 && should_fail === true) {
|
||||||
|
errors += 1;
|
||||||
|
console.error("FAILED");
|
||||||
|
console.error("==> Test was supposed to fail but all items were found...");
|
||||||
|
} else if (error_text.length !== 0 && should_fail === false) {
|
||||||
errors += 1;
|
errors += 1;
|
||||||
console.error("FAILED");
|
console.error("FAILED");
|
||||||
console.error(error_text.join("\n"));
|
console.error(error_text.join("\n"));
|
||||||
|
Loading…
Reference in New Issue
Block a user