Skip to content

Commit 0d23afb

Browse files
author
theindigamer
committed
Fixes failing tests.
* Rearranges error-checking in `install_from_dir` to pass the tests `custom_invalid_names` and `custom_invalid_names_with_archive_dates`. * Adds subdirectory `lib` to custom directories to pass the tests `custom_toolchain_cargo_fallback_proxy` and `custom_toolchain_cargo_fallback_run`. * Expect a missing directory error for `lib` in `emptydir`to pass `rustup_failed_search_path`.
1 parent c28b805 commit 0d23afb

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/rustup-mock/src/clitools.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ fn mock_bin(_name: &str, version: &str, version_hash: &str) -> Vec<u8> {
693693
fn create_custom_toolchains(customdir: &Path) {
694694
let ref dir = customdir.join("custom-1/bin");
695695
fs::create_dir_all(dir).unwrap();
696+
let ref dir = customdir.join("custom-1/lib");
697+
fs::create_dir_all(dir).unwrap();
696698
let rustc = mock_bin("rustc", "1.0.0", "hash-c-1");
697699
let ref path = customdir.join(format!("custom-1/bin/rustc{}", EXE_SUFFIX));
698700
let mut file = File::create(path).unwrap();
@@ -701,6 +703,8 @@ fn create_custom_toolchains(customdir: &Path) {
701703

702704
let ref dir = customdir.join("custom-2/bin");
703705
fs::create_dir_all(dir).unwrap();
706+
let ref dir = customdir.join("custom-2/lib");
707+
fs::create_dir_all(dir).unwrap();
704708
let rustc = mock_bin("rustc", "1.0.0", "hash-c-2");
705709
let ref path = customdir.join(format!("custom-2/bin/rustc{}", EXE_SUFFIX));
706710
let mut file = File::create(path).unwrap();

src/rustup/toolchain.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ impl<'a> Toolchain<'a> {
273273
}
274274

275275
pub fn install_from_dir(&self, src: &Path, link: bool) -> Result<()> {
276+
try!(self.ensure_custom());
277+
278+
if link {
279+
try!(self.install(InstallMethod::Link(&try!(utils::to_absolute(src)))));
280+
} else {
281+
try!(self.install(InstallMethod::Copy(src)));
282+
}
283+
276284
let mut pathbuf = PathBuf::from(src);
277285

278286
pathbuf.push("lib");
@@ -283,14 +291,6 @@ impl<'a> Toolchain<'a> {
283291
pathbuf.push("rustc");
284292
try!(utils::assert_is_file(&pathbuf));
285293

286-
try!(self.ensure_custom());
287-
288-
if link {
289-
try!(self.install(InstallMethod::Link(&try!(utils::to_absolute(src)))));
290-
} else {
291-
try!(self.install(InstallMethod::Copy(src)));
292-
}
293-
294294
Ok(())
295295
}
296296

tests/cli-misc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ fn rustup_failed_path_search() {
306306
let ref tool_path = config.exedir.join(&format!("fake_proxy{}", EXE_SUFFIX));
307307
utils::hardlink_file(rustup_path, tool_path).expect("Failed to create fake proxy for test");
308308

309-
expect_ok(config, &["rustup", "toolchain", "link", "empty", &config.emptydir.to_string_lossy()]);
309+
expect_err(config,
310+
&["rustup", "toolchain", "link", "empty", &config.emptydir.to_string_lossy()],
311+
&format!("error: not a directory: '{}'", config.emptydir.join("lib").display()));
310312
let broken = &["rustup", "run", "empty", "fake_proxy"];
311313
expect_err(config, broken, &format!(
312314
"toolchain 'empty' does not have the binary `fake_proxy{}`", EXE_SUFFIX

0 commit comments

Comments
 (0)