diff options
Diffstat (limited to 'crates/shirabe/tests/downloader')
9 files changed, 102 insertions, 93 deletions
diff --git a/crates/shirabe/tests/downloader/archive_downloader_test.rs b/crates/shirabe/tests/downloader/archive_downloader_test.rs index fedbae9e..77569e97 100644 --- a/crates/shirabe/tests/downloader/archive_downloader_test.rs +++ b/crates/shirabe/tests/downloader/archive_downloader_test.rs @@ -15,8 +15,6 @@ use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe::util::HttpDownloader; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; /// ref: TestCase::getPackage (default class CompletePackage) fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { @@ -27,7 +25,8 @@ fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { /// ref: ArchiveDownloaderTest::getArchiveDownloaderMock (the inherited getFileName/processUrl /// live on FileDownloader, so the concrete downloader is built directly). fn get_archive_downloader(vendor_dir: Option<&str>) -> FileDownloader { - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut config = Config::new(false, None); if let Some(vendor_dir) = vendor_dir { @@ -40,9 +39,9 @@ fn get_archive_downloader(vendor_dir: Option<&str>) -> FileDownloader { merged.insert("config".to_string(), PhpMixed::Array(config_options)); config.merge(&merged, "test"); } - let config = Rc::new(RefCell::new(config)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config.clone(), IndexMap::new(), diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs index 3b259c86..f596beed 100644 --- a/crates/shirabe/tests/downloader/download_manager_test.rs +++ b/crates/shirabe/tests/downloader/download_manager_test.rs @@ -8,8 +8,6 @@ use shirabe::io::IOInterface; use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe_php_shim::{PhpMixed, RuntimeException}; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; // PHP mocks `Composer\Downloader\DownloaderInterface` with getMockBuilder. mockall::mock! { @@ -91,7 +89,7 @@ fn make_package(name: &str, is_dev: bool) -> PackageInterfaceHandle { } /// ref: DownloadManagerTest::createDownloaderMock -fn create_downloader_mock() -> Rc<RefCell<dyn DownloaderInterface>> { +fn create_downloader_mock() -> std::rc::Rc<std::cell::RefCell<dyn DownloaderInterface>> { as_dyn(MockDownloader::new()) } @@ -107,12 +105,14 @@ fn downloader_mock(installation_source: &str) -> MockDownloader { downloader } -fn as_dyn(downloader: MockDownloader) -> Rc<RefCell<dyn DownloaderInterface>> { - Rc::new(RefCell::new(downloader)) as Rc<RefCell<dyn DownloaderInterface>> +fn as_dyn(downloader: MockDownloader) -> std::rc::Rc<std::cell::RefCell<dyn DownloaderInterface>> { + std::rc::Rc::new(std::cell::RefCell::new(downloader)) + as std::rc::Rc<std::cell::RefCell<dyn DownloaderInterface>> } fn create_manager() -> DownloadManager { - let io = Rc::new(RefCell::new(IOStub::new())) as Rc<RefCell<dyn IOInterface>>; + let io = std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc<std::cell::RefCell<dyn IOInterface>>; DownloadManager::new(io, false, None) } @@ -122,7 +122,7 @@ fn test_set_get_downloader() { let mut manager = create_manager(); manager.set_downloader("test", downloader.clone()); - assert!(Rc::ptr_eq( + assert!(std::rc::Rc::ptr_eq( &downloader, &manager.get_downloader("test").unwrap() )); @@ -172,7 +172,7 @@ fn test_get_downloader_for_correctly_installed_dist_package() { .get_downloader_for_package(package) .unwrap() .unwrap(); - assert!(Rc::ptr_eq(&downloader, &result)); + assert!(std::rc::Rc::ptr_eq(&downloader, &result)); } // The LogicException message uses get_class($downloader); the equivalent @@ -209,7 +209,7 @@ fn test_get_downloader_for_correctly_installed_source_package() { .get_downloader_for_package(package) .unwrap() .unwrap(); - assert!(Rc::ptr_eq(&downloader, &result)); + assert!(std::rc::Rc::ptr_eq(&downloader, &result)); } // See test_get_downloader_for_incorrectly_installed_dist_package: the LogicException diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs index ead577e2..2fd7d52e 100644 --- a/crates/shirabe/tests/downloader/file_downloader_test.rs +++ b/crates/shirabe/tests/downloader/file_downloader_test.rs @@ -20,8 +20,6 @@ use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, UnexpectedValueException, }; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; /// ref: TestCase::getPackage (default class CompletePackage) @@ -38,14 +36,16 @@ fn run<F: std::future::Future>(future: F) -> F::Output { } /// ref: TestCase::getConfig -fn get_config(config_options: IndexMap<String, PhpMixed>) -> Rc<RefCell<Config>> { +fn get_config( + config_options: IndexMap<String, PhpMixed>, +) -> std::rc::Rc<std::cell::RefCell<Config>> { let mut config = Config::new(false, None); if !config_options.is_empty() { let mut merged: IndexMap<String, PhpMixed> = IndexMap::new(); merged.insert("config".to_string(), PhpMixed::Array(config_options)); config.merge(&merged, "test"); } - Rc::new(RefCell::new(config)) + std::rc::Rc::new(std::cell::RefCell::new(config)) } /// The PHP `getDownloader` builds a HttpDownloader mock whose `addCopy` resolves to a 200 Response @@ -53,15 +53,16 @@ fn get_config(config_options: IndexMap<String, PhpMixed>) -> Rc<RefCell<Config>> /// handler returning a 200/`file~` response for any URL. The mock never writes the destination file, /// so the verification step throws "could not be saved to" exactly as in PHP. fn get_downloader( - io: Option<Rc<RefCell<dyn IOInterface>>>, - config: Option<Rc<RefCell<Config>>>, + io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>, + config: Option<std::rc::Rc<std::cell::RefCell<Config>>>, ) -> ( FileDownloader, - Rc<RefCell<HttpDownloader>>, + std::rc::Rc<std::cell::RefCell<HttpDownloader>>, crate::http_downloader_mock::HttpDownloaderMockGuard, ) { - let io = io.unwrap_or_else(|| Rc::new(RefCell::new(NullIO::new()))); - let config = config.unwrap_or_else(|| Rc::new(RefCell::new(Config::new(false, None)))); + let io = io.unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(NullIO::new()))); + let config = config + .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None)))); let (http_downloader, guard) = get_http_downloader_mock( Vec::new(), @@ -213,14 +214,15 @@ fn test_cache_garbage_collection_is_called() { // The PHP Cache mock forces gcIsNecessary() true and records the single gc() call; the CacheMock // seam plays both roles here. let tmp_dir = TempDir::new().unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut cache = Cache::new(io, tmp_dir.path().to_str().unwrap(), None, None, false); cache.__set_mock(CacheMock { gc_is_necessary: Some(true), gc_calls: Some(Vec::new()), ..Default::default() }); - let cache = Rc::new(RefCell::new(cache)); + let cache = std::rc::Rc::new(std::cell::RefCell::new(cache)); let (http_downloader, _guard) = get_http_downloader_mock( Vec::new(), @@ -232,7 +234,8 @@ fn test_cache_garbage_collection_is_called() { }, ); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let _downloader = FileDownloader::new( io, config, @@ -334,7 +337,7 @@ fn test_downgrade_shows_appropriate_message() { normalize_path_identity: true, ..Default::default() }); - let filesystem = Rc::new(RefCell::new(filesystem)); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(filesystem)); let (http_downloader, _guard) = get_http_downloader_mock( Vec::new(), @@ -346,7 +349,7 @@ fn test_downgrade_shows_appropriate_message() { }, ); - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = io_mock.clone(); let mut downloader = FileDownloader::new( io, config, diff --git a/crates/shirabe/tests/downloader/fossil_downloader_test.rs b/crates/shirabe/tests/downloader/fossil_downloader_test.rs index 912b4b47..eed3d7fb 100644 --- a/crates/shirabe/tests/downloader/fossil_downloader_test.rs +++ b/crates/shirabe/tests/downloader/fossil_downloader_test.rs @@ -12,8 +12,6 @@ use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::{Filesystem, FilesystemMock}; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; fn run<F: std::future::Future>(future: F) -> F::Output { @@ -67,20 +65,23 @@ fn get_package(source_reference: Option<&str>, source_url: Option<&str>) -> Pack /// ref: FossilDownloaderTest::getDownloaderMock fn get_downloader_mock( - io: Option<Rc<RefCell<dyn IOInterface>>>, + io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>, config: Option<Config>, - process: Rc<RefCell<ProcessExecutor>>, - filesystem: Option<Rc<RefCell<Filesystem>>>, + process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, + filesystem: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> FossilDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc<RefCell<dyn IOInterface>>); + let io = io.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc<std::cell::RefCell<dyn IOInterface>> + }); // ref: getConfig(['secure-http' => false]) - let config = Rc::new(RefCell::new(config.unwrap_or_else(|| { + let config = std::rc::Rc::new(std::cell::RefCell::new(config.unwrap_or_else(|| { ConfigStubBuilder::new() .with("secure-http", PhpMixed::Bool(false)) .build() }))); - let fs = filesystem.unwrap_or_else(|| Rc::new(RefCell::new(Filesystem::new(None)))); + let fs = filesystem + .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None)))); FossilDownloader::new(io, config, process, fs) } @@ -232,7 +233,7 @@ fn test_remove() { remove_directory_async_result: Some(true), ..Default::default() }); - let filesystem = Rc::new(RefCell::new(filesystem)); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(filesystem)); let mut downloader = get_downloader_mock(None, None, process, Some(filesystem.clone())); run(async { diff --git a/crates/shirabe/tests/downloader/git_downloader_test.rs b/crates/shirabe/tests/downloader/git_downloader_test.rs index 7e98cae8..0d8af4e9 100644 --- a/crates/shirabe/tests/downloader/git_downloader_test.rs +++ b/crates/shirabe/tests/downloader/git_downloader_test.rs @@ -18,8 +18,6 @@ use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; fn run<F: std::future::Future>(future: F) -> F::Output { @@ -104,14 +102,16 @@ fn setup_config(config: Config) -> Config { /// ref: GitDownloaderTest::getDownloaderMock (defaults the IO/Config/Filesystem) fn get_downloader_mock( - io: Option<Rc<RefCell<dyn IOInterface>>>, + io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>, config: Option<Config>, - process: Rc<RefCell<ProcessExecutor>>, - filesystem: Option<Rc<RefCell<Filesystem>>>, + process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, + filesystem: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> GitDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc<RefCell<dyn IOInterface>>); - let config = Rc::new(RefCell::new(setup_config( + let io = io.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc<std::cell::RefCell<dyn IOInterface>> + }); + let config = std::rc::Rc::new(std::cell::RefCell::new(setup_config( config.unwrap_or_else(|| ConfigStubBuilder::new().build()), ))); GitDownloader::new(io, config, Some(process), filesystem) @@ -804,7 +804,7 @@ fn test_downgrade_shows_appropriate_message() { .borrow_mut() .expects(vec![Expectation::text_regex("{Downgrading .*}")], false) .unwrap(); - let io = io_mock.clone() as Rc<RefCell<dyn IOInterface>>; + let io = io_mock.clone() as std::rc::Rc<std::cell::RefCell<dyn IOInterface>>; let mut fs = Filesystem::new(None); fs.ensure_directory_exists(&format!("{}/.git", working_dir.path().to_string_lossy())) @@ -882,7 +882,7 @@ fn test_not_using_downgrading_with_references() { .borrow_mut() .expects(vec![Expectation::text_regex("{Upgrading .*}")], false) .unwrap(); - let io = io_mock.clone() as Rc<RefCell<dyn IOInterface>>; + let io = io_mock.clone() as std::rc::Rc<std::cell::RefCell<dyn IOInterface>>; let mut fs = Filesystem::new(None); fs.ensure_directory_exists(&format!("{}/.git", working_dir.path().to_string_lossy())) diff --git a/crates/shirabe/tests/downloader/hg_downloader_test.rs b/crates/shirabe/tests/downloader/hg_downloader_test.rs index e68dfc5e..d68812d8 100644 --- a/crates/shirabe/tests/downloader/hg_downloader_test.rs +++ b/crates/shirabe/tests/downloader/hg_downloader_test.rs @@ -10,8 +10,6 @@ use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::{Filesystem, FilesystemMock}; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; fn run<F: std::future::Future>(future: F) -> F::Output { @@ -69,17 +67,20 @@ fn get_package(source_reference: Option<&str>, source_url: Option<&str>) -> Pack /// returns null for everything; a default real `Config` resolves the only /// relevant key (`secure-http`) compatibly for the https URLs used here. fn get_downloader_mock( - io: Option<Rc<RefCell<dyn IOInterface>>>, + io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>, config: Option<Config>, - process: Rc<RefCell<ProcessExecutor>>, - filesystem: Option<Rc<RefCell<Filesystem>>>, + process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, + filesystem: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, ) -> HgDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc<RefCell<dyn IOInterface>>); - let config = Rc::new(RefCell::new( + let io = io.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc<std::cell::RefCell<dyn IOInterface>> + }); + let config = std::rc::Rc::new(std::cell::RefCell::new( config.unwrap_or_else(|| Config::new(false, None)), )); - let fs = filesystem.unwrap_or_else(|| Rc::new(RefCell::new(Filesystem::new(None)))); + let fs = filesystem + .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None)))); HgDownloader::new(io, config, process, fs) } @@ -224,7 +225,7 @@ fn test_remove() { remove_directory_async_result: Some(true), ..Default::default() }); - let filesystem = Rc::new(RefCell::new(filesystem)); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(filesystem)); let mut downloader = get_downloader_mock(None, None, process, Some(filesystem.clone())); run(async { diff --git a/crates/shirabe/tests/downloader/perforce_downloader_test.rs b/crates/shirabe/tests/downloader/perforce_downloader_test.rs index 70f28e10..13a818a6 100644 --- a/crates/shirabe/tests/downloader/perforce_downloader_test.rs +++ b/crates/shirabe/tests/downloader/perforce_downloader_test.rs @@ -14,8 +14,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; // A getMockBuilder('Composer\Util\Perforce') stand-in: the seam trait extracted from the @@ -83,13 +81,14 @@ fn test_init_perforce_instantiates_a_new_perforce_object() { // RepositoryInterface), so it cannot be held in a RepositoryInterfaceHandle. The package // is therefore built without a repository, yielding an empty repo config. let test_path = TempDir::new().unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(get_config(test_path.path()))); let package = make_package(None); let (process, _process_guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let fs = Rc::new(RefCell::new(Filesystem::new(None))); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); let mut downloader = PerforceDownloader::new(io, config, process, fs); downloader.init_perforce( @@ -102,11 +101,12 @@ fn test_init_perforce_instantiates_a_new_perforce_object() { #[test] fn test_init_perforce_does_nothing_if_perforce_already_set() { let test_path = TempDir::new().unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(get_config(test_path.path()))); let (process, _process_guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let fs = Rc::new(RefCell::new(Filesystem::new(None))); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); let mut downloader = PerforceDownloader::new(io, config, process, fs); // The already-set perforce only sees initializePath; the repository's getRepoConfig is @@ -147,11 +147,11 @@ fn do_install_workflow(source_ref: &'static str, expected_label: Option<String>) false, ) .unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = io_mock.clone(); + let config = std::rc::Rc::new(std::cell::RefCell::new(get_config(test_path.path()))); let (process, _process_guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let fs = Rc::new(RefCell::new(Filesystem::new(None))); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); let mut downloader = PerforceDownloader::new(io, config, process, fs); let mut perforce = MockPerforce::new(); diff --git a/crates/shirabe/tests/downloader/xz_downloader_test.rs b/crates/shirabe/tests/downloader/xz_downloader_test.rs index 358f8964..6d504313 100644 --- a/crates/shirabe/tests/downloader/xz_downloader_test.rs +++ b/crates/shirabe/tests/downloader/xz_downloader_test.rs @@ -14,8 +14,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; /// ref: TestCase::getPackage (default class CompletePackage) @@ -82,21 +80,24 @@ fn test_error_messages() { let dist_url = format!("file://{}", file!()); package.set_dist_url(Some(dist_url)); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut config_options: IndexMap<String, PhpMixed> = IndexMap::new(); config_options.insert( "vendor-dir".to_string(), PhpMixed::String(test_dir.to_string_lossy().into_owned()), ); - let config = Rc::new(RefCell::new(get_config(config_options, false))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let config = std::rc::Rc::new(std::cell::RefCell::new(get_config(config_options, false))); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config.clone(), IndexMap::new(), false, ))); - let filesystem = Rc::new(RefCell::new(Filesystem::new(None))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let mut downloader = XzDownloader::new( io, config, diff --git a/crates/shirabe/tests/downloader/zip_downloader_test.rs b/crates/shirabe/tests/downloader/zip_downloader_test.rs index 43e79160..0c9e7b88 100644 --- a/crates/shirabe/tests/downloader/zip_downloader_test.rs +++ b/crates/shirabe/tests/downloader/zip_downloader_test.rs @@ -15,8 +15,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::r#loop::Loop; use shirabe_php_shim::{PhpMixed, ZipArchive, ZipArchiveMock}; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; fn run<F: std::future::Future>(future: F) -> F::Output { @@ -28,9 +26,9 @@ fn run<F: std::future::Future>(future: F) -> F::Output { struct SetUp { test_dir: TempDir, - io: Rc<RefCell<dyn IOInterface>>, - config: Rc<RefCell<Config>>, - http_downloader: Rc<RefCell<HttpDownloader>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, + http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, package: PackageInterfaceHandle, filename: std::path::PathBuf, } @@ -44,10 +42,11 @@ struct SetUp { fn set_up() -> SetUp { let test_dir = TempDir::new().unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); - let config = Rc::new(RefCell::new(Config::new(false, None))); - let dl_config = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock( + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let dl_config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::__new_mock( io.clone(), dl_config, ))); @@ -94,8 +93,10 @@ impl Drop for TearDown { } fn make_downloader(set_up: &SetUp) -> ZipDownloader { - let filesystem = Rc::new(RefCell::new(Filesystem::new(None))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(set_up.io.clone())))); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + set_up.io.clone(), + )))); ZipDownloader::new( set_up.io.clone(), set_up.config.clone(), @@ -124,7 +125,8 @@ fn test_error_messages() { let test_dir = TempDir::new().unwrap(); let _tear_down = TearDown::new(test_dir.path().to_path_buf()); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); // $this->config->method('get')->with('vendor-dir')->willReturn($this->testDir) let mut config = Config::new(false, None); @@ -136,11 +138,11 @@ fn test_error_messages() { let mut merged: IndexMap<String, PhpMixed> = IndexMap::new(); merged.insert("config".to_string(), PhpMixed::Array(config_options)); config.merge(&merged, "test"); - let config = Rc::new(RefCell::new(config)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); // new HttpDownloader($this->io, $dlConfig): a real downloader (not the extract-path mock). - let dl_config = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let dl_config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), dl_config, IndexMap::new(), @@ -155,8 +157,10 @@ fn test_error_messages() { .into(); package.set_dist_url(Some(dist_url)); - let filesystem = Rc::new(RefCell::new(Filesystem::new(None))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let filesystem = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let mut downloader = ZipDownloader::new( io, config, |
