Skip to content

Commit

Permalink
Fixes failing tests.
Browse files Browse the repository at this point in the history
* 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`.
* Changed `emptydir` to `customdir.join("custom-1")` to avoid directory
  structure error and pass `rustup_failed_search_path`.
  • Loading branch information
theindigamer committed Apr 26, 2017
1 parent c28b805 commit b459685
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/rustup-mock/src/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 693,8 @@ fn mock_bin(_name: &str, version: &str, version_hash: &str) -> Vec<u8> {
fn create_custom_toolchains(customdir: &Path) {
let ref dir = customdir.join("custom-1/bin");
fs::create_dir_all(dir).unwrap();
let ref dir = customdir.join("custom-1/lib");
fs::create_dir_all(dir).unwrap();
let rustc = mock_bin("rustc", "1.0.0", "hash-c-1");
let ref path = customdir.join(format!("custom-1/bin/rustc{}", EXE_SUFFIX));
let mut file = File::create(path).unwrap();
Expand All @@ -701,6 703,8 @@ fn create_custom_toolchains(customdir: &Path) {

let ref dir = customdir.join("custom-2/bin");
fs::create_dir_all(dir).unwrap();
let ref dir = customdir.join("custom-2/lib");
fs::create_dir_all(dir).unwrap();
let rustc = mock_bin("rustc", "1.0.0", "hash-c-2");
let ref path = customdir.join(format!("custom-2/bin/rustc{}", EXE_SUFFIX));
let mut file = File::create(path).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 273,18 @@ impl<'a> Toolchain<'a> {
}

pub fn install_from_dir(&self, src: &Path, link: bool) -> Result<()> {
try!(self.ensure_custom());

let mut pathbuf = PathBuf::from(src);

pathbuf.push("lib");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.pop();
pathbuf.push("bin");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.push("rustc");
pathbuf.push(format!("rustc{}", EXE_SUFFIX));
try!(utils::assert_is_file(&pathbuf));

try!(self.ensure_custom());

if link {
try!(self.install(InstallMethod::Link(&try!(utils::to_absolute(src)))));
} else {
Expand Down
7 changes: 4 additions & 3 deletions tests/cli-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 306,11 @@ fn rustup_failed_path_search() {
let ref tool_path = config.exedir.join(&format!("fake_proxy{}", EXE_SUFFIX));
utils::hardlink_file(rustup_path, tool_path).expect("Failed to create fake proxy for test");

expect_ok(config, &["rustup", "toolchain", "link", "empty", &config.emptydir.to_string_lossy()]);
let broken = &["rustup", "run", "empty", "fake_proxy"];
expect_ok(config, &["rustup", "toolchain", "link", "custom",
&config.customdir.join("custom-1").to_string_lossy()]);
let broken = &["rustup", "run", "custom", "fake_proxy"];
expect_err(config, broken, &format!(
"toolchain 'empty' does not have the binary `fake_proxy{}`", EXE_SUFFIX
"toolchain 'custom' does not have the binary `fake_proxy{}`", EXE_SUFFIX
));

// Hardlink will be automatically cleaned up by test setup code
Expand Down

0 comments on commit b459685

Please sign in to comment.