Skip to content

Commit a9f940e

Browse files
committed
Run the external doc tests in tools job.
1 parent 0d300d4 commit a9f940e

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

src/bootstrap/test.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,17 @@ fn try_run(build: &Build, cmd: &mut Command) -> bool {
7878
true
7979
}
8080

81-
fn try_run_quiet(build: &Build, cmd: &mut Command) {
81+
fn try_run_quiet(build: &Build, cmd: &mut Command) -> bool {
8282
if !build.fail_fast {
8383
if !build.try_run_quiet(cmd) {
8484
let mut failures = build.delayed_failures.borrow_mut();
8585
failures.push(format!("{:?}", cmd));
86+
return false;
8687
}
8788
} else {
8889
build.run_quiet(cmd);
8990
}
91+
true
9092
}
9193

9294
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -1042,7 +1044,15 @@ impl Step for DocTest {
10421044
continue;
10431045
}
10441046

1045-
markdown_test(builder, compiler, &p);
1047+
let test_result = markdown_test(builder, compiler, &p);
1048+
if self.is_ext_doc {
1049+
let toolstate = if test_result {
1050+
ToolState::TestPass
1051+
} else {
1052+
ToolState::TestFail
1053+
};
1054+
build.save_toolstate(self.name, toolstate);
1055+
}
10461056
}
10471057
}
10481058
}
@@ -1142,13 +1152,13 @@ impl Step for ErrorIndex {
11421152
}
11431153
}
11441154

1145-
fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
1155+
fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool {
11461156
let build = builder.build;
11471157
let mut file = t!(File::open(markdown));
11481158
let mut contents = String::new();
11491159
t!(file.read_to_string(&mut contents));
11501160
if !contents.contains("```") {
1151-
return;
1161+
return true;
11521162
}
11531163

11541164
println!("doc tests for: {}", markdown.display());
@@ -1162,9 +1172,9 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
11621172
cmd.arg("--test-args").arg(test_args);
11631173

11641174
if build.config.quiet_tests {
1165-
try_run_quiet(build, &mut cmd);
1175+
try_run_quiet(build, &mut cmd)
11661176
} else {
1167-
try_run(build, &mut cmd);
1177+
try_run(build, &mut cmd)
11681178
}
11691179
}
11701180

src/ci/docker/x86_64-gnu-tools/checktools.sh

+27-12
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,49 @@ touch "$TOOLSTATE_FILE"
2525

2626
set +e
2727
python2.7 "$X_PY" test --no-fail-fast \
28+
src/doc/book \
29+
src/doc/nomicon \
30+
src/doc/reference \
31+
src/doc/rust-by-example \
2832
src/tools/rls \
2933
src/tools/rustfmt \
3034
src/tools/miri \
3135
src/tools/clippy
3236
set -e
3337

3438
cat "$TOOLSTATE_FILE"
39+
echo
3540

36-
# If this PR is intended to update one of these tools, do not let the build pass
37-
# when they do not test-pass.
38-
for TOOL in rls rustfmt clippy; do
39-
echo "Verifying status of $TOOL..."
40-
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then
41-
echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..."
42-
if grep -vq '"'"$TOOL"'[^"]*":"test-pass"' "$TOOLSTATE_FILE"; then
41+
verify_status() {
42+
echo "Verifying status of $1..."
43+
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then
44+
echo "This PR updated '$2', verifying if status is 'test-pass'..."
45+
if grep -vq '"'"$1"'":"test-pass"' "$TOOLSTATE_FILE"; then
4346
echo
44-
echo "⚠️ We detected that this PR updated '$TOOL', but its tests failed."
47+
echo "⚠️ We detected that this PR updated '$1', but its tests failed."
4548
echo
46-
echo "If you do intend to update '$TOOL', please check the error messages above and"
49+
echo "If you do intend to update '$1', please check the error messages above and"
4750
echo "commit another update."
4851
echo
49-
echo "If you do NOT intend to update '$TOOL', please ensure you did not accidentally"
50-
echo "change the submodule at 'src/tools/$TOOL'. You may ask your reviewer for the"
52+
echo "If you do NOT intend to update '$1', please ensure you did not accidentally"
53+
echo "change the submodule at '$2'. You may ask your reviewer for the"
5154
echo "proper steps."
5255
exit 3
5356
fi
5457
fi
55-
done
58+
}
59+
60+
# If this PR is intended to update one of these tools, do not let the build pass
61+
# when they do not test-pass.
62+
63+
verify_status book src/doc/book
64+
verify_status nomicon src/doc/nomicon
65+
verify_status reference src/doc/reference
66+
verify_status rust-by-example src/doc/rust-by-example
67+
verify_status rls src/tool/rls
68+
verify_status rustfmt src/tool/rustfmt
69+
verify_status clippy-driver src/tool/clippy
70+
#verify_status miri src/tool/miri
5671

5772
if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
5873
. "$(dirname $0)/repo.sh"

src/tools/publish_toolstate.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk',
3030
'rls': '@nrc',
3131
'rustfmt': '@nrc',
32+
'book': '@carols10cents @steveklabnik',
33+
'nomicon': '@frewsxcv @Gankro',
34+
'reference': '@steveklabnik @Havvy @matthewjasper @alercah',
35+
'rust-by-example': '@steveklabnik @marioidival @projektir',
3236
}
3337

3438

@@ -83,7 +87,7 @@ def update_latest(
8387
elif new < old:
8488
changed = True
8589
message += '💔 {} on {}: {} → {} (cc {}).\n' \
86-
.format(tool, os, old, new, MAINTAINERS[tool])
90+
.format(tool, os, old, new, MAINTAINERS.get(tool))
8791

8892
if changed:
8993
status['commit'] = current_commit

0 commit comments

Comments
 (0)