diff --git a/docs/bot-usage.md b/docs/bot-usage.md index 84399e87..3a75c917 100644 --- a/docs/bot-usage.md +++ b/docs/bot-usage.md @@ -149,6 +149,8 @@ You can specify a toolchain using a rustup name or `branch#sha`, and use the following flags: * `+rustflags={flags}`: sets the `RUSTFLAGS` environment variable to `{flags}` when building with this toolchain, e.g. `+rustflags=-Zverbose` +* `+cargoflags={flags}`: appends the given `{flags}` to the Cargo command specified + by the experiment mode, e.g. `+cargoflags=-Zavoid-dev-deps` * `+patch={crate_name}={git_repo_url}={branch}`: patches all crates built by this toolchain to resolve the given crate from the given git repository and branch. diff --git a/src/runner/test.rs b/src/runner/test.rs index 1ac0a24d..17ddcfdb 100644 --- a/src/runner/test.rs +++ b/src/runner/test.rs @@ -84,6 +84,11 @@ fn run_cargo( check_errors: bool, local_packages_id: &HashSet, ) -> Fallible<()> { + let mut args = args.to_vec(); + if let Some(ref tc_cargoflags) = ctx.toolchain.cargoflags { + args.extend(tc_cargoflags.split(' ')); + } + let mut rustflags = format!("--cap-lints={}", ctx.experiment.cap_lints.to_str()); if let Some(ref tc_rustflags) = ctx.toolchain.rustflags { rustflags.push(' '); @@ -158,7 +163,7 @@ fn run_cargo( let mut command = build_env .cargo() - .args(args) + .args(&args) .env("CARGO_INCREMENTAL", "0") .env("RUST_BACKTRACE", "full") .env(rustflags_env, rustflags); diff --git a/src/server/routes/webhooks/commands.rs b/src/server/routes/webhooks/commands.rs index 7299c2e3..9f972234 100644 --- a/src/server/routes/webhooks/commands.rs +++ b/src/server/routes/webhooks/commands.rs @@ -72,12 +72,14 @@ pub fn run( detected_start = Some(Toolchain { source: RustwideToolchain::ci(&build.base_sha, false), rustflags: None, + cargoflags: None, ci_try: false, patches: Vec::new(), }); detected_end = Some(Toolchain { source: RustwideToolchain::ci(&build.merge_sha, false), rustflags: None, + cargoflags: None, ci_try: true, patches: Vec::new(), }); diff --git a/src/toolchain.rs b/src/toolchain.rs index bc87d6be..093e700c 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -10,6 +10,7 @@ lazy_static! { pub(crate) static ref MAIN_TOOLCHAIN: Toolchain = Toolchain { source: RustwideToolchain::dist("stable"), rustflags: None, + cargoflags: None, ci_try: false, patches: Vec::new(), }; @@ -18,6 +19,7 @@ lazy_static! { pub(crate) static ref TEST_TOOLCHAIN: Toolchain = Toolchain { source: RustwideToolchain::dist("beta"), rustflags: None, + cargoflags: None, ci_try: false, patches: Vec::new(), }; @@ -27,6 +29,7 @@ lazy_static! { pub struct Toolchain { pub source: RustwideToolchain, pub rustflags: Option, + pub cargoflags: Option, pub ci_try: bool, pub patches: Vec, } @@ -65,6 +68,10 @@ impl fmt::Display for Toolchain { write!(f, "+rustflags={}", flag)?; } + if let Some(ref flag) = self.cargoflags { + write!(f, "+cargoflags={}", flag)?; + } + for patch in self.patches.iter() { write!(f, "+patch={}", patch)?; } @@ -114,6 +121,7 @@ impl FromStr for Toolchain { }; let mut rustflags = None; + let mut cargoflags = None; let mut patches: Vec = vec![]; for part in parts { if let Some(equal_idx) = part.find('=') { @@ -126,6 +134,7 @@ impl FromStr for Toolchain { match flag { "rustflags" => rustflags = Some(value), + "cargoflags" => cargoflags = Some(value), "patch" => patches.push(value.parse()?), unknown => return Err(ToolchainParseError::InvalidFlag(unknown.to_string())), } @@ -137,6 +146,7 @@ impl FromStr for Toolchain { Ok(Toolchain { source, rustflags, + cargoflags, ci_try, patches, }) @@ -189,14 +199,25 @@ mod tests { test_from_str!($str => Toolchain { source: $source, rustflags: None, + cargoflags: None, ci_try: $ci_try, patches: Vec::new(), }); - // Test parsing with flags + // Test parsing with rustflags test_from_str!(concat!($str, "+rustflags=foo bar") => Toolchain { source: $source, rustflags: Some("foo bar".to_string()), + cargoflags: None, + ci_try: $ci_try, + patches: Vec::new(), + }); + + // Test parsing with cargoflags + test_from_str!(concat!($str, "+cargoflags=foo bar") => Toolchain { + source: $source, + rustflags: None, + cargoflags: Some("foo bar".to_string()), ci_try: $ci_try, patches: Vec::new(), }); @@ -205,6 +226,7 @@ mod tests { test_from_str!(concat!($str, "+patch=example=https://git.example.com/some/repo=master") => Toolchain { source: $source, rustflags: None, + cargoflags: None, ci_try: $ci_try, patches: vec![CratePatch { name: "example".to_string(), @@ -217,6 +239,7 @@ mod tests { test_from_str!(concat!($str, "+rustflags=foo bar+patch=example=https://git.example.com/some/repo=master") => Toolchain { source: $source, rustflags: Some("foo bar".to_string()), + cargoflags: None, ci_try: $ci_try, patches: vec![CratePatch { name: "example".to_string(),