From 27d00055df8691a6bd99aaf38633a7338b16cc6a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 11 Jul 2026 16:33:05 +0900 Subject: chore: use fully-qualified name for Rc/RefCell --- crates/shirabe/tests/advisory/auditor_test.rs | 34 +++--- crates/shirabe/tests/all_functional_test.rs | 5 +- crates/shirabe/tests/application_test.rs | 116 ++++++++++++--------- .../tests/autoload/autoload_generator_test.rs | 25 +++-- crates/shirabe/tests/cache_test.rs | 8 +- .../shirabe/tests/command/archive_command_test.rs | 68 +++++++----- crates/shirabe/tests/common/config_stub.rs | 6 +- .../shirabe/tests/common/http_downloader_mock.rs | 18 ++-- crates/shirabe/tests/common/io_mock.rs | 10 +- .../shirabe/tests/common/process_executor_mock.rs | 11 +- crates/shirabe/tests/common/test_case.rs | 36 ++++--- crates/shirabe/tests/composer_test.rs | 80 +++++++++----- .../tests/config/json_config_source_test.rs | 4 +- crates/shirabe/tests/config_test.rs | 4 +- .../tests/dependency_resolver/pool_builder_test.rs | 10 +- .../dependency_resolver/pool_optimizer_test.rs | 3 +- .../dependency_resolver/rule_set_iterator_test.rs | 20 ++-- .../tests/dependency_resolver/rule_set_test.rs | 28 +++-- .../tests/dependency_resolver/solver_test.rs | 38 ++++--- crates/shirabe/tests/documentation_test.rs | 6 +- .../tests/downloader/archive_downloader_test.rs | 9 +- .../tests/downloader/download_manager_test.rs | 18 ++-- .../tests/downloader/file_downloader_test.rs | 31 +++--- .../tests/downloader/fossil_downloader_test.rs | 21 ++-- .../tests/downloader/git_downloader_test.rs | 20 ++-- .../shirabe/tests/downloader/hg_downloader_test.rs | 21 ++-- .../tests/downloader/perforce_downloader_test.rs | 22 ++-- .../shirabe/tests/downloader/xz_downloader_test.rs | 15 +-- .../tests/downloader/zip_downloader_test.rs | 38 ++++--- .../event_dispatcher/event_dispatcher_test.rs | 25 +++-- crates/shirabe/tests/factory_test.rs | 4 +- .../tests/installer/binary_installer_test.rs | 11 +- .../tests/installer/installation_manager_test.rs | 28 ++--- .../tests/installer/installer_event_test.rs | 7 +- .../tests/installer/library_installer_test.rs | 31 +++--- .../tests/installer/metapackage_installer_test.rs | 5 +- .../installer/suggested_packages_reporter_test.rs | 13 ++- crates/shirabe/tests/installer_test.rs | 107 +++++++++++-------- crates/shirabe/tests/io/console_io_test.rs | 55 ++++++---- .../tests/package/archiver/archive_manager_test.rs | 26 ++--- .../package/loader/root_package_loader_test.rs | 32 +++--- crates/shirabe/tests/package/locker_test.rs | 31 ++++-- .../tests/package/version/version_guesser_test.rs | 14 ++- .../tests/package/version/version_selector_test.rs | 18 ++-- .../question/strict_confirmation_question_test.rs | 6 +- .../tests/repository/artifact_repository_test.rs | 5 +- .../tests/repository/composer_repository_test.rs | 12 +-- .../tests/repository/filesystem_repository_test.rs | 6 +- .../tests/repository/path_repository_test.rs | 11 +- .../tests/repository/repository_factory_test.rs | 9 +- .../tests/repository/repository_manager_test.rs | 22 ++-- .../tests/repository/vcs/forgejo_driver_test.rs | 18 ++-- .../tests/repository/vcs/fossil_driver_test.rs | 7 +- .../repository/vcs/git_bitbucket_driver_test.rs | 37 ++++--- .../tests/repository/vcs/git_driver_test.rs | 32 +++--- .../tests/repository/vcs/github_driver_test.rs | 88 +++++++++------- .../tests/repository/vcs/gitlab_driver_test.rs | 25 +++-- .../shirabe/tests/repository/vcs/hg_driver_test.rs | 22 ++-- .../tests/repository/vcs/perforce_driver_test.rs | 14 +-- .../tests/repository/vcs/svn_driver_test.rs | 12 +-- .../tests/repository/vcs_repository_test.rs | 13 +-- crates/shirabe/tests/script/event_test.rs | 15 +-- crates/shirabe/tests/util/auth_helper_test.rs | 17 +-- crates/shirabe/tests/util/bitbucket_test.rs | 18 ++-- crates/shirabe/tests/util/config_validator_test.rs | 5 +- crates/shirabe/tests/util/forgejo_test.rs | 10 +- crates/shirabe/tests/util/git_test.rs | 15 +-- crates/shirabe/tests/util/github_test.rs | 12 +-- crates/shirabe/tests/util/gitlab_test.rs | 11 +- crates/shirabe/tests/util/http_downloader_test.rs | 10 +- crates/shirabe/tests/util/perforce_test.rs | 110 +++++++++++-------- crates/shirabe/tests/util/process_executor_test.rs | 30 +++--- .../shirabe/tests/util/remote_filesystem_test.rs | 62 ++++++----- crates/shirabe/tests/util/svn_test.rs | 42 +++++--- 74 files changed, 999 insertions(+), 829 deletions(-) (limited to 'crates/shirabe/tests') diff --git a/crates/shirabe/tests/advisory/auditor_test.rs b/crates/shirabe/tests/advisory/auditor_test.rs index fa99825d..dd904632 100644 --- a/crates/shirabe/tests/advisory/auditor_test.rs +++ b/crates/shirabe/tests/advisory/auditor_test.rs @@ -29,8 +29,6 @@ use shirabe_php_shim::date_create; use shirabe_semver::VersionParser; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; -use std::rc::Rc; fn constraint(operator: &str, version: &str) -> shirabe_semver::constraint::AnyConstraint { SimpleConstraint::new(operator.to_string(), version.to_string(), None).into() @@ -594,9 +592,10 @@ Found 2 abandoned packages: for case in cases { let repo_set = get_repo_set(); - let io: Rc> = Rc::new(RefCell::new( - BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), + )); let auditor = Auditor; let result = auditor .audit( @@ -824,7 +823,7 @@ fn test_audit_with_ignore() { let repo_set = get_repo_set(); let (io_mock, _io_guard) = get_io_mock(io_interface::NORMAL).unwrap(); let auditor = Auditor; - let io_dyn: Rc> = io_mock.clone(); + let io_dyn: std::rc::Rc> = io_mock.clone(); let result = auditor .audit( &io_dyn, @@ -924,9 +923,10 @@ fn test_audit_with_ignore_unreachable() { // Without the ignoreUnreachable flag the TransportException propagates. { let repo_set = make_repo_set(); - let io: Rc> = Rc::new(RefCell::new( - BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), + )); let err = auditor .audit( &io, @@ -947,9 +947,10 @@ fn test_audit_with_ignore_unreachable() { // With the ignoreUnreachable flag the advisories from reachable repos are reported. { let repo_set = make_repo_set(); - let io: Rc> = Rc::new(RefCell::new( - BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), + )); let result = auditor .audit( &io, @@ -983,9 +984,10 @@ fn test_audit_with_ignore_unreachable() { // With JSON format the unreachable repositories and advisories are both included. { let repo_set = make_repo_set(); - let io: Rc> = Rc::new(RefCell::new( - BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), + )); let result = auditor .audit( &io, @@ -1082,7 +1084,7 @@ fn test_audit_with_ignore_severity() { let repo_set = get_repo_set(); let (io_mock, _io_guard) = get_io_mock(io_interface::NORMAL).unwrap(); let auditor = Auditor; - let io_dyn: Rc> = io_mock.clone(); + let io_dyn: std::rc::Rc> = io_mock.clone(); let result = auditor .audit( &io_dyn, diff --git a/crates/shirabe/tests/all_functional_test.rs b/crates/shirabe/tests/all_functional_test.rs index c6eb683b..b1717d08 100644 --- a/crates/shirabe/tests/all_functional_test.rs +++ b/crates/shirabe/tests/all_functional_test.rs @@ -10,7 +10,6 @@ use serial_test::serial; use shirabe::util::filesystem::Filesystem; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::{CaptureKey, PREG_SPLIT_DELIM_CAPTURE, PhpMixed, intval}; -use std::cell::RefCell; use std::path::{Path, PathBuf}; /// ref: AllFunctionalTest's `$oldcwd` / `$testDir` instance state plus its `setUp`/`tearDown`. @@ -19,7 +18,7 @@ use std::path::{Path, PathBuf}; /// cwd and removes the unique temp dir created by `testIntegration`. Modelled as an RAII guard. struct TearDown { old_cwd: PathBuf, - test_dir: RefCell>, + test_dir: std::cell::RefCell>, } impl Drop for TearDown { @@ -42,7 +41,7 @@ fn set_up() -> TearDown { std::env::set_current_dir(fixtures_dir()).unwrap(); TearDown { old_cwd, - test_dir: RefCell::new(None), + test_dir: std::cell::RefCell::new(None), } } diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index 7ee58e49..df5f6e4f 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -21,8 +21,6 @@ use shirabe_external_packages::symfony::console::input::input_interface::InputIn use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; fn set_up() { Platform::put_env("COMPOSER_DISABLE_XDEBUG_WARN", "1"); @@ -61,18 +59,22 @@ fn test_dev_warning_suppressed_for_self_update() { } let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); - let command: Rc> = Rc::new(RefCell::new(SelfUpdateCommand::new())); + let command: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(SelfUpdateCommand::new())); application.add(command).unwrap(); - let output = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let input: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![(PhpMixed::from("command"), PhpMixed::from("self-update"))], - None, - ) - .unwrap(), - )); - let output_trait: Rc> = output.clone(); + let output = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("command"), PhpMixed::from("self-update"))], + None, + ) + .unwrap(), + )); + let output_trait: std::rc::Rc> = output.clone(); application.do_run(input, output_trait).unwrap(); assert_eq!( @@ -88,29 +90,34 @@ fn test_process_isolation_works_multiple_times() { set_up(); let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); - let command: Rc> = Rc::new(RefCell::new(AboutCommand::new())); + let command: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(AboutCommand::new())); application.add(command).unwrap(); - let input1: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![(PhpMixed::from("command"), PhpMixed::from("about"))], - None, - ) - .unwrap(), - )); - let output1: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input1: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("command"), PhpMixed::from("about"))], + None, + ) + .unwrap(), + )); + let output1: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); assert_eq!(0, application.do_run(input1, output1).unwrap()); - let input2: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![(PhpMixed::from("command"), PhpMixed::from("about"))], - None, - ) - .unwrap(), - )); - let output2: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input2: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("command"), PhpMixed::from("about"))], + None, + ) + .unwrap(), + )); + let output2: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); assert_eq!(0, application.do_run(input2, output2).unwrap()); } @@ -143,18 +150,20 @@ fn test_no_plugins_disables_plugins_when_script_commands_exist() { // Run list command with --no-plugins, this triggers script command registration which previously // created a Composer instance with plugins enabled regardless of the --no-plugins flag - let input: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![ - (PhpMixed::from("command"), PhpMixed::from("list")), - (PhpMixed::from("--no-plugins"), PhpMixed::from(true)), - ], - None, - ) - .unwrap(), - )); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![ + (PhpMixed::from("command"), PhpMixed::from("list")), + (PhpMixed::from("--no-plugins"), PhpMixed::from(true)), + ], + None, + ) + .unwrap(), + )); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); application.do_run(input, output).unwrap(); let composer = application.__get_composer(false, None, None).unwrap(); @@ -207,15 +216,18 @@ fn test_script_command_takes_priority_over_abbreviated_builtin_command() { let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); - let app_output = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let input: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![(PhpMixed::from("command"), PhpMixed::from("check"))], - None, - ) - .unwrap(), - )); - let output_trait: Rc> = app_output.clone(); + let app_output = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("command"), PhpMixed::from("check"))], + None, + ) + .unwrap(), + )); + let output_trait: std::rc::Rc> = app_output.clone(); let exit_code = application.do_run(input, output_trait).unwrap(); assert_eq!(0, exit_code, "Script command should have run successfully"); diff --git a/crates/shirabe/tests/autoload/autoload_generator_test.rs b/crates/shirabe/tests/autoload/autoload_generator_test.rs index a79bba0f..d7159c27 100644 --- a/crates/shirabe/tests/autoload/autoload_generator_test.rs +++ b/crates/shirabe/tests/autoload/autoload_generator_test.rs @@ -21,8 +21,6 @@ use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint, SimpleConstraint}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; /// The mock `InstallationManager::getInstallPath` used throughout the test: metapackages return @@ -128,9 +126,9 @@ struct SetUp { vendor_dir: String, repository: InstalledArrayRepository, im: InstallationManager, - io: Rc>, + io: std::rc::Rc>, generator: AutoloadGenerator, - event_dispatcher: Rc>, + event_dispatcher: std::rc::Rc>, } impl Drop for SetUp { @@ -148,14 +146,14 @@ fn null_path(s: &str) -> String { /// exercised here, so a mock HttpDownloader (no real curl backend) stands in for the loop. fn make_installation_manager( vendor_dir: &str, - io: Rc>, + io: std::rc::Rc>, ) -> InstallationManager { - let config_for_downloader = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock( + let config_for_downloader = 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(), config_for_downloader, ))); - let loop_ = Rc::new(RefCell::new(Loop::new(http_downloader, None))); + let loop_ = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None))); let mut im = InstallationManager::new(loop_, io, None); im.add_installer(Box::new(InstallPathStubInstaller { @@ -173,20 +171,21 @@ fn set_up() -> SetUp { let prev_cwd = std::env::current_dir().unwrap(); std::env::set_current_dir(&working_dir).unwrap(); - let io = Rc::new(RefCell::new( + let io = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), )); - let dispatcher_io: Rc> = io.clone(); + let dispatcher_io: std::rc::Rc> = io.clone(); let im = make_installation_manager(&vendor_dir, dispatcher_io.clone()); let repository = InstalledArrayRepository::new().unwrap(); // EventDispatcher constructor is disabled in PHP and dispatch is never called when run-scripts // is off (the default), so a real dispatcher over an empty Composer is a faithful no-op stand-in. - let composer = - ComposerHandle::from_rc_unchecked(Rc::new(RefCell::new(PartialOrFullComposer::new_full()))); - let event_dispatcher = Rc::new(RefCell::new(EventDispatcher::new( + let composer = ComposerHandle::from_rc_unchecked(std::rc::Rc::new(std::cell::RefCell::new( + PartialOrFullComposer::new_full(), + ))); + let event_dispatcher = std::rc::Rc::new(std::cell::RefCell::new(EventDispatcher::new( composer.upcast().downgrade(), dispatcher_io.clone(), None, diff --git a/crates/shirabe/tests/cache_test.rs b/crates/shirabe/tests/cache_test.rs index b9644dc9..c7c665f8 100644 --- a/crates/shirabe/tests/cache_test.rs +++ b/crates/shirabe/tests/cache_test.rs @@ -4,9 +4,7 @@ use shirabe::cache::{Cache, CacheMock, GcFinderMock}; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::filesystem::Filesystem; -use std::cell::RefCell; use std::fs; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -28,7 +26,8 @@ fn set_up() -> SetUp { // PHP mocks Cache::getFinder and keeps the real Filesystem; here the CacheMock finder seam plays // that role and the Cache otherwise operates on the real temp directory. - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let cache = Cache::new(io, root.path().to_str().unwrap(), None, None, false); SetUp { root, files, cache } @@ -113,7 +112,8 @@ fn test_remove_files_when_cache_is_too_large() { #[test] fn test_clear_cache() { let root = TempDir::new().unwrap(); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut cache = Cache::new( io, root.path().to_str().unwrap(), diff --git a/crates/shirabe/tests/command/archive_command_test.rs b/crates/shirabe/tests/command/archive_command_test.rs index 991f615a..322894db 100644 --- a/crates/shirabe/tests/command/archive_command_test.rs +++ b/crates/shirabe/tests/command/archive_command_test.rs @@ -22,8 +22,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; // PHP mocks `Composer\Package\Archiver\ArchiveManager` with // getMockBuilder(...)->disableOriginalConstructor(). @@ -108,17 +106,21 @@ fn root_package(name: &str, version: &str) -> RootPackageHandle { } fn full_composer(composer: Composer) -> PartialComposerHandle { - PartialComposerHandle::from_rc(Rc::new(RefCell::new(PartialOrFullComposer::Full(composer)))) + PartialComposerHandle::from_rc(std::rc::Rc::new(std::cell::RefCell::new( + PartialOrFullComposer::Full(composer), + ))) } #[test] fn test_uses_config_from_composer_object() { - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); - let config: Rc> = ConfigStubBuilder::new() + let config: std::rc::Rc> = ConfigStubBuilder::new() .with("archive-format", PhpMixed::from("zip")) .build_shared(); @@ -144,8 +146,10 @@ fn test_uses_config_from_composer_object() { let mut composer = Composer::new(); composer.set_config(config); - composer.set_archive_manager(Rc::new(RefCell::new(manager))); - composer.set_event_dispatcher(Rc::new(RefCell::new(noop_event_dispatcher()))); + composer.set_archive_manager(std::rc::Rc::new(std::cell::RefCell::new(manager))); + composer.set_event_dispatcher(std::rc::Rc::new(std::cell::RefCell::new( + noop_event_dispatcher(), + ))); composer.set_package(package.into()); let composer = full_composer(composer); @@ -158,10 +162,12 @@ fn test_uses_config_from_composer_object() { #[test] fn test_uses_config_from_factory_when_composer_is_not_defined() { - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); // tryComposer() returns null (no Composer set), so execute() builds the Config via the Factory // and `archive` is stubbed (PHPUnit overrides initialize/tryComposer/archive). @@ -188,17 +194,19 @@ fn test_uses_config_from_factory_when_composer_is_not_defined() { #[test] fn test_uses_config_from_composer_object_with_package_name() { - let input: Rc> = Rc::new(RefCell::new( - ArrayInput::new( - vec![(PhpMixed::from("package"), PhpMixed::from("foo/bar"))], - None, - ) - .unwrap(), - )); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - - let config: Rc> = ConfigStubBuilder::new() + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + ArrayInput::new( + vec![(PhpMixed::from("package"), PhpMixed::from("foo/bar"))], + None, + ) + .unwrap(), + )); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); + + let config: std::rc::Rc> = ConfigStubBuilder::new() .with("archive-format", PhpMixed::from("zip")) .build_shared(); @@ -241,10 +249,14 @@ fn test_uses_config_from_composer_object_with_package_name() { let mut composer = Composer::new(); composer.set_config(config); - composer.set_archive_manager(Rc::new(RefCell::new(manager))); - composer.set_event_dispatcher(Rc::new(RefCell::new(noop_event_dispatcher()))); + composer.set_archive_manager(std::rc::Rc::new(std::cell::RefCell::new(manager))); + composer.set_event_dispatcher(std::rc::Rc::new(std::cell::RefCell::new( + noop_event_dispatcher(), + ))); composer.set_package(package.into()); - composer.set_repository_manager(Rc::new(RefCell::new(repository_manager))); + composer.set_repository_manager(std::rc::Rc::new(std::cell::RefCell::new( + repository_manager, + ))); let composer = full_composer(composer); let command = ArchiveCommand::new(); diff --git a/crates/shirabe/tests/common/config_stub.rs b/crates/shirabe/tests/common/config_stub.rs index bf81462a..656dea60 100644 --- a/crates/shirabe/tests/common/config_stub.rs +++ b/crates/shirabe/tests/common/config_stub.rs @@ -11,8 +11,6 @@ use indexmap::IndexMap; use shirabe::config::Config; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; pub struct ConfigStubBuilder { use_environment: bool, @@ -65,8 +63,8 @@ impl ConfigStubBuilder { config } - pub fn build_shared(self) -> Rc> { - Rc::new(RefCell::new(self.build())) + pub fn build_shared(self) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(self.build())) } } diff --git a/crates/shirabe/tests/common/http_downloader_mock.rs b/crates/shirabe/tests/common/http_downloader_mock.rs index 85d3ec81..59519ca4 100644 --- a/crates/shirabe/tests/common/http_downloader_mock.rs +++ b/crates/shirabe/tests/common/http_downloader_mock.rs @@ -9,8 +9,6 @@ use shirabe::util::http_downloader::{ HttpDownloader, HttpDownloaderMockExpectation, HttpDownloaderMockHandler, }; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; // A single HTTP request expectation as written in the PHP tests: a `url` plus an // optional response (`status`/`body`/`headers`). `options` of `None` matches any @@ -41,7 +39,7 @@ pub fn expect_full( } } -pub struct HttpDownloaderMockGuard(Rc>); +pub struct HttpDownloaderMockGuard(std::rc::Rc>); impl Drop for HttpDownloaderMockGuard { fn drop(&mut self) { @@ -60,10 +58,16 @@ pub fn get_http_downloader_mock( expectations: Vec, strict: bool, default_handler: HttpDownloaderMockHandler, -) -> (Rc>, HttpDownloaderMockGuard) { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(false, None))); - let downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock(io, config))); +) -> ( + std::rc::Rc>, + HttpDownloaderMockGuard, +) { + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::__new_mock( + io, config, + ))); downloader .borrow_mut() .__expects(expectations, strict, default_handler); diff --git a/crates/shirabe/tests/common/io_mock.rs b/crates/shirabe/tests/common/io_mock.rs index 7b932a87..e54c45b9 100644 --- a/crates/shirabe/tests/common/io_mock.rs +++ b/crates/shirabe/tests/common/io_mock.rs @@ -8,9 +8,7 @@ use shirabe::util::platform::Platform; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::{PHP_EOL, PhpMixed, preg_quote}; -use std::cell::RefCell; use std::collections::VecDeque; -use std::rc::Rc; // A single entry of the IO expectation list. PHP models these as associative // arrays (`{text, regex?}` / `{ask, reply}` / `{auth: [repo, user, pass]}`); the @@ -344,7 +342,7 @@ fn trim_eol(question: &str) -> &str { question.trim_end_matches(['\r', '\n']) } -pub struct IOMockGuard(Rc>); +pub struct IOMockGuard(std::rc::Rc>); impl Drop for IOMockGuard { fn drop(&mut self) { @@ -358,7 +356,9 @@ impl Drop for IOMockGuard { // For testing only. Mirrors TestCase::getIOMock: returns a shared IOMock handle // plus a guard that runs assert_complete when it drops at the end of the test scope. -pub fn get_io_mock(verbosity: i64) -> anyhow::Result<(Rc>, IOMockGuard)> { - let mock = Rc::new(RefCell::new(IOMock::new(verbosity)?)); +pub fn get_io_mock( + verbosity: i64, +) -> anyhow::Result<(std::rc::Rc>, IOMockGuard)> { + let mock = std::rc::Rc::new(std::cell::RefCell::new(IOMock::new(verbosity)?)); Ok((mock.clone(), IOMockGuard(mock))) } diff --git a/crates/shirabe/tests/common/process_executor_mock.rs b/crates/shirabe/tests/common/process_executor_mock.rs index 698d8d26..33d9dfba 100644 --- a/crates/shirabe/tests/common/process_executor_mock.rs +++ b/crates/shirabe/tests/common/process_executor_mock.rs @@ -2,8 +2,6 @@ use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; // A command expectation as written in the PHP tests: either a bare command // (`'git command'` / `['git', '--version']`) or the full @@ -72,7 +70,7 @@ impl IntoMockCmd for [&str; N] { } } -pub struct ProcessExecutorMockGuard(Rc>); +pub struct ProcessExecutorMockGuard(std::rc::Rc>); impl Drop for ProcessExecutorMockGuard { fn drop(&mut self) { @@ -91,8 +89,11 @@ pub fn get_process_executor_mock( expectations: Vec, strict: bool, default_handler: MockHandler, -) -> (Rc>, ProcessExecutorMockGuard) { - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); +) -> ( + std::rc::Rc>, + ProcessExecutorMockGuard, +) { + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); process .borrow_mut() .__expects(expectations, strict, default_handler); diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs index 7365f734..5bfc2d0f 100644 --- a/crates/shirabe/tests/common/test_case.rs +++ b/crates/shirabe/tests/common/test_case.rs @@ -30,9 +30,7 @@ use shirabe_external_packages::symfony::console::output::stream_output::StreamOu use shirabe_php_shim::{PhpMixed, PhpResource}; use shirabe_semver::VersionParser; use shirabe_semver::constraint::{AnyConstraint, SimpleConstraint}; -use std::cell::RefCell; use std::path::PathBuf; -use std::rc::Rc; use tempfile::TempDir; /// ref: TestCase::getPackage (default class CompletePackage) @@ -170,17 +168,22 @@ pub fn init_temp_composer( } } -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } /// ref: FactoryMock::createInstallationManager (the real installers are never created in tests, so a /// bare InstallationManager over a mock HttpDownloader suffices). -fn installation_manager(io: &Rc>) -> Rc> { - let config = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock(io.clone(), config))); - let r#loop = Rc::new(RefCell::new(Loop::new(http_downloader, None))); - Rc::new(RefCell::new(InstallationManager::new( +fn installation_manager( + io: &std::rc::Rc>, +) -> std::rc::Rc> { + let 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(), + config, + ))); + let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None))); + std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::new( r#loop, io.clone(), None, @@ -227,7 +230,9 @@ pub fn create_composer_lock( let io = null_io(); let json_file = JsonFile::new("./composer.lock".to_string(), None, None).unwrap(); let composer_file_contents = std::fs::read_to_string("./composer.json").unwrap_or_default(); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let mut locker = Locker::new( io.clone(), json_file, @@ -279,7 +284,7 @@ pub struct ApplicationTester { application: ApplicationHandle, inputs: Vec, status_code: Option, - output: Option>>, + output: Option>>, /// Handles retained before injection so `get_display`/`get_error_output` can read the memory /// streams without relying on a `get_stream()` accessor across the ConsoleOutput composition gap. output_stream: Option, @@ -320,7 +325,8 @@ impl ApplicationTester { self.init_output(&options); - let input: Rc> = Rc::new(RefCell::new(array_input)); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(array_input)); let output = self.output.clone().expect("init_output initializes output"); let status_code = self.application.run(Some(input), Some(output))?; @@ -346,7 +352,7 @@ impl ApplicationTester { if let Some(verbosity) = options.verbosity { output.set_verbosity(verbosity); } - self.output = Some(Rc::new(RefCell::new(output))); + self.output = Some(std::rc::Rc::new(std::cell::RefCell::new(output))); } else { let stdout = shirabe_php_shim::php_fopen_resource("php://memory", "w"); let stderr = shirabe_php_shim::php_fopen_resource("php://memory", "w"); @@ -363,10 +369,10 @@ impl ApplicationTester { error_output.set_verbosity(output.get_verbosity()); error_output.set_decorated(output.is_decorated()); - output.set_error_output(Rc::new(RefCell::new(error_output))); + output.set_error_output(std::rc::Rc::new(std::cell::RefCell::new(error_output))); output.__set_stream(stdout); - self.output = Some(Rc::new(RefCell::new(output))); + self.output = Some(std::rc::Rc::new(std::cell::RefCell::new(output))); } } diff --git a/crates/shirabe/tests/composer_test.rs b/crates/shirabe/tests/composer_test.rs index c394f1e6..891a47f1 100644 --- a/crates/shirabe/tests/composer_test.rs +++ b/crates/shirabe/tests/composer_test.rs @@ -16,16 +16,16 @@ use shirabe::repository::RepositoryManagerInterface; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe::util::process_executor::ProcessExecutor; -use std::cell::RefCell; -use std::rc::Rc; -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } -fn http_downloader(io: &Rc>) -> Rc> { - let config = Rc::new(RefCell::new(Config::new(false, None))); - Rc::new(RefCell::new(HttpDownloader::new( +fn http_downloader( + io: &std::rc::Rc>, +) -> std::rc::Rc> { + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config, IndexMap::new(), @@ -33,9 +33,14 @@ fn http_downloader(io: &Rc>) -> Rc>) -> Rc> { - let r#loop = Rc::new(RefCell::new(Loop::new(http_downloader(io), None))); - Rc::new(RefCell::new(InstallationManager::new( +fn installation_manager( + io: &std::rc::Rc>, +) -> std::rc::Rc> { + let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new( + http_downloader(io), + None, + ))); + std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::new( r#loop, io.clone(), None, @@ -61,48 +66,67 @@ fn test_set_get_locker() { let mut composer = Composer::new(); let io = null_io(); let json_file = JsonFile::new("composer.lock".to_string(), None, None).unwrap(); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); - let locker: Rc> = Rc::new(RefCell::new(Locker::new( + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( io.clone(), - json_file, - installation_manager(&io), - "{}", - process, - ))); + )))); + let locker: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(Locker::new( + io.clone(), + json_file, + installation_manager(&io), + "{}", + process, + ))); composer.set_locker(locker.clone()); - assert!(Rc::ptr_eq(&composer.get_locker(), &locker)); + assert!(std::rc::Rc::ptr_eq(&composer.get_locker(), &locker)); } #[test] fn test_set_get_repository_manager() { let mut composer = Composer::new(); let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(false, None))); - let manager: Rc> = Rc::new(RefCell::new( - RepositoryManager::new(io.clone(), config, http_downloader(&io), None, None), - )); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let manager: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(RepositoryManager::new( + io.clone(), + config, + http_downloader(&io), + None, + None, + ))); composer.set_repository_manager(manager.clone()); - assert!(Rc::ptr_eq(&composer.get_repository_manager(), &manager)); + assert!(std::rc::Rc::ptr_eq( + &composer.get_repository_manager(), + &manager + )); } #[test] fn test_set_get_download_manager() { let mut composer = Composer::new(); - let manager: Rc> = - Rc::new(RefCell::new(DownloadManager::new(null_io(), false, None))); + let manager: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(DownloadManager::new(null_io(), false, None)), + ); composer.set_download_manager(manager.clone()); - assert!(Rc::ptr_eq(&composer.get_download_manager(), &manager)); + assert!(std::rc::Rc::ptr_eq( + &composer.get_download_manager(), + &manager + )); } #[test] fn test_set_get_installation_manager() { let mut composer = Composer::new(); let io = null_io(); - let manager: Rc> = installation_manager(&io); + let manager: std::rc::Rc> = + installation_manager(&io); composer.set_installation_manager(manager.clone()); - assert!(Rc::ptr_eq(&composer.get_installation_manager(), &manager)); + assert!(std::rc::Rc::ptr_eq( + &composer.get_installation_manager(), + &manager + )); } diff --git a/crates/shirabe/tests/config/json_config_source_test.rs b/crates/shirabe/tests/config/json_config_source_test.rs index 200a6216..155b83a7 100644 --- a/crates/shirabe/tests/config/json_config_source_test.rs +++ b/crates/shirabe/tests/config/json_config_source_test.rs @@ -6,9 +6,7 @@ use shirabe::config::JsonConfigSource; use shirabe::json::JsonFile; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; use std::path::PathBuf; -use std::rc::Rc; use tempfile::TempDir; fn set_up() -> TearDown { @@ -58,7 +56,7 @@ fn assert_file_equals(expected: &std::path::Path, actual: &std::path::Path) { fn json_config_source(config: &std::path::Path) -> JsonConfigSource { let json_file = JsonFile::new(config.to_string_lossy().to_string(), None, None).unwrap(); - JsonConfigSource::new(Rc::new(RefCell::new(json_file)), false) + JsonConfigSource::new(std::rc::Rc::new(std::cell::RefCell::new(json_file)), false) } #[test] diff --git a/crates/shirabe/tests/config_test.rs b/crates/shirabe/tests/config_test.rs index 61a1575a..e8feafd7 100644 --- a/crates/shirabe/tests/config_test.rs +++ b/crates/shirabe/tests/config_test.rs @@ -8,8 +8,6 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::Platform; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[path = "common/io_mock.rs"] #[allow(dead_code)] // io_mock exposes more helpers than this binary uses @@ -509,7 +507,7 @@ fn test_prohibited_urls_warning_verify_peer() { .unwrap(); let mut config = Config::new(false, None); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let mut repo_options: IndexMap = IndexMap::new(); repo_options.insert( "ssl".to_string(), diff --git a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs index 548cb0dc..e6897ff7 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs @@ -22,9 +22,7 @@ use shirabe::repository::repository_set::{RepositorySet, RootAliasInput}; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::PREG_SPLIT_DELIM_CAPTURE; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; use std::path::PathBuf; -use std::rc::Rc; /// Maps the PHP `$loadPackage` closure: pops the optional `id` from the data, loads the /// package and records it in `package_ids` keyed by that id (erroring on duplicates). @@ -451,8 +449,9 @@ fn run_test_pool_builder( IndexMap::new(), IndexMap::new(), ); - let config = Rc::new(RefCell::new(Config::new(false, None))); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut rm = RepositoryFactory::manager(io.clone(), &config, None, None, None).unwrap(); // PHP: foreach ($packageRepos as $packages) @@ -605,7 +604,8 @@ fn run_test_pool_builder( message ); - let mut optimizer = PoolOptimizer::new(Rc::new(DefaultPolicy::new(false, false, None))); + let mut optimizer = + PoolOptimizer::new(std::rc::Rc::new(DefaultPolicy::new(false, false, None))); let optimized = optimizer.optimize(&request, &pool); let mut result = get_package_result_set(&optimized, &package_ids); let mut expect_optimized = expect_optimized.as_list().unwrap().clone(); diff --git a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs index 3c4952e7..08d5f989 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs @@ -15,7 +15,6 @@ use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::PREG_SPLIT_DELIM_CAPTURE; use shirabe_php_shim::PhpMixed; use std::path::PathBuf; -use std::rc::Rc; fn load_package(package_data: &PhpMixed) -> BasePackageHandle { let loader = ArrayLoader::new(None, false); @@ -237,7 +236,7 @@ fn run_test_pool_optimizer( IndexMap::new(), IndexMap::new(), ); - let mut pool_optimizer = PoolOptimizer::new(Rc::new(DefaultPolicy::new( + let mut pool_optimizer = PoolOptimizer::new(std::rc::Rc::new(DefaultPolicy::new( prefer_stable, prefer_lowest, None, diff --git a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs index 9c9f85bd..93e25962 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs @@ -7,13 +7,11 @@ use shirabe::dependency_resolver::rule::{RULE_LEARNED, RULE_ROOT_REQUIRE, Reason use shirabe::dependency_resolver::rule_set::RuleSet; use shirabe::dependency_resolver::rule_set_iterator::RuleSetIterator; use shirabe_semver::constraint::MatchAllConstraint; -use std::cell::RefCell; -use std::rc::Rc; -type Rules = IndexMap>>>; +type Rules = IndexMap>>>; -fn root_require_rule() -> Rc> { - Rc::new(RefCell::new(Rule::Generic(GenericRule::new( +fn root_require_rule() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic(GenericRule::new( vec![], RULE_ROOT_REQUIRE, ReasonData::RootRequire { @@ -40,11 +38,9 @@ fn set_up() -> (Pool, Rules) { ); rules.insert( RuleSet::TYPE_LEARNED, - vec![Rc::new(RefCell::new(Rule::Generic(GenericRule::new( - vec![], - RULE_LEARNED, - ReasonData::Int(1), - ))))], + vec![std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic( + GenericRule::new(vec![], RULE_LEARNED, ReasonData::Int(1)), + )))], ); rules.insert(RuleSet::TYPE_PACKAGE, vec![]); @@ -56,7 +52,7 @@ fn test_foreach() { let (_pool, rules) = set_up(); let mut rule_set_iterator = RuleSetIterator::new(rules.clone()); - let mut result: Vec>> = Vec::new(); + let mut result: Vec>> = Vec::new(); while rule_set_iterator.valid() { result.push(rule_set_iterator.current()); rule_set_iterator.next(); @@ -70,7 +66,7 @@ fn test_foreach() { assert_eq!(expected.len(), result.len()); for (e, r) in expected.iter().zip(result.iter()) { - assert!(Rc::ptr_eq(e, r)); + assert!(std::rc::Rc::ptr_eq(e, r)); } } diff --git a/crates/shirabe/tests/dependency_resolver/rule_set_test.rs b/crates/shirabe/tests/dependency_resolver/rule_set_test.rs index 3ed974e6..0a9582dc 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_set_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_set_test.rs @@ -7,8 +7,6 @@ use shirabe::dependency_resolver::{ }; use shirabe::repository::RepositorySet; use shirabe_semver::constraint::{MatchAllConstraint, MatchNoneConstraint}; -use std::cell::RefCell; -use std::rc::Rc; fn root_require_reason() -> ReasonData { ReasonData::RootRequire { @@ -17,16 +15,16 @@ fn root_require_reason() -> ReasonData { } } -fn rule(literals: Vec) -> Rc> { - Rc::new(RefCell::new(Rule::Generic(GenericRule::new( +fn rule(literals: Vec) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic(GenericRule::new( literals, RULE_ROOT_REQUIRE, root_require_reason(), )))) } -fn learned_rule() -> Rc> { - Rc::new(RefCell::new(Rule::Generic(GenericRule::new( +fn learned_rule() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic(GenericRule::new( vec![], RULE_LEARNED, ReasonData::Int(1), @@ -67,11 +65,11 @@ fn test_add() { ); let request = &rules[&RuleSet::TYPE_REQUEST]; assert_eq!(2, request.len()); - assert!(Rc::ptr_eq(&request[0], &request0)); - assert!(Rc::ptr_eq(&request[1], &request1)); + assert!(std::rc::Rc::ptr_eq(&request[0], &request0)); + assert!(std::rc::Rc::ptr_eq(&request[1], &request1)); let learned = &rules[&RuleSet::TYPE_LEARNED]; assert_eq!(1, learned.len()); - assert!(Rc::ptr_eq(&learned[0], &learned0)); + assert!(std::rc::Rc::ptr_eq(&learned[0], &learned0)); } #[test] @@ -110,7 +108,7 @@ fn test_rule_by_id() { let rule = rule(vec![]); rule_set.add(rule.clone(), RuleSet::TYPE_REQUEST).unwrap(); - assert!(Rc::ptr_eq(&rule_set.rule_by_id[&0], &rule)); + assert!(std::rc::Rc::ptr_eq(&rule_set.rule_by_id[&0], &rule)); } #[test] @@ -122,9 +120,9 @@ fn test_get_iterator() { rule_set.add(rule2.clone(), RuleSet::TYPE_LEARNED).unwrap(); let mut iterator = rule_set.get_iterator(); - assert!(Rc::ptr_eq(&iterator.current(), &rule1)); + assert!(std::rc::Rc::ptr_eq(&iterator.current(), &rule1)); iterator.next(); - assert!(Rc::ptr_eq(&iterator.current(), &rule2)); + assert!(std::rc::Rc::ptr_eq(&iterator.current(), &rule2)); } #[test] @@ -136,7 +134,7 @@ fn test_get_iterator_for() { rule_set.add(rule2.clone(), RuleSet::TYPE_LEARNED).unwrap(); let iterator = rule_set.get_iterator_for(vec![RuleSet::TYPE_LEARNED]); - assert!(Rc::ptr_eq(&iterator.current(), &rule2)); + assert!(std::rc::Rc::ptr_eq(&iterator.current(), &rule2)); } #[test] @@ -148,7 +146,7 @@ fn test_get_iterator_without() { rule_set.add(rule2.clone(), RuleSet::TYPE_LEARNED).unwrap(); let iterator = rule_set.get_iterator_without(vec![RuleSet::TYPE_REQUEST]); - assert!(Rc::ptr_eq(&iterator.current(), &rule2)); + assert!(std::rc::Rc::ptr_eq(&iterator.current(), &rule2)); } // The constraint is MatchNoneConstraint, so what_provides returns no packages and the @@ -178,7 +176,7 @@ fn test_pretty_string() { let mut rule_set = RuleSet::new(); let literal = p.get_id(); - let rule = Rc::new(RefCell::new(Rule::Generic(GenericRule::new( + let rule = std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic(GenericRule::new( vec![literal], RULE_ROOT_REQUIRE, ReasonData::RootRequire { diff --git a/crates/shirabe/tests/dependency_resolver/solver_test.rs b/crates/shirabe/tests/dependency_resolver/solver_test.rs index c20fd4c5..b8be2287 100644 --- a/crates/shirabe/tests/dependency_resolver/solver_test.rs +++ b/crates/shirabe/tests/dependency_resolver/solver_test.rs @@ -16,8 +16,6 @@ use shirabe::repository::handle::{LockArrayRepositoryHandle, RepositoryInterface use shirabe::repository::lock_array_repository::LockArrayRepository; use shirabe::repository::repository_set::RepositorySet; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint, MultiConstraint}; -use std::cell::RefCell; -use std::rc::Rc; #[allow(dead_code)] struct Fixtures { @@ -122,13 +120,18 @@ fn check_solver_result_repo_set( expected: Vec, ) { // createSolver() - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let pool = repo_set .create_pool(&mut request, io.clone(), None, None, vec![], None, None) .unwrap(); - let policy: Rc = Rc::new(DefaultPolicy::new(false, false, None)); - let mut solver = - shirabe::dependency_resolver::solver::Solver::new(policy, Rc::new(RefCell::new(pool)), io); + let policy: std::rc::Rc = + std::rc::Rc::new(DefaultPolicy::new(false, false, None)); + let mut solver = shirabe::dependency_resolver::solver::Solver::new( + policy, + std::rc::Rc::new(std::cell::RefCell::new(pool)), + io, + ); let transaction = solver.solve(&request, None).unwrap().unwrap(); @@ -197,7 +200,7 @@ struct SolveError { exception: SolverProblemsException, repo_set: RepositorySet, request: Request, - pool: Rc>, + pool: std::rc::Rc>, } /// ref: SolverTest::createSolver + solve, returning the caught SolverProblemsException. @@ -212,13 +215,15 @@ fn solve_expecting_problems( .unwrap(); repo_set.add_repository(repo_locked.into()).unwrap(); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let pool = Rc::new(RefCell::new( + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let pool = std::rc::Rc::new(std::cell::RefCell::new( repo_set .create_pool(&mut request, io.clone(), None, None, vec![], None, None) .unwrap(), )); - let policy: Rc = Rc::new(DefaultPolicy::new(false, false, None)); + let policy: std::rc::Rc = + std::rc::Rc::new(DefaultPolicy::new(false, false, None)); let mut solver = shirabe::dependency_resolver::solver::Solver::new(policy, pool.clone(), io); let exception = match solver.solve(&request, None).unwrap() { @@ -2489,13 +2494,18 @@ fn test_learn_positive_literal() { let mut request = fixtures.request; request.require_name("A", None).unwrap(); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let pool = repo_set .create_pool(&mut request, io.clone(), None, None, vec![], None, None) .unwrap(); - let policy: Rc = Rc::new(DefaultPolicy::new(false, false, None)); - let mut solver = - shirabe::dependency_resolver::solver::Solver::new(policy, Rc::new(RefCell::new(pool)), io); + let policy: std::rc::Rc = + std::rc::Rc::new(DefaultPolicy::new(false, false, None)); + let mut solver = shirabe::dependency_resolver::solver::Solver::new( + policy, + std::rc::Rc::new(std::cell::RefCell::new(pool)), + io, + ); // check correct setup for assertion later assert!(!solver.test_flag_learned_positive_literal); diff --git a/crates/shirabe/tests/documentation_test.rs b/crates/shirabe/tests/documentation_test.rs index 7dc049cf..7a13ce1d 100644 --- a/crates/shirabe/tests/documentation_test.rs +++ b/crates/shirabe/tests/documentation_test.rs @@ -3,10 +3,8 @@ use shirabe::console::application::ApplicationHandle; use shirabe_external_packages::symfony::console::command::Command; use shirabe_external_packages::symfony::console::descriptor::application_description::ApplicationDescription; -use std::cell::RefCell; -use std::rc::Rc; -fn get_command_name(command: &Rc>) -> String { +fn get_command_name(command: &std::rc::Rc>) -> String { let mut name = command.borrow().get_name().unwrap_or_default(); for alias in command.borrow().get_aliases() { name = format!("{} / {}", name, alias); @@ -15,7 +13,7 @@ fn get_command_name(command: &Rc>) -> String { name } -fn provide_command_cases() -> Vec>> { +fn provide_command_cases() -> Vec>> { let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); 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> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + 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> { +fn create_downloader_mock() -> std::rc::Rc> { as_dyn(MockDownloader::new()) } @@ -107,12 +105,14 @@ fn downloader_mock(installation_source: &str) -> MockDownloader { downloader } -fn as_dyn(downloader: MockDownloader) -> Rc> { - Rc::new(RefCell::new(downloader)) as Rc> +fn as_dyn(downloader: MockDownloader) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(downloader)) + as std::rc::Rc> } fn create_manager() -> DownloadManager { - let io = Rc::new(RefCell::new(IOStub::new())) as Rc>; + let io = std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc>; 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(future: F) -> F::Output { } /// ref: TestCase::getConfig -fn get_config(config_options: IndexMap) -> Rc> { +fn get_config( + config_options: IndexMap, +) -> std::rc::Rc> { let mut config = Config::new(false, None); if !config_options.is_empty() { let mut merged: IndexMap = 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) -> Rc> /// 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>>, - config: Option>>, + io: Option>>, + config: Option>>, ) -> ( FileDownloader, - Rc>, + std::rc::Rc>, 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> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + 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> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + 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> = io_mock.clone(); + let io: std::rc::Rc> = 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(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>>, + io: Option>>, config: Option, - process: Rc>, - filesystem: Option>>, + process: std::rc::Rc>, + filesystem: Option>>, ) -> FossilDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc>); + let io = io.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())) + as std::rc::Rc> + }); // 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(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>>, + io: Option>>, config: Option, - process: Rc>, - filesystem: Option>>, + process: std::rc::Rc>, + filesystem: Option>>, ) -> GitDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc>); - 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> + }); + 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>; + let io = io_mock.clone() as std::rc::Rc>; 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>; + let io = io_mock.clone() as std::rc::Rc>; 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(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>>, + io: Option>>, config: Option, - process: Rc>, - filesystem: Option>>, + process: std::rc::Rc>, + filesystem: Option>>, ) -> HgDownloader { - let io = - io.unwrap_or_else(|| Rc::new(RefCell::new(IOStub::new())) as Rc>); - 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> + }); + 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> = Rc::new(RefCell::new(IOStub::new())); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc> = + 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> = Rc::new(RefCell::new(IOStub::new())); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc> = + 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) false, ) .unwrap(); - let io: Rc> = io_mock.clone(); - let config = Rc::new(RefCell::new(get_config(test_path.path()))); + let io: std::rc::Rc> = 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> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut config_options: IndexMap = 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(future: F) -> F::Output { @@ -28,9 +26,9 @@ fn run(future: F) -> F::Output { struct SetUp { test_dir: TempDir, - io: Rc>, - config: Rc>, - http_downloader: Rc>, + io: std::rc::Rc>, + config: std::rc::Rc>, + http_downloader: std::rc::Rc>, 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> = 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::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> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + 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 = 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, diff --git a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs index cabb6794..67059a7c 100644 --- a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs +++ b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs @@ -17,8 +17,6 @@ use shirabe::util::platform::Platform; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PHP_EOL; -use std::cell::RefCell; -use std::rc::Rc; fn tear_down() { Platform::clear_env("COMPOSER_SKIP_SCRIPTS"); @@ -40,9 +38,10 @@ impl Drop for TearDown { /// here drive only command-line / composer-script listeners, which never touch those collaborators, /// so a minimal full Composer carrying a Config and a RootPackage is sufficient. fn create_composer_instance() -> ComposerHandle { - let composer = - ComposerHandle::from_rc_unchecked(Rc::new(RefCell::new(PartialOrFullComposer::new_full()))); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let composer = ComposerHandle::from_rc_unchecked(std::rc::Rc::new(std::cell::RefCell::new( + PartialOrFullComposer::new_full(), + ))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); composer.borrow_mut().set_config(config); let package: RootPackageInterfaceHandle = RootPackageHandle::new( "foo".to_string(), @@ -54,8 +53,8 @@ fn create_composer_instance() -> ComposerHandle { composer } -fn null_io() -> Rc> { - Rc::new(RefCell::new(shirabe::io::null_io::NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(shirabe::io::null_io::NullIO::new())) } /// Locates a `php` executable on PATH and points `PHP_BINARY` at it. @@ -83,8 +82,8 @@ fn ensure_php_binary() -> bool { false } -fn buffer_io_verbose() -> Rc> { - Rc::new(RefCell::new( +fn buffer_io_verbose() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), output_interface::VERBOSITY_VERBOSE, None).unwrap(), )) } @@ -93,8 +92,8 @@ fn buffer_io_verbose() -> Rc> { /// `getMockBuilder(EventDispatcher)->onlyMethods(['getListeners'])`. fn dispatcher_with_listeners( composer: &ComposerHandle, - io: Rc>, - process: Rc>, + io: std::rc::Rc>, + process: std::rc::Rc>, callback: Box Vec>, ) -> EventDispatcher { let mut dispatcher = EventDispatcher::new(composer.upcast().downgrade(), io, Some(process)); @@ -154,7 +153,7 @@ fn test_dispatcher_can_execute_composer_script_groups() { let composer = create_composer_instance(); let io = buffer_io_verbose(); - let io_dyn: Rc> = io.clone(); + let io_dyn: std::rc::Rc> = io.clone(); let callback: Box Vec> = Box::new(|event| match event.get_name() { @@ -205,7 +204,7 @@ fn test_recursion_in_scripts_names() { let composer = create_composer_instance(); let io = buffer_io_verbose(); - let io_dyn: Rc> = io.clone(); + let io_dyn: std::rc::Rc> = io.clone(); let callback: Box Vec> = Box::new(|event| match event.get_name() { diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs index 8685861a..be32dac3 100644 --- a/crates/shirabe/tests/factory_test.rs +++ b/crates/shirabe/tests/factory_test.rs @@ -7,8 +7,6 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::platform::Platform; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[path = "common/config_stub.rs"] mod config_stub; @@ -50,7 +48,7 @@ fn test_default_values_are_as_expected() { .with("disable-tls", PhpMixed::Bool(true)) .build_shared(); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); Factory::create_http_downloader(io, &config, IndexMap::new()).unwrap(); } diff --git a/crates/shirabe/tests/installer/binary_installer_test.rs b/crates/shirabe/tests/installer/binary_installer_test.rs index 6b3cae5d..8b2d0636 100644 --- a/crates/shirabe/tests/installer/binary_installer_test.rs +++ b/crates/shirabe/tests/installer/binary_installer_test.rs @@ -7,9 +7,7 @@ use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::Filesystem; use shirabe::util::ProcessExecutor; -use std::cell::RefCell; use std::fs; -use std::rc::Rc; use tempfile::TempDir; /// Mirror of setUp(): builds temp root/vendor/bin dirs plus a mocked IO. PHP uses a @@ -18,7 +16,7 @@ struct SetUp { root: TempDir, vendor_dir: String, bin_dir: String, - io: Rc>, + io: std::rc::Rc>, fs: Filesystem, } @@ -37,7 +35,8 @@ fn set_up() -> SetUp { let bin_dir = format!("{}/bin", root_dir); fs::create_dir_all(&bin_dir).unwrap(); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); SetUp { root, @@ -94,7 +93,9 @@ fn run_install_and_exec_binary_with_full_compat(contents: &[u8]) { setup.io.clone(), setup.bin_dir.clone(), "full".to_string(), - Some(Rc::new(RefCell::new(Filesystem::new(None)))), + Some(std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new( + None, + )))), None, ); installer.install_binaries(package, &pkg_dir, true); diff --git a/crates/shirabe/tests/installer/installation_manager_test.rs b/crates/shirabe/tests/installer/installation_manager_test.rs index bc1fcfdc..e3e4c0fc 100644 --- a/crates/shirabe/tests/installer/installation_manager_test.rs +++ b/crates/shirabe/tests/installer/installation_manager_test.rs @@ -14,8 +14,6 @@ use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; fn run(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() @@ -27,17 +25,23 @@ fn run(future: F) -> F::Output { /// ref: setUp(): the PHP loop/io mocks are never exercised by these tests (the loop has its /// constructor disabled), so a real Loop over a real HttpDownloader and a NullIO stand in. struct SetUp { - loop_: Rc>, - io: Rc>, + loop_: std::rc::Rc>, + io: std::rc::Rc>, } fn set_up() -> SetUp { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(shirabe::config::Config::new(false, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(shirabe::config::Config::new( + false, None, + ))); // The PHP loop mock has its constructor disabled and is never exercised by these tests, so a // mock HttpDownloader (no real curl backend) stands in. - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock(io.clone(), config))); - let loop_ = Rc::new(RefCell::new(Loop::new(http_downloader, None))); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::__new_mock( + io.clone(), + config, + ))); + let loop_ = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None))); SetUp { loop_, io } } @@ -150,12 +154,12 @@ struct BinaryInstallerCalls { #[derive(Debug)] struct BinaryInstaller { - calls: Rc>, + calls: std::rc::Rc>, } impl BinaryInstaller { - fn new() -> (Self, Rc>) { - let calls = Rc::new(RefCell::new(BinaryInstallerCalls::default())); + fn new() -> (Self, std::rc::Rc>) { + let calls = std::rc::Rc::new(std::cell::RefCell::new(BinaryInstallerCalls::default())); ( Self { calls: calls.clone(), @@ -262,7 +266,7 @@ fn typed_package(name: &str, version: &str, r#type: &str) -> PackageInterfaceHan } fn same_handle(a: &PackageInterfaceHandle, b: &PackageInterfaceHandle) -> bool { - Rc::ptr_eq(a.as_rc(), b.as_rc()) + std::rc::Rc::ptr_eq(a.as_rc(), b.as_rc()) } #[test] diff --git a/crates/shirabe/tests/installer/installer_event_test.rs b/crates/shirabe/tests/installer/installer_event_test.rs index b3bf14df..8a8887ab 100644 --- a/crates/shirabe/tests/installer/installer_event_test.rs +++ b/crates/shirabe/tests/installer/installer_event_test.rs @@ -6,14 +6,13 @@ use shirabe::event_dispatcher::EventInterface; use shirabe::installer::InstallerEvent; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; -use std::cell::RefCell; -use std::rc::Rc; #[test] fn test_getter() { - let composer_rc = Rc::new(RefCell::new(PartialOrFullComposer::new_full())); + let composer_rc = std::rc::Rc::new(std::cell::RefCell::new(PartialOrFullComposer::new_full())); let composer = ComposerHandle::from_rc_unchecked(composer_rc); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let transaction = Transaction::new(vec![], vec![]); let event = InstallerEvent::new( "EVENT_NAME".to_string(), diff --git a/crates/shirabe/tests/installer/library_installer_test.rs b/crates/shirabe/tests/installer/library_installer_test.rs index 44c7e5f7..72272a07 100644 --- a/crates/shirabe/tests/installer/library_installer_test.rs +++ b/crates/shirabe/tests/installer/library_installer_test.rs @@ -16,9 +16,7 @@ use shirabe::repository::RepositoryInterface; use shirabe::repository::WritableRepositoryInterface; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; use std::fs; -use std::rc::Rc; use tempfile::TempDir; // PHP mocks `Composer\Downloader\DownloadManager` with getMockBuilder and asserts its @@ -34,7 +32,7 @@ mockall::mock! { fn get_downloader_for_package( &self, package: PackageInterfaceHandle, - ) -> anyhow::Result>>>; + ) -> anyhow::Result>>>; async fn download( &self, package: PackageInterfaceHandle, @@ -104,7 +102,7 @@ struct SetUp { root: TempDir, vendor_dir: String, bin_dir: String, - io: Rc>, + io: std::rc::Rc>, composer: PartialComposerWeakHandle, fs: Filesystem, composer_full: ComposerHandle, @@ -116,7 +114,7 @@ fn set_download_manager(setup: &SetUp, dm: MockDownloadManager) { setup .composer_full .borrow_mut() - .set_download_manager(Rc::new(RefCell::new(dm))); + .set_download_manager(std::rc::Rc::new(std::cell::RefCell::new(dm))); } fn set_up() -> SetUp { @@ -144,11 +142,12 @@ fn set_up() -> SetUp { let mut merged: IndexMap = IndexMap::new(); merged.insert("config".to_string(), PhpMixed::Array(config_section)); config.merge(&merged, Config::SOURCE_UNKNOWN); - let config_rc = Rc::new(RefCell::new(config)); + let config_rc = std::rc::Rc::new(std::cell::RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); - let composer_rc = Rc::new(RefCell::new(PartialOrFullComposer::new_full())); + let composer_rc = std::rc::Rc::new(std::cell::RefCell::new(PartialOrFullComposer::new_full())); let composer = ComposerHandle::from_rc_unchecked(composer_rc.clone()); composer.borrow_mut().set_config(config_rc); // Default unconfigured mock so LibraryInstaller::new can resolve a DownloadManager even in @@ -156,7 +155,9 @@ fn set_up() -> SetUp { // set_download_manager. composer .borrow_mut() - .set_download_manager(Rc::new(RefCell::new(MockDownloadManager::new()))); + .set_download_manager(std::rc::Rc::new(std::cell::RefCell::new( + MockDownloadManager::new(), + ))); let weak = PartialComposerHandle::from_rc(composer_rc).downgrade(); @@ -236,7 +237,7 @@ fn test_install() { dm.expect_install() .times(1) .withf_st(move |package, target_dir| { - Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) + std::rc::Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) && target_dir == expected_path.as_str() }) .returning(|_, _| Ok(None)); @@ -290,8 +291,8 @@ fn test_update() { dm.expect_update() .times(1) .withf_st(move |initial, target, target_dir| { - Rc::ptr_eq(initial.as_rc(), expected_initial.as_rc()) - && Rc::ptr_eq(target.as_rc(), expected_target.as_rc()) + std::rc::Rc::ptr_eq(initial.as_rc(), expected_initial.as_rc()) + && std::rc::Rc::ptr_eq(target.as_rc(), expected_target.as_rc()) && target_dir == expected_path.as_str() }) .returning(|_, _, _| Ok(None)); @@ -343,7 +344,7 @@ fn test_uninstall() { dm.expect_remove() .times(1) .withf_st(move |package, target_dir| { - Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) + std::rc::Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) && target_dir == expected_path.as_str() }) .returning(|_, _| Ok(None)); @@ -426,12 +427,12 @@ fn test_ensure_binaries_installed() { .expect_install_binaries() .times(1) .withf_st(move |package, install_path, warn_on_overwrite| { - Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) + std::rc::Rc::ptr_eq(package.as_rc(), expected_package.as_rc()) && install_path == expected_install_path.as_str() && !*warn_on_overwrite }) .returning(|_, _, _| ()); - library.__set_binary_installer(Rc::new(RefCell::new(binary_installer))); + library.__set_binary_installer(std::rc::Rc::new(std::cell::RefCell::new(binary_installer))); library.ensure_binaries_presence(package.clone()); diff --git a/crates/shirabe/tests/installer/metapackage_installer_test.rs b/crates/shirabe/tests/installer/metapackage_installer_test.rs index 8528f6a7..bc740e74 100644 --- a/crates/shirabe/tests/installer/metapackage_installer_test.rs +++ b/crates/shirabe/tests/installer/metapackage_installer_test.rs @@ -8,8 +8,6 @@ use shirabe::installer::{InstallerInterface, MetapackageInstaller}; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::repository::{InstalledArrayRepository, RepositoryInterface}; -use std::cell::RefCell; -use std::rc::Rc; fn run(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() @@ -19,7 +17,8 @@ fn run(future: F) -> F::Output { } fn installer() -> MetapackageInstaller { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); MetapackageInstaller::new(io) } diff --git a/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs b/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs index 16650853..046e84e4 100644 --- a/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs +++ b/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs @@ -8,16 +8,18 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::io::null_io::NullIO; use shirabe::repository::{InstalledRepository, LockArrayRepository, RepositoryInterfaceHandle}; -use std::cell::RefCell; -use std::rc::Rc; /// ref: SuggestedPackagesReporterTest::setUp. /// /// Builds an IO mock and a SuggestedPackagesReporter sharing it. The IOMockGuard runs /// assert_complete when it drops at the end of the test scope. -fn set_up() -> (Rc>, SuggestedPackagesReporter, IOMockGuard) { +fn set_up() -> ( + std::rc::Rc>, + SuggestedPackagesReporter, + IOMockGuard, +) { let (mock, guard) = get_io_mock(io_interface::NORMAL).unwrap(); - let io: Rc> = mock.clone(); + let io: std::rc::Rc> = mock.clone(); let reporter = SuggestedPackagesReporter::new(io); (mock, reporter, guard) } @@ -32,7 +34,8 @@ fn get_suggested_package_array() -> IndexMap { } fn reporter() -> SuggestedPackagesReporter { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); SuggestedPackagesReporter::new(io) } diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs index a38c870a..e5006b86 100644 --- a/crates/shirabe/tests/installer_test.rs +++ b/crates/shirabe/tests/installer_test.rs @@ -9,8 +9,6 @@ use config_stub::ConfigStubBuilder; use test_case::{get_package, get_version_constraint}; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; use shirabe::advisory::{AuditConfig, Auditor}; use shirabe::autoload::{AutoloadGeneratorInterface, ClassLoader}; @@ -83,7 +81,7 @@ impl DownloadManagerInterface for StubDownloadManager { fn get_downloader_for_package( &self, _package: PackageInterfaceHandle, - ) -> anyhow::Result>>> { + ) -> anyhow::Result>>> { Ok(None) } async fn download( @@ -186,7 +184,7 @@ impl AutoloadGeneratorInterface for StubAutoloadGenerator { fn set_dry_run(&mut self, _dry_run: bool) {} fn set_platform_requirement_filter( &mut self, - _platform_requirement_filter: Rc, + _platform_requirement_filter: std::rc::Rc, ) { } #[allow(clippy::too_many_arguments)] @@ -348,10 +346,10 @@ fn test_installer() { let _tear_down = TearDown; for case in provide_installer() { - let io_buffer = Rc::new(RefCell::new( + let io_buffer = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_NORMAL, None).unwrap(), )); - let io: Rc> = io_buffer.clone(); + let io: std::rc::Rc> = io_buffer.clone(); let config = ConfigStubBuilder::new() .with("vendor-dir", PhpMixed::String("foo".to_string())) @@ -359,13 +357,12 @@ fn test_installer() { .with("notify-on-install", PhpMixed::Bool(true)) .build_shared(); - let download_manager: Rc> = - Rc::new(RefCell::new(StubDownloadManager)); + let download_manager: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(StubDownloadManager)); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock( - io.clone(), - config.clone(), - ))); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new( + HttpDownloader::__new_mock(io.clone(), config.clone()), + )); let mut repository_manager = RepositoryManager::new( io.clone(), @@ -380,13 +377,19 @@ fn test_installer() { for repository in &case.repositories { repository_manager.add_repository(repository.clone()); } - let repository_manager: Rc> = - Rc::new(RefCell::new(repository_manager)); + let repository_manager: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(repository_manager)); - let r#loop = Rc::new(RefCell::new(Loop::new(http_downloader.clone(), None))); - let installation_manager: Rc> = Rc::new(RefCell::new( - InstallationManager::__new_mock(r#loop, io.clone(), None), - )); + let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new( + http_downloader.clone(), + None, + ))); + let installation_manager: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::__new_mock( + r#loop, + io.clone(), + None, + ))); // emulate a writable lock file: a real JsonFile over a fresh temp path (initially absent, so // the installer falls back to an update; PHP uses an in-memory JsonFile mock instead). @@ -394,17 +397,20 @@ fn test_installer() { let lock_path = lock_dir.path().join("composer.lock"); let lock_json = JsonFile::new(lock_path.to_string_lossy().into_owned(), None, None).unwrap(); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); - let locker: Rc> = Rc::new(RefCell::new(Locker::new( + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( io.clone(), - lock_json, - installation_manager.clone(), - "{}", - process, - ))); - - let autoload_generator: Rc> = - Rc::new(RefCell::new(StubAutoloadGenerator)); + )))); + let locker: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(Locker::new( + io.clone(), + lock_json, + installation_manager.clone(), + "{}", + process, + ))); + + let autoload_generator: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(StubAutoloadGenerator)); let root_package: RootPackageInterfaceHandle = RootPackageInterfaceHandle::dup(&case.root_package.clone().into()); @@ -416,7 +422,7 @@ fn test_installer() { repository_manager, locker, installation_manager.clone(), - Rc::new(RefCell::new(StubEventDispatcher)), + std::rc::Rc::new(std::cell::RefCell::new(StubEventDispatcher)), autoload_generator, ); installer.set_audit_config( @@ -790,10 +796,10 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { return; // markTestSkipped } - let io_buffer = Rc::new(RefCell::new( + let io_buffer = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_NORMAL, None).unwrap(), )); - let io: Rc> = io_buffer.clone(); + let io: std::rc::Rc> = io_buffer.clone(); let is_exception = matches!(case.expect_result, ExpectResult::Exception(_)); @@ -845,9 +851,11 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { // The Locker needs a concrete InstallationManager; build a fresh recording mock just for it. The // asserted trace comes from the composer's own installation manager (read via as_any below). - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let locker_loop = composer.borrow().get_loop(); - let locker_im = Rc::new(RefCell::new(InstallationManager::__new_mock( + let locker_im = std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::__new_mock( locker_loop, io.clone(), None, @@ -856,16 +864,20 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { let locker = Locker::new(io.clone(), lock_json, locker_im, &contents, process); composer .borrow_mut() - .set_locker(Rc::new(RefCell::new(locker))); + .set_locker(std::rc::Rc::new(std::cell::RefCell::new(locker))); composer .borrow_mut() - .set_autoload_generator(Rc::new(RefCell::new(StubAutoloadGenerator))); + .set_autoload_generator(std::rc::Rc::new(std::cell::RefCell::new( + StubAutoloadGenerator, + ))); composer .borrow_mut() - .set_event_dispatcher(Rc::new(RefCell::new(StubEventDispatcher))); + .set_event_dispatcher(std::rc::Rc::new(std::cell::RefCell::new( + StubEventDispatcher, + ))); - let installer = Rc::new(RefCell::new(Installer::create( + let installer = std::rc::Rc::new(std::cell::RefCell::new(Installer::create( io.clone(), &composer.upcast(), ))); @@ -874,9 +886,12 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); - let run_result: Rc>>> = Rc::new(RefCell::new(None)); + let run_result: std::rc::Rc>>> = + std::rc::Rc::new(std::cell::RefCell::new(None)); - let install = Rc::new(RefCell::new(CommandData::new(Some("install".to_string())))); + let install = std::rc::Rc::new(std::cell::RefCell::new(CommandData::new(Some( + "install".to_string(), + )))); { let install_ref = install.borrow(); install_ref @@ -944,10 +959,12 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { })); } application - .add(install.clone() as Rc>) + .add(install.clone() as std::rc::Rc>) .unwrap(); - let update = Rc::new(RefCell::new(CommandData::new(Some("update".to_string())))); + let update = std::rc::Rc::new(std::cell::RefCell::new(CommandData::new(Some( + "update".to_string(), + )))); { let update_ref = update.borrow(); for (name, mode) in [ @@ -1045,7 +1062,7 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { })); } application - .add(update.clone() as Rc>) + .add(update.clone() as std::rc::Rc>) .unwrap(); assert!( @@ -1059,8 +1076,10 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { .expect("php://memory is a valid stream"); let mut string_input = StringInput::new(&format!("{} -vvv", case.run)).unwrap(); string_input.set_interactive(false); - let input: Rc> = Rc::new(RefCell::new(string_input)); - let output: Rc> = Rc::new(RefCell::new(app_output)); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(string_input)); + let output: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(app_output)); let app_run = application.run(Some(input), Some(output)); diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs index 9df851ec..62cb8322 100644 --- a/crates/shirabe/tests/io/console_io_test.rs +++ b/crates/shirabe/tests/io/console_io_test.rs @@ -23,17 +23,17 @@ use shirabe_external_packages::symfony::console::input::streamable_input_interfa use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; /// Builds a ConsoleIO backed by real, side-effect-free Input/Output/QuestionHelper. PHP uses /// PHPUnit mocks here, but for tests that exercise only the authentication map they carry no /// expectations, so concrete implementations are an exact substitute. fn make_console_io() -> ConsoleIO { - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); ConsoleIO::new(input, output, QuestionHelper::default()) } @@ -49,12 +49,17 @@ fn get_input_stream(input: &str) -> shirabe_php_shim::PhpResource { /// Builds a ConsoleIO whose interactive input stream yields `answer`, plus a handle on the /// `BufferedOutput` so the prompt can be inspected. The input is an `ArrayInput` (interactive by /// default) with the answer stream attached, exactly as the question-helper tests set things up. -fn make_console_io_with_answer(answer: &str) -> (ConsoleIO, Rc>) { +fn make_console_io_with_answer( + answer: &str, +) -> (ConsoleIO, std::rc::Rc>) { let mut array_input = ArrayInput::new(vec![], None).unwrap(); array_input.set_stream(get_input_stream(answer)); - let input: Rc> = Rc::new(RefCell::new(array_input)); - let buffered = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let output: Rc> = buffered.clone(); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(array_input)); + let buffered = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let output: std::rc::Rc> = buffered.clone(); ( ConsoleIO::new(input, output, QuestionHelper::default()), buffered, @@ -66,9 +71,11 @@ fn test_is_interactive() { // PHP mocks isInteractive to return true then false on consecutive calls. A real ArrayInput // exposes a mutable interactive flag, so toggling it between the two asserts is equivalent. let array_input = ArrayInput::new(vec![], None).unwrap(); - let input: Rc> = Rc::new(RefCell::new(array_input)); - let output: Rc> = - Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); + let input: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(array_input)); + let output: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(BufferedOutput::new(None, false, None)), + ); let console_io = ConsoleIO::new(input.clone(), output, QuestionHelper::default()); input.borrow_mut().set_interactive(true); @@ -82,10 +89,13 @@ fn test_write() { // PHP: expects write('some information about something', false) at VERBOSITY_NORMAL. // A plain (non-Console) OutputInterface routes write to the main output, so the message lands // in the BufferedOutput verbatim (no trailing EOL since newline is false). - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); - let buffered = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let output: Rc> = buffered.clone(); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); + let buffered = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let output: std::rc::Rc> = buffered.clone(); let console_io = ConsoleIO::new(input, output, QuestionHelper::default()); console_io.write3("some information about something", false, NORMAL); @@ -123,10 +133,13 @@ fn test_overwrite() { // "\x08" * 12 (clear previous, len = 12) // 'something longer than initial (34)' (new message) // The final overwrite needs no fill and newline defaults true, appending a trailing "\n". - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); - let buffered = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let output: Rc> = buffered.clone(); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); + let buffered = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( + None, false, None, + ))); + let output: std::rc::Rc> = buffered.clone(); let console_io = ConsoleIO::new(input, output, QuestionHelper::default()); console_io.write3("something (strlen = 23)", true, NORMAL); diff --git a/crates/shirabe/tests/package/archiver/archive_manager_test.rs b/crates/shirabe/tests/package/archiver/archive_manager_test.rs index b275692b..4f28b468 100644 --- a/crates/shirabe/tests/package/archiver/archive_manager_test.rs +++ b/crates/shirabe/tests/package/archiver/archive_manager_test.rs @@ -16,8 +16,6 @@ use shirabe_external_packages::symfony::process::Process; use shirabe_php_shim::{ PhpMixed, file_exists, file_put_contents, realpath, sys_get_temp_dir, unlink, }; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; // ref: ArchiverTestCase::setUp + ArchiveManagerTest::setUp. @@ -36,30 +34,34 @@ impl TestCase { let guard = TempDir::new().unwrap(); let test_dir = guard.path().to_string_lossy().to_string(); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(false, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); // The filename/unknown-format tests never drive the download path, so a mock // HttpDownloader (no curl backend) is sufficient to satisfy Loop's dependency. - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock( + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new( + HttpDownloader::__new_mock(io.clone(), config.clone()), + )); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( io.clone(), - config.clone(), - ))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); - let fs = Rc::new(RefCell::new(Filesystem::new(Some(process.clone())))); + )))); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(Some( + process.clone(), + )))); let mut dm = DownloadManager::new(io.clone(), false, Some(fs.clone())); // Factory::createDownloadManager registers a git downloader; the archive tests clone the // package source (source type 'git') through it. dm.set_downloader( "git", - Rc::new(RefCell::new(GitDownloader::new( + std::rc::Rc::new(std::cell::RefCell::new(GitDownloader::new( io.clone(), config.clone(), Some(process.clone()), Some(fs.clone()), ))), ); - let dm = Rc::new(RefCell::new(dm)); - let r#loop = Rc::new(RefCell::new(Loop::new(http_downloader, None))); + let dm = std::rc::Rc::new(std::cell::RefCell::new(dm)); + let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None))); let mut manager = ArchiveManager::new(dm, r#loop); manager.add_archiver(Box::new(ZipArchiver::new())); diff --git a/crates/shirabe/tests/package/loader/root_package_loader_test.rs b/crates/shirabe/tests/package/loader/root_package_loader_test.rs index 6a13736d..069cf5a7 100644 --- a/crates/shirabe/tests/package/loader/root_package_loader_test.rs +++ b/crates/shirabe/tests/package/loader/root_package_loader_test.rs @@ -21,18 +21,16 @@ use shirabe::util::Git as GitUtil; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } fn http_downloader( - io: &Rc>, - config: &Rc>, -) -> Rc> { - Rc::new(RefCell::new(HttpDownloader::new( + io: &std::rc::Rc>, + config: &std::rc::Rc>, +) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config.clone(), IndexMap::new(), @@ -41,8 +39,8 @@ fn http_downloader( } // `$config = new Config; $config->merge(['repositories' => ['packagist' => false]]);` -fn make_config() -> Rc> { - let config = Rc::new(RefCell::new(Config::new(true, None))); +fn make_config() -> std::rc::Rc> { + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); let mut repositories: IndexMap = IndexMap::new(); repositories.insert("packagist".to_string(), PhpMixed::Bool(false)); let mut merge: IndexMap = IndexMap::new(); @@ -54,10 +52,10 @@ fn make_config() -> Rc> { // Stands in for `getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()`. // The loader only stores it and feeds it default repositories, so a real instance suffices. fn make_manager( - io: &Rc>, - config: &Rc>, -) -> Rc> { - Rc::new(RefCell::new(RepositoryManager::new( + io: &std::rc::Rc>, + config: &std::rc::Rc>, +) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(RepositoryManager::new( io.clone(), config.clone(), http_downloader(io, config), @@ -103,7 +101,7 @@ mockall::mock! { #[ignore = "process_executor.enable_async() drives the async stream path, which calls stream_set_blocking (fcntl(2) todo!() in shirabe-php-shim::stream)"] fn test_stability_flags_parsing() { let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); { let mut cfg = IndexMap::new(); cfg.insert( @@ -117,7 +115,7 @@ fn test_stability_flags_parsing() { config.borrow_mut().merge(&cfg, "test"); } - let manager = Rc::new(RefCell::new(RepositoryManager::new( + let manager = std::rc::Rc::new(std::cell::RefCell::new(RepositoryManager::new( io.clone(), config.clone(), http_downloader(&io, &config), @@ -129,7 +127,7 @@ fn test_stability_flags_parsing() { process_executor.enable_async(); let guesser = VersionGuesser::new( config.clone(), - Rc::new(RefCell::new(process_executor)), + std::rc::Rc::new(std::cell::RefCell::new(process_executor)), VersionParser::new(), Some(io.clone()), ); diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs index bbc333e7..fc66293b 100644 --- a/crates/shirabe/tests/package/locker_test.rs +++ b/crates/shirabe/tests/package/locker_test.rs @@ -14,21 +14,24 @@ use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe::util::process_executor::ProcessExecutor; use shirabe_php_shim::{LogicException, PhpMixed, hash}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } -fn installation_manager(io: &Rc>) -> Rc> { +fn installation_manager( + io: &std::rc::Rc>, +) -> std::rc::Rc> { // These tests never reach Locker::get_package_time, so the InstallationManager is never // actually used; build it over a mock HttpDownloader to avoid the unimplemented curl backend. - let config = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::__new_mock(io.clone(), config))); - let r#loop = Rc::new(RefCell::new(Loop::new(http_downloader, None))); - Rc::new(RefCell::new(InstallationManager::new( + let 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(), + config, + ))); + let r#loop = std::rc::Rc::new(std::cell::RefCell::new(Loop::new(http_downloader, None))); + std::rc::Rc::new(std::cell::RefCell::new(InstallationManager::new( r#loop, io.clone(), None, @@ -57,7 +60,11 @@ fn get_json_content(custom_data: &[(&str, &str)]) -> String { fn make_locker( json_content: &str, lock_contents: Option<&str>, -) -> (Locker, TempDir, Rc>) { +) -> ( + Locker, + TempDir, + std::rc::Rc>, +) { let temp_dir = TempDir::new().unwrap(); let lock_path = temp_dir.path().join("composer.lock"); if let Some(contents) = lock_contents { @@ -66,7 +73,9 @@ fn make_locker( let io = null_io(); let json_file = JsonFile::new(lock_path.to_string_lossy().into_owned(), None, None).unwrap(); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let locker = Locker::new( io.clone(), json_file, diff --git a/crates/shirabe/tests/package/version/version_guesser_test.rs b/crates/shirabe/tests/package/version/version_guesser_test.rs index 1a3f23c1..92d5e90b 100644 --- a/crates/shirabe/tests/package/version/version_guesser_test.rs +++ b/crates/shirabe/tests/package/version/version_guesser_test.rs @@ -9,8 +9,6 @@ use shirabe::util::Git as GitUtil; use shirabe::util::platform::Platform; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; // Mirrors VersionGuesserTest::setUp/tearDown: reset GitUtil's cached `version` // static so each test re-runs `git --version` against its own mock. @@ -27,19 +25,19 @@ impl Drop for TearDown { } // `$config = new Config; $config->merge(['repositories' => ['packagist' => false]]);` -fn make_config() -> Rc> { +fn make_config() -> std::rc::Rc> { let mut config = Config::new(true, None); let mut repositories: IndexMap = IndexMap::new(); repositories.insert("packagist".to_string(), PhpMixed::Bool(false)); let mut merge: IndexMap = IndexMap::new(); merge.insert("repositories".to_string(), PhpMixed::Array(repositories)); config.merge(&merge, Config::SOURCE_UNKNOWN); - Rc::new(RefCell::new(config)) + std::rc::Rc::new(std::cell::RefCell::new(config)) } fn make_guesser( - config: Rc>, - process: Rc>, + config: std::rc::Rc>, + process: std::rc::Rc>, ) -> VersionGuesser { VersionGuesser::new(config, process, VersionParser::new(), None) } @@ -615,8 +613,8 @@ fn test_get_root_version_from_env() { for (env, expected_version) in root_env_versions { Platform::put_env("COMPOSER_ROOT_VERSION", env); - let config = Rc::new(RefCell::new(Config::new(true, None))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let guesser = VersionGuesser::new(config, process, VersionParser::new(), None); assert_eq!( expected_version, diff --git a/crates/shirabe/tests/package/version/version_selector_test.rs b/crates/shirabe/tests/package/version/version_selector_test.rs index 3a0c7019..70874bcb 100644 --- a/crates/shirabe/tests/package/version/version_selector_test.rs +++ b/crates/shirabe/tests/package/version/version_selector_test.rs @@ -19,8 +19,6 @@ use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PhpMixed; use shirabe_php_shim::{PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION}; use shirabe_semver::constraint::AnyConstraint; -use std::cell::RefCell; -use std::rc::Rc; mockall::mock! { RepositorySet {} @@ -41,8 +39,10 @@ impl std::fmt::Debug for MockRepositorySet { } } -fn into_seam(mock: MockRepositorySet) -> Rc> { - Rc::new(RefCell::new(mock)) +fn into_seam( + mock: MockRepositorySet, +) -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(mock)) } /// Mirrors PHPUnit `assertSame($expected, $best)`: object identity, not value equality. @@ -77,7 +77,7 @@ fn find_best( dyn shirabe::filter::platform_requirement_filter::PlatformRequirementFilterInterface, >, >, - io: Option>>, + io: Option>>, ) -> Option { version_selector .find_best_candidate( @@ -159,10 +159,10 @@ fn test_latest_version_is_returned_that_matches_php_requirements() { let mut version_selector = VersionSelector::new(into_seam(repository_set), Some(&mut platform)).unwrap(); - let io = Rc::new(RefCell::new( + let io = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), output_interface::VERBOSITY_NORMAL, None).unwrap(), )); - let io_dyn: Rc> = io.clone(); + let io_dyn: std::rc::Rc> = io.clone(); let best = find_best( &mut version_selector, package_name, @@ -180,10 +180,10 @@ fn test_latest_version_is_returned_that_matches_php_requirements() { io.borrow().get_output() ); - let io = Rc::new(RefCell::new( + let io = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), output_interface::VERBOSITY_VERBOSE, None).unwrap(), )); - let io_dyn: Rc> = io.clone(); + let io_dyn: std::rc::Rc> = io.clone(); let best = find_best( &mut version_selector, package_name, diff --git a/crates/shirabe/tests/question/strict_confirmation_question_test.rs b/crates/shirabe/tests/question/strict_confirmation_question_test.rs index d8606ebe..37d57117 100644 --- a/crates/shirabe/tests/question/strict_confirmation_question_test.rs +++ b/crates/shirabe/tests/question/strict_confirmation_question_test.rs @@ -7,8 +7,6 @@ use shirabe_external_packages::symfony::console::input::streamable_input_interfa use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_external_packages::symfony::console::output::stream_output::StreamOutput; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; const TRUE_ANSWER_REGEX: &str = "/^y(?:es)?$/i"; const FALSE_ANSWER_REGEX: &str = "/^no?$/i"; @@ -111,12 +109,12 @@ fn get_input_stream(input: &str) -> shirabe_php_shim::PhpResource { stream } -fn create_output_interface() -> Rc> { +fn create_output_interface() -> std::rc::Rc> { let stream = shirabe_php_shim::php_fopen_resource("php://memory", "r+"); let output = StreamOutput::new(stream, None, None, None) .unwrap() .expect("php://memory is a valid stream"); - Rc::new(RefCell::new(output)) + std::rc::Rc::new(std::cell::RefCell::new(output)) } /// @return array{ArrayInput, QuestionHelper} diff --git a/crates/shirabe/tests/repository/artifact_repository_test.rs b/crates/shirabe/tests/repository/artifact_repository_test.rs index 558ee8b1..2bfe85de 100644 --- a/crates/shirabe/tests/repository/artifact_repository_test.rs +++ b/crates/shirabe/tests/repository/artifact_repository_test.rs @@ -4,8 +4,6 @@ use indexmap::IndexMap; use shirabe::io::{IOInterface, NullIO}; use shirabe::repository::ArtifactRepository; use shirabe_php_shim::{PhpMixed, extension_loaded}; -use std::cell::RefCell; -use std::rc::Rc; /// Returns true when the test should be skipped because the zip extension is /// unavailable, mirroring PHP's markTestSkipped in setUp. @@ -29,7 +27,8 @@ fn create_repo(url: &str) -> ArtifactRepository { coordinates.insert("type".to_string(), PhpMixed::String("artifact".to_string())); coordinates.insert("url".to_string(), PhpMixed::String(url.to_string())); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); ArtifactRepository::new(coordinates, io).unwrap() } diff --git a/crates/shirabe/tests/repository/composer_repository_test.rs b/crates/shirabe/tests/repository/composer_repository_test.rs index 8e5a7f12..613dbb8e 100644 --- a/crates/shirabe/tests/repository/composer_repository_test.rs +++ b/crates/shirabe/tests/repository/composer_repository_test.rs @@ -11,8 +11,6 @@ use shirabe::repository::composer_repository::{ComposerRepository, ProviderListi use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, SimpleConstraint}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; // Mirrors PHP's `['url' => .., 'body' => ..]` mock entry (status defaults to 200, @@ -53,8 +51,8 @@ fn create_config_read_only() -> (Config, TempDir) { (config, home) } -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } fn repo_config(url: &str) -> IndexMap { @@ -250,9 +248,9 @@ fn test_what_provides() { ) .unwrap(); - let rc = Rc::new(RefCell::new(repo)); - let rc_dyn: Rc> = rc.clone(); - rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + let rc = std::rc::Rc::new(std::cell::RefCell::new(repo)); + let rc_dyn: std::rc::Rc> = rc.clone(); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc_dyn)); let mut provider_listing: IndexMap = IndexMap::new(); provider_listing.insert("a".to_string(), ProviderListingEntry { sha256 }); diff --git a/crates/shirabe/tests/repository/filesystem_repository_test.rs b/crates/shirabe/tests/repository/filesystem_repository_test.rs index e8bdddb2..f9d03ecd 100644 --- a/crates/shirabe/tests/repository/filesystem_repository_test.rs +++ b/crates/shirabe/tests/repository/filesystem_repository_test.rs @@ -15,8 +15,6 @@ use shirabe::repository::filesystem_repository::FilesystemRepository; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; -use std::cell::RefCell; -use std::rc::Rc; /// PHP mocks JsonFile::read()/exists(); without a mocking framework the canned read value is /// materialized as a real temp file whose decoded JSON reproduces the mock return value exactly. @@ -107,14 +105,14 @@ mockall::mock! { fn execute( &mut self, repo: &mut dyn InstalledRepositoryInterface, - operations: Vec>, + operations: Vec>, dev_mode: bool, run_scripts: bool, download_only: bool, ) -> anyhow::Result<()>; fn get_install_path(&mut self, package: PackageInterfaceHandle) -> Option; fn set_output_progress(&mut self, output_progress: bool); - fn notify_installs(&mut self, io: Rc>); + fn notify_installs(&mut self, io: std::rc::Rc>); } } diff --git a/crates/shirabe/tests/repository/path_repository_test.rs b/crates/shirabe/tests/repository/path_repository_test.rs index f86d659d..1cd034d2 100644 --- a/crates/shirabe/tests/repository/path_repository_test.rs +++ b/crates/shirabe/tests/repository/path_repository_test.rs @@ -11,8 +11,6 @@ use shirabe::util::{Platform, ProcessExecutor}; use shirabe_php_shim::{ DIRECTORY_SEPARATOR, PhpMixed, file_get_contents, hash, realpath, serialize, }; -use std::cell::RefCell; -use std::rc::Rc; fn fixtures_dir() -> String { format!( @@ -23,14 +21,15 @@ fn fixtures_dir() -> String { /// ref: PathRepositoryTest::createPathRepo fn create_path_repo(options: IndexMap) -> PathRepository { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); - let proc = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); + let proc = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); // ref: createPathRepo wires the ProcessExecutor through a Loop so the VersionGuesser's async // git calls are permitted; constructing the Loop calls enable_async() on the shared executor. - 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/repository/repository_factory_test.rs b/crates/shirabe/tests/repository/repository_factory_test.rs index ef523808..287e7a4e 100644 --- a/crates/shirabe/tests/repository/repository_factory_test.rs +++ b/crates/shirabe/tests/repository/repository_factory_test.rs @@ -7,14 +7,13 @@ use shirabe::io::null_io::NullIO; use shirabe::repository::RepositoryFactory; use shirabe::util::http_downloader::HttpDownloader; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[test] fn test_manager_with_all_repository_types() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(false, None))); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let 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(), config.clone(), IndexMap::new(), diff --git a/crates/shirabe/tests/repository/repository_manager_test.rs b/crates/shirabe/tests/repository/repository_manager_test.rs index c67cec49..2eac5265 100644 --- a/crates/shirabe/tests/repository/repository_manager_test.rs +++ b/crates/shirabe/tests/repository/repository_manager_test.rs @@ -14,8 +14,6 @@ use shirabe::repository::{ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloader; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -50,13 +48,15 @@ impl Drop for TearDown { } } -fn null_io() -> Rc> { - Rc::new(RefCell::new(NullIO::new())) +fn null_io() -> std::rc::Rc> { + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } -fn http_downloader(io: &Rc>) -> Rc> { - let config = Rc::new(RefCell::new(Config::new(false, None))); - Rc::new(RefCell::new(HttpDownloader::new( +fn http_downloader( + io: &std::rc::Rc>, +) -> std::rc::Rc> { + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); + std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config, IndexMap::new(), @@ -78,7 +78,7 @@ fn test_prepend() { let _tear_down = TearDown::new(tmpdir.path().to_path_buf()); let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(false, None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); let mut rm = RepositoryManager::new(io.clone(), config, http_downloader(&io), None, None); let repository1 = RepositoryInterfaceHandle::new(ArrayRepository::new(vec![]).unwrap()); @@ -96,7 +96,7 @@ fn test_repo_creation() { let _tear_down = TearDown::new(tmpdir.path().to_path_buf()); let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(false, None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); let mut rm = RepositoryManager::new(io.clone(), config.clone(), http_downloader(&io), None, None); @@ -181,7 +181,7 @@ fn test_invalid_repo_creation_throws() { let _tear_down = TearDown::new(tmpdir.path().to_path_buf()); let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(false, None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); let rm = RepositoryManager::new(io.clone(), config.clone(), http_downloader(&io), None, None); config.borrow_mut().merge( @@ -217,7 +217,7 @@ fn test_filter_repo_wrapping() { let _tear_down = TearDown::new(tmpdir.path().to_path_buf()); let io = null_io(); - let config = Rc::new(RefCell::new(Config::new(false, None))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(false, None))); let mut rm = RepositoryManager::new(io.clone(), config, http_downloader(&io), None, None); rm.set_repository_class("path", "Composer\\Repository\\PathRepository"); diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs index 296309f4..d9138b0c 100644 --- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs @@ -11,14 +11,12 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { home: TempDir, - config: Rc>, - io: Rc>, + config: std::rc::Rc>, + io: std::rc::Rc>, } fn set_up() -> SetUp { @@ -39,11 +37,12 @@ fn set_up() -> SetUp { // PHP mocks IOInterface with isInteractive() => true; on the passing (200) paths // exercised here the interactivity flag is never consulted, so a bare NullIO matches. - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); SetUp { home, - config: Rc::new(RefCell::new(config)), + config: std::rc::Rc::new(std::cell::RefCell::new(config)), io, } } @@ -73,7 +72,7 @@ impl Drop for TearDown { fn initialize_driver( set_up: &SetUp, repo_url: &str, - http_downloader: Rc>, + http_downloader: std::rc::Rc>, ) -> (ForgejoDriver, ProcessExecutorMockGuard) { let (process, process_guard) = get_process_executor_mock(vec![], false, MockHandler::default()); @@ -93,7 +92,10 @@ fn initialize_driver( fn http_mock( expectations: Vec, -) -> (Rc>, HttpDownloaderMockGuard) { +) -> ( + std::rc::Rc>, + HttpDownloaderMockGuard, +) { get_http_downloader_mock(expectations, true, HttpDownloaderMockHandler::default()) } diff --git a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs index 1a5a4256..77c1f130 100644 --- a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs @@ -7,8 +7,6 @@ use shirabe::io::null_io::NullIO; use shirabe::repository::vcs::FossilDriver; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -66,8 +64,9 @@ fn support_provider() -> Vec<(&'static str, bool)> { #[test] fn test_support() { for (url, assertion) in support_provider() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); let result = FossilDriver::supports(io, config, url, false).unwrap(); assert_eq!(assertion, result); } diff --git a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs index 124d5291..4d84bcf2 100644 --- a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs @@ -11,8 +11,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::ProcessExecutor; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -70,14 +68,16 @@ fn http_body( // then calls initialize(). fn get_driver( url: &str, - io: Rc>, - config: Rc>, - http_downloader: Rc>, + io: std::rc::Rc>, + config: std::rc::Rc>, + http_downloader: std::rc::Rc>, ) -> anyhow::Result { let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(url.to_string())); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); let mut driver = GitBitbucketDriver::new(repo_config, io, config, http_downloader, process); driver.initialize()?; @@ -89,8 +89,9 @@ fn test_get_root_identifier_wrong_scm_type() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock( vec![http_body( @@ -124,8 +125,9 @@ fn test_driver() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let urls = [ "https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner", @@ -238,8 +240,9 @@ fn test_initialize_invalid_repository_url() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard) = get_http_downloader_mock(vec![], true, HttpDownloaderMockHandler::default()); @@ -257,8 +260,9 @@ fn test_invalid_support_data() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let repo_url = "https://bitbucket.org/user/repo.git"; @@ -306,8 +310,9 @@ fn test_invalid_support_data() { #[test] fn test_supports() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); assert!( GitBitbucketDriver::supports( diff --git a/crates/shirabe/tests/repository/vcs/git_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_driver_test.rs index be26dd1d..7a85d4cc 100644 --- a/crates/shirabe/tests/repository/vcs/git_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/git_driver_test.rs @@ -13,8 +13,6 @@ use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::platform::Platform; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -80,8 +78,9 @@ fn test_get_root_identifier_from_remote_local_repository() { let home_path = home.path().to_string_lossy().into_owned(); let _tear_down = TearDown::new(home.path().to_path_buf(), network_env); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -114,8 +113,9 @@ fn test_get_root_identifier_from_remote() { let home_path = home.path().to_string_lossy().into_owned(); let _tear_down = TearDown::new(home.path().to_path_buf(), network_env); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -182,8 +182,9 @@ fn test_get_root_identifier_from_local_with_network_disabled() { Platform::put_env("COMPOSER_DISABLE_NETWORK", "1"); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -218,8 +219,9 @@ fn test_get_branches_filter_invalid_branch_names() { let home_path = home.path().to_string_lossy().into_owned(); let _tear_down = TearDown::new(home.path().to_path_buf(), network_env); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -270,8 +272,9 @@ fn test_file_get_content_invalid_identifier() { } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf(), network_env); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -302,8 +305,9 @@ fn test_get_change_date_invalid_identifier() { } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf(), network_env); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); diff --git a/crates/shirabe/tests/repository/vcs/github_driver_test.rs b/crates/shirabe/tests/repository/vcs/github_driver_test.rs index 11da393a..5b8367c7 100644 --- a/crates/shirabe/tests/repository/vcs/github_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/github_driver_test.rs @@ -15,8 +15,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -136,8 +134,9 @@ fn test_supports() { let _tear_down = TearDown::new(home.path().to_path_buf()); for (expected, repo_url) in supports_provider() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); assert_eq!( expected, @@ -157,13 +156,14 @@ fn test_private_repository() { let identifier = "v0.0.0"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new() - .with_is_interactive(true) - .with_ask_and_hide_answer(Some("sometoken".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_is_interactive(true) + .with_ask_and_hide_answer(Some("sometoken".to_string())), + )); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock( vec![ @@ -239,9 +239,10 @@ fn test_public_repository() { let identifier = "v0.0.0"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![http_body( @@ -252,7 +253,7 @@ fn test_public_repository() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); @@ -296,9 +297,10 @@ fn test_public_repository2() { let identifier = "feature/3.2-foo"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![ @@ -329,7 +331,7 @@ fn test_public_repository2() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); @@ -379,9 +381,10 @@ fn test_invalid_support_data() { let identifier = "feature/3.2-foo"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![ @@ -412,7 +415,7 @@ fn test_invalid_support_data() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); @@ -522,9 +525,10 @@ fn test_funding_format() { let identifier = "feature/3.2-foo"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![ @@ -552,7 +556,7 @@ fn test_funding_format() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); @@ -621,9 +625,10 @@ fn test_public_repository_archived() { sha ); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![ @@ -657,7 +662,7 @@ fn test_public_repository_archived() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); @@ -688,9 +693,10 @@ fn test_private_repository_no_interaction() { let identifier = "v0.0.0"; let sha = "SOMESHA"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(false))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(false)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![http_status(repo_api_url, 404)], @@ -810,12 +816,13 @@ fn test_initialize_invalid_repo_url() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard) = get_http_downloader_mock(vec![], true, HttpDownloaderMockHandler::default()); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(url.to_string())); @@ -838,9 +845,10 @@ fn test_get_empty_file_content() { let repo_url = "http://github.com/composer/packagist"; - let config = Rc::new(RefCell::new(config)); - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_is_interactive(true))); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_is_interactive(true)), + ); let (http_downloader, _http_guard) = get_http_downloader_mock( vec![ @@ -857,7 +865,7 @@ fn test_get_empty_file_content() { HttpDownloaderMockHandler::default(), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(repo_url.to_string())); diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs index f3648630..1a201ba0 100644 --- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs @@ -10,8 +10,6 @@ use shirabe::repository::vcs::GitLabDriver; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::{PhpMixed, extension_loaded}; -use std::cell::RefCell; -use std::rc::Rc; // Mirrors GitLabDriverTest::setUp's `gitlab-domains` configuration. fn make_config() -> Config { @@ -38,15 +36,16 @@ fn make_config() -> Config { // bare `getMock()` ProcessExecutor; none of these tests invoke git, so an empty // strict expectation set both matches PHP and catches unexpected process calls. struct Fixtures { - io: Rc>, - config: Rc>, - process: Rc>, + io: std::rc::Rc>, + config: std::rc::Rc>, + process: std::rc::Rc>, _process_guard: ProcessExecutorMockGuard, } fn fixtures() -> Fixtures { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(make_config())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(make_config())); let (process, _process_guard) = get_process_executor_mock(vec![], true, MockHandler::default()); Fixtures { io, @@ -60,7 +59,10 @@ fn fixtures() -> Fixtures { fn http_mock_with_body( url: &str, body: &str, -) -> (Rc>, HttpDownloaderMockGuard) { +) -> ( + std::rc::Rc>, + HttpDownloaderMockGuard, +) { get_http_downloader_mock( vec![expect_full(url, None, 200, body, vec![String::new()])], true, @@ -625,8 +627,9 @@ fn test_get_branches() { #[test] fn test_supports() { for (url, expected) in data_for_test_supports() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(make_config())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(make_config())); assert_eq!( expected, @@ -867,7 +870,7 @@ fn test_protocol_override_repository_url_generation() { ); top.insert("config".to_string(), PhpMixed::Array(config_section)); config.merge(&top, Config::SOURCE_UNKNOWN); - let config = Rc::new(RefCell::new(config)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); let mut repo_config: IndexMap = IndexMap::new(); repo_config.insert("url".to_string(), PhpMixed::String(url.to_string())); diff --git a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs index 5e16c679..be36f412 100644 --- a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs @@ -12,8 +12,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -70,8 +68,9 @@ fn supports_data_provider() -> Vec<&'static str> { #[test] fn test_supports() { for repository_url in supports_data_provider() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); assert!(HgDriver::supports(io, config, repository_url, false).unwrap()); } @@ -82,8 +81,9 @@ fn test_get_branches_filter_invalid_branch_names() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -120,8 +120,9 @@ fn test_file_get_content_invalid_identifier() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); @@ -148,8 +149,9 @@ fn test_get_change_date_invalid_identifier() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); diff --git a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs index 13b36a3c..ea7976fd 100644 --- a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs @@ -10,8 +10,6 @@ use shirabe::util::HttpDownloader; use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; const TEST_URL: &str = "TEST_PERFORCE_URL"; @@ -92,9 +90,10 @@ fn make_driver( config: Config, repo_config: &IndexMap, ) -> (PerforceDriver, ProcessExecutorMockGuard) { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(config)); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config.clone(), IndexMap::new(), @@ -130,8 +129,9 @@ impl Drop for TearDown { #[test] fn test_supports_returns_false_no_deep_check() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); assert!(!PerforceDriver::supports(io, config, "existing.url", false).unwrap()); } diff --git a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs index 70eeeadc..6a74063d 100644 --- a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs @@ -12,8 +12,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -69,8 +67,9 @@ fn support_provider() -> Vec<(&'static str, bool)> { #[test] fn test_support() { for (url, assertion) in support_provider() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); assert_eq!( assertion, @@ -84,8 +83,9 @@ fn test_wrong_credentials_in_url() { let SetUp { home, config } = set_up(); let _tear_down = TearDown::new(home.path().to_path_buf()); - let config = Rc::new(RefCell::new(config)); - let console: Rc> = Rc::new(RefCell::new(IOStub::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let console: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let (http_downloader, _http_guard): (_, HttpDownloaderMockGuard) = get_http_downloader_mock(vec![], false, HttpDownloaderMockHandler::default()); diff --git a/crates/shirabe/tests/repository/vcs_repository_test.rs b/crates/shirabe/tests/repository/vcs_repository_test.rs index 1ee72cb8..9ae3eac4 100644 --- a/crates/shirabe/tests/repository/vcs_repository_test.rs +++ b/crates/shirabe/tests/repository/vcs_repository_test.rs @@ -11,8 +11,6 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -196,16 +194,19 @@ fn test_load_versions() { ); top.insert("config".to_string(), PhpMixed::Array(config_section)); config.merge(&top, Config::SOURCE_UNKNOWN); - let config = Rc::new(RefCell::new(config)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let http_downloader = std::rc::Rc::new(std::cell::RefCell::new(HttpDownloader::new( io.clone(), config.clone(), IndexMap::new(), false, ))); - let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(Some( + io.clone(), + )))); // VcsRepository's git driver / VersionGuesser run async git processes; constructing a Loop // enables async on the shared ProcessExecutor. let _loop = Loop::new(http_downloader.clone(), Some(process.clone())); diff --git a/crates/shirabe/tests/script/event_test.rs b/crates/shirabe/tests/script/event_test.rs index e249269d..e4fea99d 100644 --- a/crates/shirabe/tests/script/event_test.rs +++ b/crates/shirabe/tests/script/event_test.rs @@ -9,13 +9,12 @@ use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::package::{RootPackageHandle, RootPackageInterfaceHandle}; use shirabe::script::{Event, OriginatingEvent}; -use std::cell::RefCell; -use std::rc::Rc; fn create_composer_instance() -> ComposerHandle { - let composer = - ComposerHandle::from_rc_unchecked(Rc::new(RefCell::new(PartialOrFullComposer::new_full()))); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let composer = ComposerHandle::from_rc_unchecked(std::rc::Rc::new(std::cell::RefCell::new( + PartialOrFullComposer::new_full(), + ))); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); composer.borrow_mut().set_config(config); let package: RootPackageInterfaceHandle = RootPackageHandle::new( "foo".to_string(), @@ -29,7 +28,8 @@ fn create_composer_instance() -> ComposerHandle { #[test] fn test_event_sets_originating_event() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let composer = create_composer_instance(); let originating_event = BaseEvent::new("originatingEvent".to_string(), vec![], IndexMap::new()); @@ -62,7 +62,8 @@ fn test_event_sets_originating_event() { #[test] fn test_event_calculates_nested_originating_event() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let composer = create_composer_instance(); let originating_event = diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs index 905cbf7f..d719abf3 100644 --- a/crates/shirabe/tests/util/auth_helper_test.rs +++ b/crates/shirabe/tests/util/auth_helper_test.rs @@ -8,21 +8,19 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::{AuthHelper, Bitbucket, StoreAuth}; use shirabe_php_shim::{PhpMixed, base64_encode, json_encode}; -use std::cell::RefCell; -use std::rc::Rc; // Mirrors AuthHelperTest::setUp: a DEBUG-verbosity IOMock plus a real Config, both // shared with the AuthHelper under test. The IOMockGuard runs assert_complete on drop. struct Fixture { - io: Rc>, - config: Rc>, + io: std::rc::Rc>, + config: std::rc::Rc>, auth_helper: AuthHelper, _guard: crate::io_mock::IOMockGuard, } -fn set_up_with_config(config: Rc>) -> Fixture { +fn set_up_with_config(config: std::rc::Rc>) -> Fixture { let (mock, guard) = get_io_mock(io_interface::DEBUG).unwrap(); - let io: Rc> = mock.clone(); + let io: std::rc::Rc> = mock.clone(); let auth_helper = AuthHelper::new(io, config.clone()); Fixture { io: mock, @@ -38,7 +36,12 @@ fn set_up() -> Fixture { // Mirrors AuthHelperTest::expectsAuthentication: pre-seed the IO so hasAuthentication // and getAuthentication return the given credentials for `origin`. -fn expects_authentication(io: &Rc>, origin: &str, username: &str, password: &str) { +fn expects_authentication( + io: &std::rc::Rc>, + origin: &str, + username: &str, + password: &str, +) { use shirabe::io::IOInterfaceMutable; io.borrow_mut().set_authentication( origin.to_string(), diff --git a/crates/shirabe/tests/util/bitbucket_test.rs b/crates/shirabe/tests/util/bitbucket_test.rs index db45b3e1..d9010ab1 100644 --- a/crates/shirabe/tests/util/bitbucket_test.rs +++ b/crates/shirabe/tests/util/bitbucket_test.rs @@ -14,8 +14,6 @@ use shirabe::util::http_downloader::{ }; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, time}; -use std::cell::RefCell; -use std::rc::Rc; const USERNAME: &str = "username"; const PASSWORD: &str = "password"; @@ -60,9 +58,9 @@ fn placeholder_auth_config_source() -> Box { // real Config, the captured `time()`, and the Bitbucket under test. The mock guards // run their assert_complete on drop at the end of the test scope. struct Fixture { - io: Rc>, - config: Rc>, - http_downloader: Rc>, + io: std::rc::Rc>, + config: std::rc::Rc>, + http_downloader: std::rc::Rc>, time: i64, bitbucket: Bitbucket, _io_guard: crate::io_mock::IOMockGuard, @@ -70,7 +68,7 @@ struct Fixture { } fn set_up_with_config_and_http( - config: Rc>, + config: std::rc::Rc>, http_expectations: Vec, ) -> Fixture { let (io_mock, io_guard) = get_io_mock(io_interface::DEBUG).unwrap(); @@ -80,7 +78,7 @@ fn set_up_with_config_and_http( HttpDownloaderMockHandler::default(), ); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let time = time(); let bitbucket = Bitbucket::new( io, @@ -127,7 +125,7 @@ fn access_token_body() -> String { // mirroring BitbucketTest::setExpectationsForStoringAccessToken. Verification happens // when the mocks are dropped together with the Config. fn set_expectations_for_storing_access_token( - config: &Rc>, + config: &std::rc::Rc>, time: i64, remove_basic_auth: bool, ) { @@ -575,7 +573,7 @@ fn test_authorize_oauth_without_available_git_config_token() { }, ); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let time = time(); let mut bitbucket = Bitbucket::new(io, config, Some(process), Some(http_downloader), Some(time)).unwrap(); @@ -592,7 +590,7 @@ fn test_authorize_oauth_with_available_git_config_token() { let (process, _process_guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let time = time(); let mut bitbucket = Bitbucket::new(io, config, Some(process), Some(http_downloader), Some(time)).unwrap(); diff --git a/crates/shirabe/tests/util/config_validator_test.rs b/crates/shirabe/tests/util/config_validator_test.rs index 6d7aaf8f..a65cfa56 100644 --- a/crates/shirabe/tests/util/config_validator_test.rs +++ b/crates/shirabe/tests/util/config_validator_test.rs @@ -4,8 +4,6 @@ use shirabe::io::io_interface::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::package::loader::validating_array_loader::ValidatingArrayLoader; use shirabe::util::config_validator::ConfigValidator; -use std::cell::RefCell; -use std::rc::Rc; fn fixture(name: &str) -> String { format!( @@ -16,7 +14,8 @@ fn fixture(name: &str) -> String { } fn validate(file: &str) -> Vec { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let config_validator = ConfigValidator::new(io); let (_, _, warnings) = config_validator.validate( file, diff --git a/crates/shirabe/tests/util/forgejo_test.rs b/crates/shirabe/tests/util/forgejo_test.rs index 106cdabc..3829ebf2 100644 --- a/crates/shirabe/tests/util/forgejo_test.rs +++ b/crates/shirabe/tests/util/forgejo_test.rs @@ -9,8 +9,6 @@ use shirabe::io::io_interface; use shirabe::util::Forgejo; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; const USERNAME: &str = "username"; const ACCESS_TOKEN: &str = "access-token"; @@ -63,11 +61,11 @@ fn get_conf_json_mock(origin: &str) -> Box { } fn build_forgejo( - io_mock: &Rc>, - config: Rc>, - http_downloader: Rc>, + io_mock: &std::rc::Rc>, + config: std::rc::Rc>, + http_downloader: std::rc::Rc>, ) -> Forgejo { - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); Forgejo::new(io, config, http_downloader) } diff --git a/crates/shirabe/tests/util/git_test.rs b/crates/shirabe/tests/util/git_test.rs index 991dc91c..907ec38a 100644 --- a/crates/shirabe/tests/util/git_test.rs +++ b/crates/shirabe/tests/util/git_test.rs @@ -12,8 +12,6 @@ use shirabe::util::git::Git; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::{PhpMixed, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; // No-op ConfigSourceInterface, equivalent to PHPUnit's // `getMockBuilder(Config::class)` auto-stubbing getConfigSource/getAuthConfigSource: @@ -73,10 +71,15 @@ impl ConfigSourceInterface for NullConfigSource { // flattens each callable to a `Vec` and hands it to `execute_args`, which always // builds a `PhpMixed::List`. So the single-token string command becomes a one-element list, // and the corresponding process expectation is a one-element list as well. -fn build_git(io: IOStub, config: Config, process: Rc>) -> Git { - let io: Rc> = Rc::new(RefCell::new(io)); - let config = Rc::new(RefCell::new(config)); - let fs = Rc::new(RefCell::new(Filesystem::new(None))); +fn build_git( + io: IOStub, + config: Config, + process: std::rc::Rc>, +) -> Git { + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(io)); + let config = std::rc::Rc::new(std::cell::RefCell::new(config)); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None))); Git::new(io, config, process, fs) } diff --git a/crates/shirabe/tests/util/github_test.rs b/crates/shirabe/tests/util/github_test.rs index b9abeb26..377a44fa 100644 --- a/crates/shirabe/tests/util/github_test.rs +++ b/crates/shirabe/tests/util/github_test.rs @@ -9,8 +9,6 @@ use shirabe::io::io_interface; use shirabe::util::GitHub; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; const PASSWORD: &str = "password"; const MESSAGE: &str = "mymessage"; @@ -62,18 +60,18 @@ fn get_conf_json_mock(origin: &str) -> Box { } fn build_github( - io_mock: &Rc>, - config: Rc>, - http_downloader: Rc>, + io_mock: &std::rc::Rc>, + config: std::rc::Rc>, + http_downloader: std::rc::Rc>, ) -> GitHub { - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); GitHub::new(io, config, None, Some(http_downloader)).unwrap() } // The PHP Config mock returns null for `get('github-expose-hostname')`, which is // falsy and skips the `hostname` process call. A real Config defaults that key to // true, so the stub seeds false to reproduce the mock's behaviour. -fn build_config() -> Rc> { +fn build_config() -> std::rc::Rc> { ConfigStubBuilder::new() .with("github-expose-hostname", PhpMixed::Bool(false)) .build_shared() diff --git a/crates/shirabe/tests/util/gitlab_test.rs b/crates/shirabe/tests/util/gitlab_test.rs index 46c03585..70aa4656 100644 --- a/crates/shirabe/tests/util/gitlab_test.rs +++ b/crates/shirabe/tests/util/gitlab_test.rs @@ -9,8 +9,6 @@ use shirabe::io::io_interface; use shirabe::util::GitLab; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; const USERNAME: &str = "username"; const PASSWORD: &str = "password"; @@ -50,7 +48,10 @@ fn get_auth_json_mock() -> Box { Box::new(mock) } -fn set_up(io_mock: &Rc>, config: &Rc>) { +fn set_up( + io_mock: &std::rc::Rc>, + config: &std::rc::Rc>, +) { config .borrow_mut() .set_auth_config_source(get_auth_json_mock()); @@ -91,7 +92,7 @@ fn test_username_password_authentication_flow() { let config = ConfigStubBuilder::new().build_shared(); set_up(&io_mock, &config); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let mut gitlab = GitLab::new(io, config, None, Some(http_downloader)).unwrap(); assert!( @@ -138,7 +139,7 @@ fn test_username_password_failure() { let config = ConfigStubBuilder::new().build_shared(); set_up(&io_mock, &config); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); let mut gitlab = GitLab::new(io, config, None, Some(http_downloader)).unwrap(); let err = gitlab diff --git a/crates/shirabe/tests/util/http_downloader_test.rs b/crates/shirabe/tests/util/http_downloader_test.rs index b1841840..2be5eb96 100644 --- a/crates/shirabe/tests/util/http_downloader_test.rs +++ b/crates/shirabe/tests/util/http_downloader_test.rs @@ -12,8 +12,6 @@ use shirabe::util::Platform; use shirabe::util::http_downloader::HttpDownloader; use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL; use shirabe_php_shim::{PHP_EOL, PhpMixed}; -use std::cell::RefCell; -use std::rc::Rc; // PHP performs a live HTTP get to assert the URL's user:pass is captured via // setAuthentication. The credential capture happens in `add_job`, before any @@ -37,12 +35,12 @@ fn test_capture_authentication_params_from_url() { .unwrap(); // The PHP Config mock returns [] for github-domains/gitlab-domains. - let config: Rc> = ConfigStubBuilder::new() + let config: std::rc::Rc> = ConfigStubBuilder::new() .with("github-domains", PhpMixed::Array(IndexMap::new())) .with("gitlab-domains", PhpMixed::Array(IndexMap::new())) .build_shared(); - let io: Rc> = io_mock.clone(); + let io: std::rc::Rc> = io_mock.clone(); Platform::put_env("COMPOSER_DISABLE_NETWORK", "1"); let mut fs = HttpDownloader::new(io, config, IndexMap::new(), false); @@ -59,10 +57,10 @@ fn test_capture_authentication_params_from_url() { #[test] fn test_output_warnings() { - let io: Rc> = Rc::new(RefCell::new( + let io: std::rc::Rc> = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_NORMAL, None).unwrap(), )); - let io_dyn: Rc> = io.clone(); + let io_dyn: std::rc::Rc> = io.clone(); HttpDownloader::output_warnings(io_dyn.clone(), "$URL", &IndexMap::new()).unwrap(); assert_eq!("", io.borrow().get_output()); diff --git a/crates/shirabe/tests/util/perforce_test.rs b/crates/shirabe/tests/util/perforce_test.rs index b6f8f116..b63a5e0e 100644 --- a/crates/shirabe/tests/util/perforce_test.rs +++ b/crates/shirabe/tests/util/perforce_test.rs @@ -9,8 +9,6 @@ use shirabe::util::Perforce; use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; const TEST_DEPOT: &str = "depot"; const TEST_BRANCH: &str = "branch"; @@ -41,8 +39,9 @@ fn get_test_repo_config() -> IndexMap { } fn create_new_perforce_with_windows_flag(flag: bool) -> Perforce { - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); Perforce::new( get_test_repo_config(), TEST_PORT.to_string(), @@ -57,8 +56,8 @@ fn create_new_perforce_with_windows_flag(flag: bool) -> Perforce { // ProcessExecutor and IO it configured, matching the PHP `setUp` wiring. fn create_perforce( flag: bool, - process: Rc>, - io: Rc>, + process: std::rc::Rc>, + io: std::rc::Rc>, ) -> Perforce { Perforce::new( get_test_repo_config(), @@ -201,7 +200,8 @@ fn test_query_p4_user_with_user_set_in_p4_variables_with_windows_os() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_user(None); @@ -224,7 +224,8 @@ fn test_query_p4_user_with_user_set_in_p4_variables_not_windows_os() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(false, process, io); perforce.set_user(None); @@ -240,9 +241,10 @@ fn test_query_p4_user_queries_for_user() { // Non-strict empty process mock: the p4-variable lookup returns empty so the // code falls through to io->ask(). let (process, _guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), + )); let mut perforce = create_perforce(true, process, io); perforce.set_user(None); @@ -261,9 +263,10 @@ fn test_query_p4_user_stores_response_to_query_for_user_with_windows() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), + )); let mut perforce = create_perforce(true, process, io); perforce.set_user(None); @@ -284,9 +287,10 @@ fn test_query_p4_user_stores_response_to_query_for_user_without_windows() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), + )); let mut perforce = create_perforce(false, process, io); perforce.set_user(None); @@ -304,9 +308,10 @@ fn test_query_p4_user_escapes_injection_on_windows() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("foo && calc.exe".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new().with_ask(PhpMixed::String("foo && calc.exe".to_string())), + )); let mut perforce = create_perforce(true, process, io); perforce.set_user(None); @@ -324,9 +329,9 @@ fn test_query_p4_user_escapes_injection_on_unix() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("foo; id".to_string())), - )); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_ask(PhpMixed::String("foo; id".to_string()))), + ); let mut perforce = create_perforce(false, process, io); perforce.set_user(None); @@ -343,8 +348,9 @@ fn test_query_p4_password_with_password_already_set() { "p4password".to_string(), PhpMixed::String("TEST_PASSWORD".to_string()), ); - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let process = std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = Perforce::new( repo_config, "port".to_string(), @@ -373,7 +379,8 @@ fn test_query_p4_password_with_password_set_in_p4_variables_with_windows_os() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let password = perforce.query_p4_password(); @@ -392,7 +399,8 @@ fn test_query_p4_password_with_password_set_in_p4_variables_not_windows_os() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(false, process, io); let password = perforce.query_p4_password(); @@ -404,9 +412,10 @@ fn test_query_p4_password_queries_for_password() { // Non-strict empty process mock: the p4-variable lookup returns empty so the // code falls through to io->askAndHideAnswer(). let (process, _guard) = get_process_executor_mock(vec![], false, MockHandler::default()); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new().with_ask_and_hide_answer(Some("TEST_QUERY_PASSWORD".to_string())), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new().with_ask_and_hide_answer(Some("TEST_QUERY_PASSWORD".to_string())), + )); let mut perforce = create_perforce(true, process, io); let password = perforce.query_p4_password(); @@ -420,7 +429,8 @@ fn test_is_logged_in() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.is_logged_in().unwrap(); @@ -467,7 +477,8 @@ fn test_get_branches_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_stream("//depot/branch"); @@ -487,7 +498,8 @@ fn test_get_branches_without_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let branches = perforce.get_branches(); @@ -519,7 +531,8 @@ fn test_get_tags_without_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let tags = perforce.get_tags(); @@ -552,7 +565,8 @@ fn test_get_tags_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_stream("//depot/branch"); @@ -582,7 +596,8 @@ fn test_check_stream_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let result = perforce.check_stream(); @@ -612,7 +627,8 @@ fn test_get_composer_information_without_label_without_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let result = perforce.get_composer_information("//depot").unwrap(); @@ -657,7 +673,8 @@ fn test_get_composer_information_with_label_without_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); let result = perforce.get_composer_information("//depot@0.0.1").unwrap(); @@ -686,7 +703,8 @@ fn test_get_composer_information_without_label_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_stream("//depot/branch"); @@ -732,7 +750,8 @@ fn test_get_composer_information_with_label_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_stream("//depot/branch"); @@ -761,7 +780,8 @@ fn test_sync_code_base_without_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.sync_code_base(Some("label")).unwrap(); @@ -786,7 +806,8 @@ fn test_sync_code_base_with_stream() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process, io); perforce.set_stream("//depot/branch"); @@ -849,10 +870,11 @@ fn test_cleanup_client_spec_should_delete_client() { true, MockHandler::default(), ); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut perforce = create_perforce(true, process.clone(), io); - let fs = Rc::new(RefCell::new(Filesystem::new(Some(process)))); + let fs = std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(Some(process)))); perforce.set_filesystem(fs); perforce.cleanup_client_spec(); diff --git a/crates/shirabe/tests/util/process_executor_test.rs b/crates/shirabe/tests/util/process_executor_test.rs index 78c5f9f7..e093a801 100644 --- a/crates/shirabe/tests/util/process_executor_test.rs +++ b/crates/shirabe/tests/util/process_executor_test.rs @@ -16,8 +16,6 @@ use shirabe_external_packages::symfony::console::output::output_interface::{ OutputInterface, VERBOSITY_DEBUG, VERBOSITY_NORMAL, }; use shirabe_php_shim::{PHP_EOL, trim}; -use std::cell::RefCell; -use std::rc::Rc; #[test] fn test_execute_captures_output() { @@ -90,11 +88,12 @@ fn hide_password_provider() -> Vec<(&'static str, &'static str)> { #[test] fn test_hide_passwords() { for (command, expected_command_output) in hide_password_provider() { - let buffer = Rc::new(RefCell::new( + let buffer = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_DEBUG, None).unwrap(), )); - let mut process = - ProcessExecutor::new(Some(buffer.clone() as Rc>)); + let mut process = ProcessExecutor::new(Some( + buffer.clone() as std::rc::Rc> + )); let mut output = String::new(); process.execute(command, &mut output, None).unwrap(); assert_eq!( @@ -106,10 +105,12 @@ fn test_hide_passwords() { #[test] fn test_doesnt_hide_ports() { - let buffer = Rc::new(RefCell::new( + let buffer = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_DEBUG, None).unwrap(), )); - let mut process = ProcessExecutor::new(Some(buffer.clone() as Rc>)); + let mut process = ProcessExecutor::new(Some( + buffer.clone() as std::rc::Rc> + )); let mut output = String::new(); process .execute("echo https://localhost:1234/", &mut output, None) @@ -128,21 +129,22 @@ fn test_split_lines() { #[test] fn test_console_io_does_not_format_symfony_console_style() { - let output = Rc::new(RefCell::new(BufferedOutput::new( + let output = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( Some(VERBOSITY_NORMAL), true, None, ))); - let input: Rc> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); + let input: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); let console_io = ConsoleIO::new( input, - output.clone() as Rc>, + output.clone() as std::rc::Rc>, QuestionHelper::default(), ); - let mut process = ProcessExecutor::new(Some( - Rc::new(RefCell::new(console_io)) as Rc> - )); + let mut process = + ProcessExecutor::new(Some(std::rc::Rc::new(std::cell::RefCell::new(console_io)) + as std::rc::Rc>)); process .execute( diff --git a/crates/shirabe/tests/util/remote_filesystem_test.rs b/crates/shirabe/tests/util/remote_filesystem_test.rs index c699b94a..9c1fe0bd 100644 --- a/crates/shirabe/tests/util/remote_filesystem_test.rs +++ b/crates/shirabe/tests/util/remote_filesystem_test.rs @@ -9,13 +9,11 @@ use shirabe_php_shim::{ PHP_URL_HOST, PhpMixed, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, file_get_contents, parse_url, strpos, unlink, }; -use std::cell::RefCell; -use std::rc::Rc; // Mirrors RemoteFilesystemTest::getConfigMock: get('github-domains') and // get('gitlab-domains') return [], everything else returns null. add_authentication_options // reads gitlab-domains, so seed it as an empty list. -fn config_mock() -> Rc> { +fn config_mock() -> std::rc::Rc> { ConfigStubBuilder::new() .with("github-domains", PhpMixed::List(vec![])) .with("gitlab-domains", PhpMixed::List(vec![])) @@ -25,7 +23,7 @@ fn config_mock() -> Rc> { // Mirrors RemoteFilesystemTest::callGetOptionsForUrl: build a RemoteFilesystem, set the // private file_url, then invoke the private get_options_for_url with the given args. fn call_get_options_for_url( - io: Rc>, + io: std::rc::Rc>, origin_url: &str, additional_options: IndexMap, options: IndexMap, @@ -50,8 +48,9 @@ fn http_header_list(res: &IndexMap) -> Option> { #[test] fn test_get_options_for_url() { - let io: Rc> = - Rc::new(RefCell::new(IOStub::new().with_has_authentication(false))); + let io: std::rc::Rc> = std::rc::Rc::new( + std::cell::RefCell::new(IOStub::new().with_has_authentication(false)), + ); let res = call_get_options_for_url( io, @@ -72,11 +71,12 @@ fn test_get_options_for_url_with_authorization() { let mut auth: IndexMap> = IndexMap::new(); auth.insert("username".to_string(), Some("login".to_string())); auth.insert("password".to_string(), Some("password".to_string())); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_has_authentication(true) + .with_get_authentication(auth), + )); let options = call_get_options_for_url( io, @@ -100,11 +100,12 @@ fn test_get_options_for_url_with_stream_options() { let mut auth: IndexMap> = IndexMap::new(); auth.insert("username".to_string(), None); auth.insert("password".to_string(), None); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_has_authentication(true) + .with_get_authentication(auth), + )); let mut ssl: IndexMap = IndexMap::new(); ssl.insert("allow_self_signed".to_string(), PhpMixed::Bool(true)); @@ -136,11 +137,12 @@ fn test_get_options_for_url_with_call_options_keeps_header() { let mut auth: IndexMap> = IndexMap::new(); auth.insert("username".to_string(), None); auth.insert("password".to_string(), None); - let io: Rc> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_has_authentication(true) + .with_get_authentication(auth), + )); let mut http: IndexMap = IndexMap::new(); http.insert( @@ -172,7 +174,8 @@ fn test_get_options_for_url_with_call_options_keeps_header() { #[test] fn test_callback_get_file_size() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut fs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); fs.__callback_get(STREAM_NOTIFY_FILE_SIZE_IS, 0, Some(String::new()), 0, 0, 20) .unwrap(); @@ -181,7 +184,8 @@ fn test_callback_get_file_size() { #[test] fn test_callback_get_notify_progress() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut fs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); fs.__set_bytes_max(20); fs.__set_progress(true); @@ -193,7 +197,8 @@ fn test_callback_get_notify_progress() { #[test] fn test_callback_get_passes_through404() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut fs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); fs.__callback_get( @@ -226,7 +231,8 @@ fn this_file() -> String { #[test] fn test_get_contents() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut fs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); let res = fs @@ -242,7 +248,8 @@ fn test_get_contents() { #[test] fn test_copy() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut fs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); let file = tempfile::NamedTempFile::new().unwrap(); @@ -293,7 +300,8 @@ fn provide_bitbucket_public_download_urls() -> Vec<(&'static str, &'static str)> #[ignore = "performs a real network download; get_remote_contents has no stream layer (TODO(phase-c)) and returns None, so getContents raises a TransportException"] fn test_bit_bucket_public_download() { for (url, contents) in provide_bitbucket_public_download_urls() { - let io: Rc> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut rfs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); let hostname = parse_url(url, PHP_URL_HOST); let hostname = hostname.as_string().unwrap_or(""); diff --git a/crates/shirabe/tests/util/svn_test.rs b/crates/shirabe/tests/util/svn_test.rs index f7006345..650fbd89 100644 --- a/crates/shirabe/tests/util/svn_test.rs +++ b/crates/shirabe/tests/util/svn_test.rs @@ -6,8 +6,6 @@ use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::svn::Svn; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; fn map(pairs: Vec<(&str, PhpMixed)>) -> IndexMap { pairs.into_iter().map(|(k, v)| (k.to_string(), v)).collect() @@ -43,8 +41,9 @@ fn url_provider() -> Vec<(&'static str, Vec<&'static str>)> { #[test] fn test_credentials() { for (url, expect) in url_provider() { - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); let mut svn = Svn::new(url.to_string(), io, config, None); let expect: Vec = expect.iter().map(|s| s.to_string()).collect(); @@ -56,8 +55,9 @@ fn test_credentials() { fn test_interactive_string() { let url = "http://svn.example.org"; - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let config = std::rc::Rc::new(std::cell::RefCell::new(Config::new(true, None))); let mut svn = Svn::new(url.to_string(), io, config, None); assert_eq!( @@ -79,8 +79,14 @@ fn test_credentials_from_config() { let mut config = Config::new(true, None); config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test"); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let mut svn = Svn::new( + url.to_string(), + io, + std::rc::Rc::new(std::cell::RefCell::new(config)), + None, + ); assert_eq!( vec![ @@ -100,8 +106,14 @@ fn test_credentials_from_config_with_cache_credentials_true() { let mut config = Config::new(true, None); config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test"); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let mut svn = Svn::new( + url.to_string(), + io, + std::rc::Rc::new(std::cell::RefCell::new(config)), + None, + ); svn.set_cache_credentials(true); assert_eq!( @@ -122,8 +134,14 @@ fn test_credentials_from_config_with_cache_credentials_false() { let mut config = Config::new(true, None); config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test"); - let io: Rc> = Rc::new(RefCell::new(NullIO::new())); - let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None); + let io: std::rc::Rc> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); + let mut svn = Svn::new( + url.to_string(), + io, + std::rc::Rc::new(std::cell::RefCell::new(config)), + None, + ); svn.set_cache_credentials(false); assert_eq!( -- cgit v1.3.1