mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 10:19:02 +00:00
fix tests
This commit is contained in:
@@ -408,7 +408,7 @@ fn detect_installed_program(log: &log::Logger, quality: Quality) -> io::Result<V
|
|||||||
let target: PathBuf = [dir, name].iter().collect();
|
let target: PathBuf = [dir, name].iter().collect();
|
||||||
match std::fs::canonicalize(&target) {
|
match std::fs::canonicalize(&target) {
|
||||||
Ok(m) if m == current_exe => continue,
|
Ok(m) if m == current_exe => continue,
|
||||||
Ok(_) => {},
|
Ok(_) => {}
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -438,18 +438,13 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn make_fake_vscode_install(path: &Path, quality: options::Quality) {
|
fn make_fake_vscode_install(path: &Path) {
|
||||||
let bin = DESKTOP_CLI_RELATIVE_PATH
|
let bin = DESKTOP_CLI_RELATIVE_PATH
|
||||||
.split(',')
|
.split(',')
|
||||||
.next()
|
.next()
|
||||||
.expect("expected exe path");
|
.expect("expected exe path");
|
||||||
|
|
||||||
let binary_file_path = if cfg!(target_os = "macos") {
|
let binary_file_path = path.join(bin);
|
||||||
path.join(format!("{}/{}", quality.get_macos_app_name(), bin))
|
|
||||||
} else {
|
|
||||||
path.join(bin)
|
|
||||||
};
|
|
||||||
|
|
||||||
let parent_dir_path = binary_file_path.parent().expect("expected parent path");
|
let parent_dir_path = binary_file_path.parent().expect("expected parent path");
|
||||||
|
|
||||||
create_dir_all(parent_dir_path).expect("expected to create parent dir");
|
create_dir_all(parent_dir_path).expect("expected to create parent dir");
|
||||||
@@ -462,8 +457,8 @@ mod tests {
|
|||||||
|
|
||||||
fn make_multiple_vscode_install() -> tempfile::TempDir {
|
fn make_multiple_vscode_install() -> tempfile::TempDir {
|
||||||
let dir = tempfile::tempdir().expect("expected to make temp dir");
|
let dir = tempfile::tempdir().expect("expected to make temp dir");
|
||||||
make_fake_vscode_install(&dir.path().join("desktop/stable"), options::Quality::Stable);
|
make_fake_vscode_install(&dir.path().join("desktop/stable"));
|
||||||
make_fake_vscode_install(&dir.path().join("desktop/1.68.2"), options::Quality::Stable);
|
make_fake_vscode_install(&dir.path().join("desktop/1.68.2"));
|
||||||
dir
|
dir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,17 +563,17 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_gets_entrypoint() {
|
async fn test_gets_entrypoint() {
|
||||||
let dir = make_multiple_vscode_install();
|
let dir = make_multiple_vscode_install();
|
||||||
let lp = LauncherPaths::new_without_replacements(dir.path().to_owned());
|
|
||||||
let vm = CodeVersionManager::new(log::Logger::test(), &lp, Platform::LinuxARM64);
|
|
||||||
|
|
||||||
assert!(vm
|
assert!(CodeVersionManager::get_entrypoint_for_install_dir(
|
||||||
.try_get_entrypoint(&RequestedVersion::Quality(options::Quality::Stable))
|
&dir.path().join("desktop").join("stable")
|
||||||
.await
|
)
|
||||||
.is_some());
|
.await
|
||||||
|
.is_some());
|
||||||
|
|
||||||
assert!(vm
|
assert!(
|
||||||
.try_get_entrypoint(&RequestedVersion::Quality(options::Quality::Exploration))
|
CodeVersionManager::get_entrypoint_for_install_dir(&dir.path().join("invalid"))
|
||||||
.await
|
.await
|
||||||
.is_none());
|
.is_none()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user