Permalink
Browse files

Auto merge of #355 - pietroalbini:validate-manifest, r=pietroalbini

Validate manifests in the prepare step

This will hopefully fix most of the errors in recent runs.
  • Loading branch information...
bors committed Oct 23, 2018
2 parents 4b09fcd + 9a542c7 commit c2fcf3a283c299211ef8f4ed51350b005af598cd
@@ -0,0 +1 @@
wow! this isn't valid toml? :O
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
View
@@ -1,3 +1,5 @@
use results::TestResult;
error_chain! {
foreign_links {
IoError(::std::io::Error);
@@ -81,5 +83,10 @@ error_chain! {
BadConfig {
description("the config file contains errors")
}
OverrideResult(result: TestResult) {
description("overridden task result")
display("overridden task result to {}", result.to_str())
}
}
}
View
@@ -61,6 +61,7 @@ pub(crate) struct RunCommand {
quiet: bool,
enable_timeout: bool,
local_rustup: bool,
hide_output: bool,
}
impl RunCommand {
@@ -73,6 +74,7 @@ impl RunCommand {
quiet: false,
enable_timeout: true,
local_rustup: false,
hide_output: false,
})
}
@@ -110,6 +112,11 @@ impl RunCommand {
self
}
pub(crate) fn hide_output(mut self, hide_output: bool) -> Self {
self.hide_output = hide_output;
self
}
pub(crate) fn sandboxed(self) -> SandboxedCommand {
SandboxedCommand::new(self)
}
@@ -154,7 +161,13 @@ impl RunCommand {
}
info!("running `{}`", cmdstr);
let out = log_command(cmd, capture, self.quiet, self.enable_timeout).map_err(|e| {
let out = log_command(
cmd,
capture,
self.quiet,
self.enable_timeout,
self.hide_output,
).map_err(|e| {
info!("error running command: {}", e);
e
})?;
@@ -255,6 +268,7 @@ fn log_command(
capture: bool,
quiet: bool,
enable_timeout: bool,
hide_output: bool,
) -> Result<ProcessOutput> {
let (max_timeout, heartbeat_timeout) = if enable_timeout {
let max_timeout = Duration::from_secs(MAX_TIMEOUT_SECS);
@@ -290,14 +304,18 @@ fn log_command(
let stdout = lines(BufReader::new(stdout)).map({
let logger = logger.clone();
move |line| {
slog_info!(logger, "blam! {}", line);
if !hide_output {
slog_info!(logger, "blam! {}", line);
}
line
}
});
let stderr = lines(BufReader::new(stderr)).map({
let logger = logger.clone();
move |line| {
slog_info!(logger, "kablam! {}", line);
if !hide_output {
slog_info!(logger, "kablam! {}", line);
}
line
}
});
View
@@ -79,6 +79,8 @@ fn run_ex_inner<DB: WriteResults + Sync>(
let result = if config.is_broken(&task.krate) {
TestResult::BuildFail
} else if let ErrorKind::OverrideResult(res) = e.kind() {
*res
} else {
TestResult::Error
};
View
@@ -3,7 +3,7 @@ use crates::Crate;
use dirs::{EXPERIMENT_DIR, TEST_SOURCE_DIR};
use errors::*;
use experiments::Experiment;
use results::WriteResults;
use results::{TestResult, WriteResults};
use run::RunCommand;
use runner::toml_frobber::TomlFrobber;
use std::fs;
@@ -92,6 +92,21 @@ pub(super) fn with_frobbed_toml(ex: &Experiment, krate: &Crate, path: &Path) ->
Ok(())
}
pub(super) fn validate_manifest(ex: &Experiment, krate: &Crate, tc: &Toolchain) -> Result<()> {
info!("validating manifest of {} on toolchain {}", krate, tc);
with_work_crate(ex, tc, krate, |path| {
RunCommand::new(CARGO.toolchain(tc))
.args(&["read-manifest", "--manifest-path", "Cargo.toml"])
.cd(path)
.hide_output(true)
.run()
.chain_err(|| format!("invalid syntax in {}'s Cargo.toml", krate))
.chain_err(|| ErrorKind::OverrideResult(TestResult::BuildFail))?;
Ok(())
})
}
fn lockfile_dir(ex_name: &str) -> PathBuf {
EXPERIMENT_DIR.join(ex_name).join("lockfiles")
}
View
@@ -5,7 +5,7 @@ use experiments::Experiment;
use results::{TestResult, WriteResults};
use runner::test;
use std::fmt;
use toolchain::{Toolchain, MAIN_TOOLCHAIN};
use toolchain::Toolchain;
use utils;
pub(super) enum TaskStep {
@@ -131,8 +131,9 @@ impl Task {
}
::runner::prepare::frob_toml(ex, &self.krate)?;
::runner::prepare::capture_lockfile(config, ex, &self.krate, &MAIN_TOOLCHAIN)?;
::runner::prepare::fetch_crate_deps(config, ex, &self.krate, &MAIN_TOOLCHAIN)?;
::runner::prepare::validate_manifest(ex, &self.krate, &ex.toolchains[0])?;
::runner::prepare::capture_lockfile(config, ex, &self.krate, &ex.toolchains[0])?;
::runner::prepare::fetch_crate_deps(config, ex, &self.krate, &ex.toolchains[0])?;
Ok(())
}
@@ -30,6 +30,21 @@
],
"url": "https://github.com/rust-lang-nursery/crater/tree/master/local-crates/beta-regression"
},
{
"name": "broken-cargotoml (local)",
"res": "SameBuildFail",
"runs": [
{
"log": "stable/local/broken-cargotoml",
"res": "BuildFail"
},
{
"log": "beta/local/broken-cargotoml",
"res": "BuildFail"
}
],
"url": "https://github.com/rust-lang-nursery/crater/tree/master/local-crates/broken-cargotoml"
},
{
"name": "build-fail (local)",
"res": "SameBuildFail",

0 comments on commit c2fcf3a

Please sign in to comment.