aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs24
-rw-r--r--crates/shirabe/src/installer/library_installer.rs26
-rw-r--r--crates/shirabe/src/package/handle.rs9
-rw-r--r--crates/shirabe/src/util/auth_helper.rs16
4 files changed, 54 insertions, 21 deletions
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index bea2b20..80ce6f9 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -332,7 +332,7 @@ impl ZipDownloader {
}
}
- let extract_result = zip_archive.extract_to(path);
+ let extract_result = zip_archive.extract_to(path)?;
if extract_result {
zip_archive.close();
@@ -393,6 +393,28 @@ impl ZipDownloader {
),
}
}
+
+ /// For testing only. Mirrors the test's `setPrivateProperty('hasZipArchive', ...)` reflection on
+ /// the `ZipDownloader::$hasZipArchive` static.
+ pub fn __set_has_zip_archive(value: Option<bool>) {
+ *HAS_ZIP_ARCHIVE.lock().unwrap() = value;
+ }
+
+ /// For testing only. Mirrors the test's `setPrivateProperty('isWindows', ...)` reflection.
+ pub fn __set_is_windows(value: Option<bool>) {
+ *IS_WINDOWS.lock().unwrap() = value;
+ }
+
+ /// For testing only. Mirrors the test's `setPrivateProperty('unzipCommands', ...)` reflection.
+ pub fn __set_unzip_commands(value: Option<Vec<Vec<String>>>) {
+ *UNZIP_COMMANDS.lock().unwrap() = value;
+ }
+
+ /// For testing only. Mirrors the test's `setPrivateProperty('zipArchiveObject', $zipArchive, $obj)`
+ /// reflection on the instance's `$zipArchiveObject` property.
+ pub fn __set_zip_archive_object(&mut self, value: Option<ZipArchive>) {
+ self.zip_archive_object = value;
+ }
}
impl ArchiveDownloader for ZipDownloader {
diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs
index d2f222e..d716814 100644
--- a/crates/shirabe/src/installer/library_installer.rs
+++ b/crates/shirabe/src/installer/library_installer.rs
@@ -63,21 +63,23 @@ impl LibraryInstaller {
Some("/"),
);
let binary_installer = binary_installer.unwrap_or_else(|| {
- BinaryInstaller::new(
- io.clone(),
- rtrim(
- &composer_ref
- .get_config()
- .borrow_mut()
- .get_str("bin-dir")
- .unwrap_or_default(),
- Some("/"),
- ),
- composer_ref
+ let bin_dir = rtrim(
+ &composer_ref
.get_config()
.borrow_mut()
- .get_str("bin-compat")
+ .get_str("bin-dir")
.unwrap_or_default(),
+ Some("/"),
+ );
+ let bin_compat = composer_ref
+ .get_config()
+ .borrow_mut()
+ .get_str("bin-compat")
+ .unwrap_or_default();
+ BinaryInstaller::new(
+ io.clone(),
+ bin_dir,
+ bin_compat,
Some(filesystem.clone()),
Some(vendor_dir.clone()),
)
diff --git a/crates/shirabe/src/package/handle.rs b/crates/shirabe/src/package/handle.rs
index 8a6ed83..9405692 100644
--- a/crates/shirabe/src/package/handle.rs
+++ b/crates/shirabe/src/package/handle.rs
@@ -1231,6 +1231,15 @@ macro_rules! impl_real_package_test_setters {
.expect("real package handle invariant")
.set_dist_sha1_checksum(sha1checksum);
}
+
+ /// For testing only: mirrors PHP `Package::setTargetDir`.
+ pub fn __set_target_dir(&self, target_dir: Option<String>) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_target_dir(target_dir);
+ }
}
};
}
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index 0b1620d..f386b1e 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -534,14 +534,14 @@ impl AuthHelper {
true,
) && in_array(
PhpMixed::String(origin.to_string()),
- &PhpMixed::List(
- self.config
- .borrow_mut()
- .get("gitlab-domains")
- .as_array()
- .map(|a| a.values().map(|v| v.clone()).collect())
- .unwrap_or_default(),
- ),
+ &PhpMixed::List({
+ let gitlab_domains = self.config.borrow_mut().get("gitlab-domains");
+ match &gitlab_domains {
+ PhpMixed::List(l) => l.clone(),
+ PhpMixed::Array(a) => a.values().cloned().collect(),
+ _ => vec![],
+ }
+ }),
true,
) {
if password == "oauth2" {