Skip to content

Commit d3022e2

Browse files
author
Pietro Albini
authored
Merge pull request #22 from Freax13/remove-cargo-config
2 parents 2b0d92b + ca65505 commit d3022e2

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
### Changed
9+
10+
- The file `.cargo/config` will be removed before starting the build
11+
812
## [0.6.1] - 2020-05-04
913

1014
### Fixed

src/prepare.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::cmd::Command;
22
use crate::{build::CratePatch, Crate, Toolchain, Workspace};
33
use failure::{Error, Fail, ResultExt};
44
use log::info;
5+
use std::fs::remove_file;
56
use std::path::Path;
67
use toml::{
78
value::{Array, Table},
@@ -38,6 +39,7 @@ impl<'a> Prepare<'a> {
3839
pub(crate) fn prepare(&mut self) -> Result<(), Error> {
3940
self.krate.copy_source_to(self.workspace, self.source_dir)?;
4041
self.validate_manifest()?;
42+
self.remove_cargo_config()?;
4143
self.tweak_toml()?;
4244
self.capture_lockfile(false)?;
4345
self.fetch_deps()?;
@@ -68,6 +70,15 @@ impl<'a> Prepare<'a> {
6870
Ok(())
6971
}
7072

73+
fn remove_cargo_config(&self) -> Result<(), Error> {
74+
let path = self.source_dir.join(".cargo").join("config");
75+
if path.exists() {
76+
remove_file(path.clone())?;
77+
info!("removed {}", path.as_path().display());
78+
}
79+
Ok(())
80+
}
81+
7182
fn tweak_toml(&self) -> Result<(), Error> {
7283
let path = self.source_dir.join("Cargo.toml");
7384
let mut tweaker = TomlTweaker::new(&self.krate, &path, &self.patches)?;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
target = "invalid-test-target"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "cargo-config"
3+
version = "0.1.0"
4+
authors = ["Tom Dohrmann <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

tests/buildtest/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ fn test_sandbox_oom() {
7373
});
7474
}
7575

76+
#[test]
77+
fn test_cargo_config() {
78+
runner::run("cargo-config", |run| {
79+
run.build(SandboxBuilder::new().enable_networking(false), |build| {
80+
let storage = rustwide::logging::LogStorage::new(LevelFilter::Info);
81+
rustwide::logging::capture(&storage, || -> Result<_, Error> {
82+
build.cargo().args(&["run"]).run()?;
83+
Ok(())
84+
})?;
85+
Ok(())
86+
})?;
87+
Ok(())
88+
});
89+
}
90+
7691
test_prepare_error!(
7792
test_missing_cargotoml,
7893
"missing-cargotoml",

0 commit comments

Comments
 (0)