Skip to content

Commit da38429

Browse files
committed
Remove rust-toolchain before running builds
This avoids running with the wrong version of the toolchain.
1 parent 5347594 commit da38429

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/prepare.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'a> Prepare<'a> {
3838
pub(crate) fn prepare(&mut self) -> Result<(), Error> {
3939
self.krate.copy_source_to(self.workspace, self.source_dir)?;
4040
self.validate_manifest()?;
41-
self.remove_cargo_config()?;
41+
self.remove_override_files()?;
4242
self.tweak_toml()?;
4343
self.capture_lockfile(false)?;
4444
self.fetch_deps()?;
@@ -69,11 +69,17 @@ impl<'a> Prepare<'a> {
6969
Ok(())
7070
}
7171

72-
fn remove_cargo_config(&self) -> Result<(), Error> {
73-
let path = self.source_dir.join(".cargo").join("config");
74-
if path.exists() {
75-
crate::utils::remove_file(&path)?;
76-
info!("removed {}", path.display());
72+
fn remove_override_files(&self) -> Result<(), Error> {
73+
let paths = [
74+
&Path::new(".cargo").join("config"),
75+
Path::new("rust-toolchain"),
76+
];
77+
for path in &paths {
78+
let path = self.source_dir.join(path);
79+
if path.exists() {
80+
crate::utils::remove_file(&path)?;
81+
info!("removed {}", path.display());
82+
}
7783
}
7884
Ok(())
7985
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

tests/buildtest/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,18 @@ fn test_sandbox_oom() {
8383
}
8484

8585
#[test]
86-
fn test_cargo_config() {
86+
fn test_override_files() {
8787
runner::run("cargo-config", |run| {
8888
run.build(SandboxBuilder::new().enable_networking(false), |build| {
8989
let storage = rustwide::logging::LogStorage::new(LevelFilter::Info);
9090
rustwide::logging::capture(&storage, || -> Result<_, Error> {
91-
build.cargo().args(&["run"]).run()?;
91+
build.cargo().args(&["--version"]).run()?;
9292
Ok(())
9393
})?;
94+
let output = storage.to_string();
95+
assert!(output.contains("cargo 1."));
96+
assert!(!output.contains("1.0.0"));
97+
build.cargo().args(&["run"]).run()?;
9498
Ok(())
9599
})?;
96100
Ok(())

0 commit comments

Comments
 (0)