Skip to content

Commit 9cb18a9

Browse files
committed
Auto merge of rust-lang#48653 - Manishearth:rollup2, r=Manishearth
Another rollup None
2 parents ddfbf2b + 2b3c815 commit 9cb18a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+705
-336
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ matrix:
188188
script:
189189
MESSAGE_FILE=$(mktemp -t msg.XXXXXX);
190190
. src/ci/docker/x86_64-gnu-tools/repo.sh;
191-
commit_toolstate_change "$MESSAGE_FILE" "$TRAVIS_BUILD_DIR/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "$MESSAGE_FILE"
191+
commit_toolstate_change "$MESSAGE_FILE" "$TRAVIS_BUILD_DIR/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "$MESSAGE_FILE" "$TOOLSTATE_REPO_ACCESS_TOKEN";
192192

193193
env:
194194
global:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ find out how various parts of the compiler work.
233233
[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
234234
[#rust]: irc://irc.mozilla.org/rust
235235
[#rust-beginners]: irc://irc.mozilla.org/rust-beginners
236-
[rustc-guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
236+
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
237237

238238
## License
239239
[license]: #license

src/bootstrap/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub struct ShouldRun<'a> {
231231
paths: BTreeSet<PathSet>,
232232

233233
// If this is a default rule, this is an additional constraint placed on
234-
// it's run. Generally something like compiler docs being enabled.
234+
// its run. Generally something like compiler docs being enabled.
235235
is_really_default: bool,
236236
}
237237

@@ -326,7 +326,9 @@ impl<'a> Builder<'a> {
326326
test::RunPassPretty, test::RunFailPretty, test::RunPassValgrindPretty,
327327
test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, test::RunMake,
328328
test::Crate, test::CrateLibrustc, test::Rustdoc, test::Linkcheck, test::Cargotest,
329-
test::Cargo, test::Rls, test::Docs, test::ErrorIndex, test::Distcheck,
329+
test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck,
330+
test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
331+
test::TheBook, test::UnstableBook,
330332
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme),
331333
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
332334
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,

src/bootstrap/compile.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ impl Step for CodegenBackend {
629629
.arg(build.src.join("src/librustc_trans/Cargo.toml"));
630630
rustc_cargo_env(build, &mut cargo);
631631

632+
let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage));
633+
632634
match &*self.backend {
633635
"llvm" | "emscripten" => {
634636
// Build LLVM for our target. This will implicitly build the
@@ -642,7 +644,6 @@ impl Step for CodegenBackend {
642644
features.push_str(" emscripten");
643645
}
644646

645-
let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage));
646647
println!("Building stage{} codegen artifacts ({} -> {}, {})",
647648
compiler.stage, &compiler.host, target, self.backend);
648649

src/bootstrap/test.rs

+69-18
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)]
@@ -994,23 +996,19 @@ impl Step for Compiletest {
994996
}
995997

996998
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
997-
pub struct Docs {
999+
struct DocTest {
9981000
compiler: Compiler,
1001+
path: &'static str,
1002+
name: &'static str,
1003+
is_ext_doc: bool,
9991004
}
10001005

1001-
impl Step for Docs {
1006+
impl Step for DocTest {
10021007
type Output = ();
1003-
const DEFAULT: bool = true;
10041008
const ONLY_HOSTS: bool = true;
10051009

10061010
fn should_run(run: ShouldRun) -> ShouldRun {
1007-
run.path("src/doc")
1008-
}
1009-
1010-
fn make_run(run: RunConfig) {
1011-
run.builder.ensure(Docs {
1012-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
1013-
});
1011+
run.never()
10141012
}
10151013

10161014
/// Run `rustdoc --test` for all documentation in `src/doc`.
@@ -1026,9 +1024,9 @@ impl Step for Docs {
10261024

10271025
// Do a breadth-first traversal of the `src/doc` directory and just run
10281026
// tests for all files that end in `*.md`
1029-
let mut stack = vec![build.src.join("src/doc")];
1027+
let mut stack = vec![build.src.join(self.path)];
10301028
let _time = util::timeit();
1031-
let _folder = build.fold_output(|| "test_docs");
1029+
let _folder = build.fold_output(|| format!("test_{}", self.name));
10321030

10331031
while let Some(p) = stack.pop() {
10341032
if p.is_dir() {
@@ -1046,11 +1044,64 @@ impl Step for Docs {
10461044
continue;
10471045
}
10481046

1049-
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+
}
10501056
}
10511057
}
10521058
}
10531059

1060+
macro_rules! test_book {
1061+
($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1062+
$(
1063+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1064+
pub struct $name {
1065+
compiler: Compiler,
1066+
}
1067+
1068+
impl Step for $name {
1069+
type Output = ();
1070+
const DEFAULT: bool = $default;
1071+
const ONLY_HOSTS: bool = true;
1072+
1073+
fn should_run(run: ShouldRun) -> ShouldRun {
1074+
run.path($path)
1075+
}
1076+
1077+
fn make_run(run: RunConfig) {
1078+
run.builder.ensure($name {
1079+
compiler: run.builder.compiler(run.builder.top_stage, run.host),
1080+
});
1081+
}
1082+
1083+
fn run(self, builder: &Builder) {
1084+
builder.ensure(DocTest {
1085+
compiler: self.compiler,
1086+
path: $path,
1087+
name: $book_name,
1088+
is_ext_doc: !$default,
1089+
});
1090+
}
1091+
}
1092+
)+
1093+
}
1094+
}
1095+
1096+
test_book!(
1097+
Nomicon, "src/doc/nomicon", "nomicon", default=false;
1098+
Reference, "src/doc/reference", "reference", default=false;
1099+
RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1100+
RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1101+
TheBook, "src/doc/book", "book", default=false;
1102+
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1103+
);
1104+
10541105
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
10551106
pub struct ErrorIndex {
10561107
compiler: Compiler,
@@ -1101,13 +1152,13 @@ impl Step for ErrorIndex {
11011152
}
11021153
}
11031154

1104-
fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
1155+
fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool {
11051156
let build = builder.build;
11061157
let mut file = t!(File::open(markdown));
11071158
let mut contents = String::new();
11081159
t!(file.read_to_string(&mut contents));
11091160
if !contents.contains("```") {
1110-
return;
1161+
return true;
11111162
}
11121163

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

11231174
if build.config.quiet_tests {
1124-
try_run_quiet(build, &mut cmd);
1175+
try_run_quiet(build, &mut cmd)
11251176
} else {
1126-
try_run(build, &mut cmd);
1177+
try_run(build, &mut cmd)
11271178
}
11281179
}
11291180

src/ci/docker/x86_64-gnu-tools/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
COPY scripts/sccache.sh /scripts/
1818
RUN sh /scripts/sccache.sh
1919

20+
COPY x86_64-gnu-tools/checkregression.py /tmp/
2021
COPY x86_64-gnu-tools/checktools.sh /tmp/
2122
COPY x86_64-gnu-tools/repo.sh /tmp/
2223

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2018 The Rust Project Developers. See the COPYRIGHT
5+
# file at the top-level directory of this distribution and at
6+
# http://rust-lang.org/COPYRIGHT.
7+
#
8+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
11+
# option. This file may not be copied, modified, or distributed
12+
# except according to those terms.
13+
14+
import sys
15+
import json
16+
17+
if __name__ == '__main__':
18+
os_name = sys.argv[1]
19+
toolstate_file = sys.argv[2]
20+
current_state = sys.argv[3]
21+
22+
with open(toolstate_file, 'r') as f:
23+
toolstate = json.load(f)
24+
with open(current_state, 'r') as f:
25+
current = json.load(f)
26+
27+
regressed = False
28+
for cur in current:
29+
tool = cur['tool']
30+
state = cur[os_name]
31+
new_state = toolstate.get(tool, '')
32+
if new_state < state:
33+
print(
34+
'Error: The state of "{}" has regressed from "{}" to "{}"'
35+
.format(tool, state, new_state)
36+
)
37+
regressed = True
38+
39+
if regressed:
40+
sys.exit(1)

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

+35-12
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,57 @@ TOOLSTATE_FILE="$(realpath $2)"
1717
OS="$3"
1818
COMMIT="$(git rev-parse HEAD)"
1919
CHANGED_FILES="$(git diff --name-status HEAD HEAD^)"
20+
SIX_WEEK_CYCLE="$(( ($(date +%s) / 604800 - 3) % 6 ))"
21+
# ^ 1970 Jan 1st is a Thursday, and our release dates are also on Thursdays,
22+
# thus we could divide by 604800 (7 days in seconds) directly.
2023

2124
touch "$TOOLSTATE_FILE"
2225

2326
set +e
2427
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 \
2532
src/tools/rls \
2633
src/tools/rustfmt \
2734
src/tools/miri \
2835
src/tools/clippy
2936
set -e
3037

3138
cat "$TOOLSTATE_FILE"
39+
echo
3240

33-
# If this PR is intended to update one of these tools, do not let the build pass
34-
# when they do not test-pass.
35-
for TOOL in rls rustfmt clippy; do
36-
echo "Verifying status of $TOOL..."
37-
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then
38-
echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..."
39-
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
4046
echo
41-
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."
4248
echo
43-
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"
4450
echo "commit another update."
4551
echo
46-
echo "If you do NOT intend to update '$TOOL', please ensure you did not accidentally"
47-
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"
4854
echo "proper steps."
4955
exit 3
5056
fi
5157
fi
52-
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
5371

5472
if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
5573
. "$(dirname $0)/repo.sh"
@@ -59,6 +77,11 @@ if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_s
5977
sed -i "1 a\\
6078
$COMMIT\t$(cat "$TOOLSTATE_FILE")
6179
" "history/$OS.tsv"
80+
# if we are at the last week in the 6-week release cycle, reject any kind of regression.
81+
if [ $SIX_WEEK_CYCLE -eq 5 ]; then
82+
python2.7 "$(dirname $0)/checkregression.py" \
83+
"$OS" "$TOOLSTATE_FILE" "rust-toolstate/_data/latest.json"
84+
fi
6285
rm -f "$MESSAGE_FILE"
6386
exit 0
6487
fi

0 commit comments

Comments
 (0)