Skip to content

Commit 0527be9

Browse files
committedJul 5, 2020
bootstrap: test that src/tools/semverver builds.
1 parent f726125 commit 0527be9

File tree

9 files changed

+115
-9
lines changed

9 files changed

+115
-9
lines changed
 

‎Cargo.lock

+46-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ dependencies = [
282282
"cargo-test-support",
283283
"clap",
284284
"core-foundation",
285-
"crates-io",
285+
"crates-io 0.31.1",
286286
"crossbeam-utils 0.7.2",
287287
"crypto-hash",
288288
"curl",
@@ -680,6 +680,21 @@ dependencies = [
680680
"url 2.1.0",
681681
]
682682

683+
[[package]]
684+
name = "crates-io"
685+
version = "0.32.0"
686+
source = "registry+https://github.com/rust-lang/crates.io-index"
687+
checksum = "65949ecc100abd1df7d80740ee58afb599f2447c5011bbf5acb5a039a67607ca"
688+
dependencies = [
689+
"anyhow",
690+
"curl",
691+
"percent-encoding 2.1.0",
692+
"serde",
693+
"serde_derive",
694+
"serde_json",
695+
"url 2.1.0",
696+
]
697+
683698
[[package]]
684699
name = "crc32fast"
685700
version = "1.1.2"
@@ -2376,6 +2391,18 @@ version = "1.2.3"
23762391
source = "registry+https://github.com/rust-lang/crates.io-index"
23772392
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
23782393

2394+
[[package]]
2395+
name = "quickcheck"
2396+
version = "0.9.2"
2397+
source = "registry+https://github.com/rust-lang/crates.io-index"
2398+
checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
2399+
dependencies = [
2400+
"env_logger 0.7.1",
2401+
"log",
2402+
"rand 0.7.3",
2403+
"rand_core 0.5.1",
2404+
]
2405+
23792406
[[package]]
23802407
name = "quine-mc_cluskey"
23812408
version = "0.2.4"
@@ -4170,6 +4197,24 @@ version = "0.7.0"
41704197
source = "registry+https://github.com/rust-lang/crates.io-index"
41714198
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
41724199

4200+
[[package]]
4201+
name = "semverver"
4202+
version = "0.1.46"
4203+
dependencies = [
4204+
"anyhow",
4205+
"cargo",
4206+
"crates-io 0.32.0",
4207+
"curl",
4208+
"env_logger 0.7.1",
4209+
"log",
4210+
"quickcheck",
4211+
"rand 0.7.3",
4212+
"rustc-workspace-hack",
4213+
"semver 0.9.0",
4214+
"serde",
4215+
"serde_json",
4216+
]
4217+
41734218
[[package]]
41744219
name = "serde"
41754220
version = "1.0.99"

‎Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ members = [
2626
"src/tools/rustdoc-themes",
2727
"src/tools/unicode-table-generator",
2828
"src/tools/expand-yaml-anchors",
29+
"src/tools/semverver",
2930
]
3031
exclude = [
3132
"build",
@@ -69,6 +70,9 @@ cargo = { path = "src/tools/cargo" }
6970
# `rustfmt` executable are the same exact version).
7071
rustfmt-nightly = { path = "src/tools/rustfmt" }
7172

73+
# Cargo again but from `crates.io` (semverver uses that instead of a git dependency).
74+
cargo = { path = "src/tools/cargo" }
75+
7276
# See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
7377
# here
7478
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }

‎config.toml.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
# Installs chosen set of extended tools if `extended = true`. By default builds all.
208208
# If chosen tool failed to build the installation fails. If `extended = false`, this
209209
# option is ignored.
210-
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"]
210+
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src", "semverver"]
211211

212212
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
213213
#verbose = 0

‎src/bootstrap/builder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ impl<'a> Builder<'a> {
372372
tool::Rustdoc,
373373
tool::Clippy,
374374
tool::CargoClippy,
375+
tool::Semverver,
376+
tool::SemverPublic,
377+
tool::CargoSemver,
375378
native::Llvm,
376379
native::Sanitizers,
377380
tool::Rustfmt,
@@ -380,7 +383,7 @@ impl<'a> Builder<'a> {
380383
native::Lld
381384
),
382385
Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => {
383-
describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy)
386+
describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy, check::Semverver)
384387
}
385388
Kind::Test => describe!(
386389
crate::toolstate::ToolStateCheck,
@@ -426,6 +429,7 @@ impl<'a> Builder<'a> {
426429
test::RustdocJSNotStd,
427430
test::RustdocTheme,
428431
test::RustdocUi,
432+
test::Semverver,
429433
// Run bootstrap close to the end as it's unlikely to fail
430434
test::Bootstrap,
431435
// Run run-make last, since these won't pass without make on Windows

‎src/bootstrap/check.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ macro_rules! tool_check_step {
196196
}
197197

198198
tool_check_step!(Rustdoc, "src/tools/rustdoc", SourceType::InTree);
199-
// Clippy is a hybrid. It is an external tool, but uses a git subtree instead
200-
// of a submodule. Since the SourceType only drives the deny-warnings
201-
// behavior, treat it as in-tree so that any new warnings in clippy will be
202-
// rejected.
199+
// Clippy and semverver are hybrids. They're external tools, but use git subtrees
200+
// instead of submodules. Since the SourceType only drives the deny-warnings
201+
// behavior, treat it as in-tree so that any new warnings will be rejected.
203202
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
203+
// FIXME(eddyb) use `InTree` here as per the comment above, when Cargo can build
204+
// with deny-warnings + `-Wrust_2018_idioms` (which it can't today).
205+
tool_check_step!(Semverver, "src/tools/semverver", SourceType::Submodule);
204206

205207
/// Cargo's output path for the standard library in a given stage, compiled
206208
/// by a particular compiler for the specified target.

‎src/bootstrap/test.rs

+39
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,45 @@ impl Step for Clippy {
559559
}
560560
}
561561

562+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
563+
pub struct Semverver {
564+
stage: u32,
565+
host: Interned<String>,
566+
}
567+
568+
impl Step for Semverver {
569+
type Output = ();
570+
const ONLY_HOSTS: bool = true;
571+
const DEFAULT: bool = false;
572+
573+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
574+
run.path("src/tools/semverver")
575+
}
576+
577+
fn make_run(run: RunConfig<'_>) {
578+
run.builder.ensure(Semverver { stage: run.builder.top_stage, host: run.target });
579+
}
580+
581+
/// Runs `cargo test` for semverver.
582+
fn run(self, builder: &Builder<'_>) {
583+
let stage = self.stage;
584+
let host = self.host;
585+
let compiler = builder.compiler(stage, host);
586+
587+
builder
588+
.ensure(tool::CargoSemver { compiler, target: self.host, extra_features: Vec::new() })
589+
.expect("in-tree tool");
590+
builder
591+
.ensure(tool::Semverver { compiler, target: self.host, extra_features: Vec::new() })
592+
.expect("in-tree tool");
593+
builder
594+
.ensure(tool::SemverPublic { compiler, target: self.host, extra_features: Vec::new() })
595+
.expect("in-tree tool");
596+
597+
// FIXME(eddyb) actually run tests from `src/tools/semverver`.
598+
}
599+
}
600+
562601
fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
563602
// Configure PATH to find the right rustc. NB. we have to use PATH
564603
// and not RUSTC because the Cargo test suite has tests that will

‎src/bootstrap/tool.rs

+7
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub fn prepare_tool_cargo(
237237
|| path.ends_with("clippy")
238238
|| path.ends_with("miri")
239239
|| path.ends_with("rustfmt")
240+
|| path.ends_with("semverver")
240241
{
241242
cargo.env("LIBZ_SYS_STATIC", "1");
242243
features.push("rustc-workspace-hack/all-static".to_string());
@@ -604,6 +605,7 @@ macro_rules! tool_extended {
604605
|tools| {
605606
tools.iter().any(|tool| match tool.as_ref() {
606607
"clippy" => $tool_name == "clippy-driver",
608+
"semverver" => $tool_name == "rust-semverver",
607609
x => $tool_name == x,
608610
})
609611
}),
@@ -659,6 +661,11 @@ tool_extended!((self, builder),
659661
};
660662
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {};
661663
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=false, {};
664+
// FIXME(eddyb) use `in_tree=true` for semverver, when Cargo can build
665+
// with deny-warnings + `-Wrust_2018_idioms` (which it can't today).
666+
CargoSemver, semverver, "src/tools/semverver", "cargo-semver", stable=false, {};
667+
Semverver, semverver, "src/tools/semverver", "rust-semverver", stable=false, {};
668+
SemverPublic, semverver, "src/tools/semverver", "rust-semver-public", stable=false, {};
662669
);
663670

664671
impl<'a> Builder<'a> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ set -e
2323
# debugging: print out the saved toolstates
2424
cat /tmp/toolstate/toolstates.json
2525
python3 "$X_PY" test check-tools
26-
python3 "$X_PY" test src/tools/clippy
26+
python3 "$X_PY" test src/tools/clippy src/tools/semverver

‎src/tools/semverver/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ name = "rust-semver-public"
2727
path = "src/bin/rust_semver_public.rs"
2828

2929
[dependencies]
30-
cargo = "0.44"
30+
cargo = "0.47"
3131
crates-io = "0.32"
3232
curl = "0.4.21"
3333
env_logger = "0.7"
@@ -40,3 +40,8 @@ serde_json = "1.0.34"
4040

4141
[dev-dependencies]
4242
quickcheck = "0.9"
43+
44+
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
45+
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
46+
# for more information.
47+
rustc-workspace-hack = "1.0.0"

0 commit comments

Comments
 (0)