Skip to content

Commit 14f504c

Browse files
committed
Add a build-aux-docs directive to compiletest
This flag causes the documentation for all `aux-build` files to be built, which happens prior to running/building the parent test.
1 parent 1099af7 commit 14f504c

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/compiletest/header.rs

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub struct TestProps {
3434
pub exec_env: Vec<(String,String)> ,
3535
// Lines to check if they appear in the expected debugger output
3636
pub check_lines: Vec<String> ,
37+
// Build documentation for all specified aux-builds as well
38+
pub build_aux_docs: bool,
3739
// Flag to force a crate to be built with the host architecture
3840
pub force_host: bool,
3941
// Check stdout for error-pattern output as well as stderr
@@ -59,6 +61,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
5961
let mut run_flags = None;
6062
let mut pp_exact = None;
6163
let mut check_lines = Vec::new();
64+
let mut build_aux_docs = false;
6265
let mut force_host = false;
6366
let mut check_stdout = false;
6467
let mut no_prefer_dynamic = false;
@@ -83,6 +86,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
8386
pp_exact = parse_pp_exact(ln, testfile);
8487
}
8588

89+
if !build_aux_docs {
90+
build_aux_docs = parse_build_aux_docs(ln);
91+
}
92+
8693
if !force_host {
8794
force_host = parse_force_host(ln);
8895
}
@@ -144,6 +151,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
144151
aux_builds: aux_builds,
145152
exec_env: exec_env,
146153
check_lines: check_lines,
154+
build_aux_docs: build_aux_docs,
147155
force_host: force_host,
148156
check_stdout: check_stdout,
149157
no_prefer_dynamic: no_prefer_dynamic,
@@ -284,6 +292,10 @@ fn parse_force_host(line: &str) -> bool {
284292
parse_name_directive(line, "force-host")
285293
}
286294

295+
fn parse_build_aux_docs(line: &str) -> bool {
296+
parse_name_directive(line, "build-aux-docs")
297+
}
298+
287299
fn parse_check_stdout(line: &str) -> bool {
288300
parse_name_directive(line, "check-stdout")
289301
}

src/compiletest/runtest.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -1149,11 +1149,20 @@ fn compile_test(config: &Config, props: &TestProps,
11491149
}
11501150

11511151
fn document(config: &Config, props: &TestProps,
1152-
testfile: &Path) -> (ProcRes, PathBuf) {
1152+
testfile: &Path, out_dir: &Path) -> ProcRes {
1153+
if props.build_aux_docs {
1154+
for rel_ab in &props.aux_builds {
1155+
let abs_ab = config.aux_base.join(rel_ab);
1156+
let aux_props = header::load_props(&abs_ab);
1157+
1158+
let auxres = document(config, &aux_props, &abs_ab, out_dir);
1159+
if !auxres.status.success() {
1160+
return auxres;
1161+
}
1162+
}
1163+
}
1164+
11531165
let aux_dir = aux_output_dir_name(config, testfile);
1154-
let out_dir = output_base_name(config, testfile);
1155-
let _ = fs::remove_dir_all(&out_dir);
1156-
ensure_dir(&out_dir);
11571166
let mut args = vec!["-L".to_owned(),
11581167
aux_dir.to_str().unwrap().to_owned(),
11591168
"-o".to_owned(),
@@ -1164,7 +1173,7 @@ fn document(config: &Config, props: &TestProps,
11641173
prog: config.rustdoc_path.to_str().unwrap().to_owned(),
11651174
args: args,
11661175
};
1167-
(compose_and_run_compiler(config, props, testfile, args, None), out_dir)
1176+
compose_and_run_compiler(config, props, testfile, args, None)
11681177
}
11691178

11701179
fn exec_compiled_test(config: &Config, props: &TestProps,
@@ -1723,7 +1732,11 @@ fn charset() -> &'static str {
17231732
}
17241733

17251734
fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) {
1726-
let (proc_res, out_dir) = document(config, props, testfile);
1735+
let out_dir = output_base_name(config, testfile);
1736+
let _ = fs::remove_dir_all(&out_dir);
1737+
ensure_dir(&out_dir);
1738+
1739+
let proc_res = document(config, props, testfile, &out_dir);
17271740
if !proc_res.status.success() {
17281741
fatal_proc_rec("rustdoc failed!", &proc_res);
17291742
}

0 commit comments

Comments
 (0)