-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 rustdoc JS non-std tests #58330
Add rustdoc JS non-std tests #58330
Changes from all commits
834347d
aa3ca32
be23cd9
240fad0
405d950
d6add90
37ab3dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const QUERY = 'String'; | ||
|
||
const EXPECTED = { | ||
'others': [ | ||
{ 'path': 'std::string', 'name': 'String' }, | ||
{ 'path': 'std::ffi', 'name': 'CString' }, | ||
{ 'path': 'std::ffi', 'name': 'OsString' }, | ||
], | ||
'in_args': [ | ||
{ 'path': 'std::str', 'name': 'eq' }, | ||
], | ||
'returned': [ | ||
{ 'path': 'std::string::String', 'name': 'add' }, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
const QUERY = 'String'; | ||
const QUERY = 'Fo'; | ||
|
||
const EXPECTED = { | ||
'others': [ | ||
{ 'path': 'std::string', 'name': 'String' }, | ||
{ 'path': 'std::ffi', 'name': 'CString' }, | ||
{ 'path': 'std::ffi', 'name': 'OsString' }, | ||
], | ||
'in_args': [ | ||
{ 'path': 'std::str', 'name': 'eq' }, | ||
], | ||
'returned': [ | ||
{ 'path': 'std::string::String', 'name': 'add' }, | ||
{ 'path': 'basic', 'name': 'Foo' }, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// Foo | ||
pub struct Foo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ use crate::common::{output_base_dir, output_base_name, output_testname_unique}; | |
use crate::common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc}; | ||
use crate::common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind}; | ||
use crate::common::{Config, TestPaths}; | ||
use crate::common::{Incremental, MirOpt, RunMake, Ui}; | ||
use crate::common::{Incremental, MirOpt, RunMake, Ui, JsDocTest}; | ||
use diff; | ||
use crate::errors::{self, Error, ErrorKind}; | ||
use filetime::FileTime; | ||
|
@@ -275,6 +275,7 @@ impl<'test> TestCx<'test> { | |
RunMake => self.run_rmake_test(), | ||
RunPass | Ui => self.run_ui_test(), | ||
MirOpt => self.run_mir_opt_test(), | ||
JsDocTest => self.run_js_doc_test(), | ||
} | ||
} | ||
|
||
|
@@ -291,6 +292,7 @@ impl<'test> TestCx<'test> { | |
match self.config.mode { | ||
CompileFail => self.props.compile_pass, | ||
RunPass => true, | ||
JsDocTest => true, | ||
Ui => self.props.compile_pass, | ||
Incremental => { | ||
let revision = self.revision | ||
|
@@ -1712,7 +1714,8 @@ impl<'test> TestCx<'test> { | |
} | ||
|
||
fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> Command { | ||
let is_rustdoc = self.config.src_base.ends_with("rustdoc-ui"); | ||
let is_rustdoc = self.config.src_base.ends_with("rustdoc-ui") || | ||
self.config.src_base.ends_with("rustdoc-js"); | ||
let mut rustc = if !is_rustdoc { | ||
Command::new(&self.config.rustc_path) | ||
} else { | ||
|
@@ -1802,7 +1805,7 @@ impl<'test> TestCx<'test> { | |
rustc.arg(dir_opt); | ||
} | ||
RunFail | RunPassValgrind | Pretty | DebugInfoBoth | DebugInfoGdb | DebugInfoLldb | ||
| Codegen | Rustdoc | RunMake | CodegenUnits => { | ||
| Codegen | Rustdoc | RunMake | CodegenUnits | JsDocTest => { | ||
// do not use JSON output | ||
} | ||
} | ||
|
@@ -2710,6 +2713,27 @@ impl<'test> TestCx<'test> { | |
fs::remove_dir(path) | ||
} | ||
|
||
fn run_js_doc_test(&self) { | ||
if let Some(nodejs) = &self.config.nodejs { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took the same code I used previously. But iirc, it is from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, and checked in bootstrap (this is a config "passed through" from bootstrap). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! |
||
let out_dir = self.output_base_dir(); | ||
|
||
self.document(&out_dir); | ||
|
||
let root = self.config.find_rust_src_root().unwrap(); | ||
let res = self.cmd2procres( | ||
Command::new(&nodejs) | ||
.arg(root.join("src/tools/rustdoc-js/tester.js")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be Either way, I'm confused why we've only migrated one of the suites and not both to compiletest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
.arg(out_dir.parent().expect("no parent")) | ||
.arg(&self.testpaths.file.file_stem().expect("couldn't get file stem")), | ||
); | ||
if !res.status.success() { | ||
self.fatal_proc_rec("rustdoc-js test failed!", &res); | ||
} | ||
} else { | ||
self.fatal("no nodeJS"); | ||
} | ||
} | ||
|
||
fn run_ui_test(&self) { | ||
// if the user specified a format in the ui test | ||
// print the output to the stderr file, otherwise extract | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this isn't needed? The compiletest invocation above is has the mode as js-doc-test, which you've also checked below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more convenient to check for instance:
or: