Merge pull request #533 from RalfJung/cargo-miri-2018

port cargo-miri-test to 2018 edition, mostly to test that that works with cargo miri
This commit is contained in:
Ralf Jung 2018-11-20 10:40:55 +01:00 committed by GitHub
commit 3cfaed2dbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -2,6 +2,7 @@
name = "cargo-miri-test"
version = "0.1.0"
authors = ["Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>"]
edition = "2018"
[dependencies]
byteorder = "1.0"
byteorder = "1.0"

View file

@ -1,5 +1,3 @@
extern crate byteorder;
use byteorder::{BigEndian, ByteOrder};
fn main() {

View file

@ -46,11 +46,15 @@ fn main() {
}
if let Some("miri") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
// this arm is when `cargo miri` is called
// this arm is when `cargo miri` is called. We call `cargo rustc` for
// each applicable target, but with the RUSTC env var set to the `cargo-miri`
// binary so that we come back in the other branch, and dispatch
// the invocations to rustc and miri, respectively.
let test = std::env::args().nth(2).map_or(false, |text| text == "test");
let skip = if test { 3 } else { 2 };
// We need to get the manifest, and then the metadata, to enumerate targets.
let manifest_path_arg = std::env::args().skip(skip).find(|val| {
val.starts_with("--manifest-path=")
});
@ -92,6 +96,9 @@ fn main() {
})
.expect("could not find matching package");
let package = metadata.packages.remove(package_index);
// Finally we got the metadata, iterate all targets and see for which ones
// we do anything.
for target in package.targets {
let args = std::env::args().skip(skip);
let kind = target.kind.get(0).expect(
@ -139,7 +146,8 @@ fn main() {
}
}
} else {
// this arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself
// This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself:
// Dependencies get dispatched to rustc, the final test/binary to miri.
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));