diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
| commit | 27d00055df8691a6bd99aaf38633a7338b16cc6a (patch) | |
| tree | 4af17ccff5f8c2d09156fa62c559e60e3e683dac /crates/shirabe/tests/util | |
| parent | 1ec2220def43e37e5a65b96dde93c19b493258f4 (diff) | |
| download | php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.gz php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.zst php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.zip | |
chore: use fully-qualified name for Rc/RefCell
Diffstat (limited to 'crates/shirabe/tests/util')
| -rw-r--r-- | crates/shirabe/tests/util/auth_helper_test.rs | 17 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/bitbucket_test.rs | 18 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/config_validator_test.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/forgejo_test.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/git_test.rs | 15 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/github_test.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/gitlab_test.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/http_downloader_test.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/perforce_test.rs | 110 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/process_executor_test.rs | 30 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/remote_filesystem_test.rs | 62 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/svn_test.rs | 42 |
12 files changed, 195 insertions, 147 deletions
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<RefCell<IOMock>>, - config: Rc<RefCell<shirabe::config::Config>>, + io: std::rc::Rc<std::cell::RefCell<IOMock>>, + config: std::rc::Rc<std::cell::RefCell<shirabe::config::Config>>, auth_helper: AuthHelper, _guard: crate::io_mock::IOMockGuard, } -fn set_up_with_config(config: Rc<RefCell<shirabe::config::Config>>) -> Fixture { +fn set_up_with_config(config: std::rc::Rc<std::cell::RefCell<shirabe::config::Config>>) -> Fixture { let (mock, guard) = get_io_mock(io_interface::DEBUG).unwrap(); - let io: Rc<RefCell<dyn IOInterface>> = mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<IOMock>>, origin: &str, username: &str, password: &str) { +fn expects_authentication( + io: &std::rc::Rc<std::cell::RefCell<IOMock>>, + 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<MockConfigSource> { // 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<RefCell<IOMock>>, - config: Rc<RefCell<Config>>, - http_downloader: Rc<RefCell<HttpDownloader>>, + io: std::rc::Rc<std::cell::RefCell<IOMock>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, + http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, 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<RefCell<Config>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, http_expectations: Vec<HttpDownloaderMockExpectation>, ) -> 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<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<Config>>, + config: &std::rc::Rc<std::cell::RefCell<Config>>, time: i64, remove_basic_auth: bool, ) { @@ -575,7 +573,7 @@ fn test_authorize_oauth_without_available_git_config_token() { }, ); - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<String> { - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let 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<MockConfigSource> { } fn build_forgejo( - io_mock: &Rc<RefCell<IOMock>>, - config: Rc<RefCell<Config>>, - http_downloader: Rc<RefCell<HttpDownloader>>, + io_mock: &std::rc::Rc<std::cell::RefCell<IOMock>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, + http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, ) -> Forgejo { - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<String>` 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<RefCell<ProcessExecutor>>) -> Git { - let io: Rc<RefCell<dyn IOInterface>> = 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<std::cell::RefCell<ProcessExecutor>>, +) -> Git { + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<MockConfigSource> { } fn build_github( - io_mock: &Rc<RefCell<IOMock>>, - config: Rc<RefCell<Config>>, - http_downloader: Rc<RefCell<HttpDownloader>>, + io_mock: &std::rc::Rc<std::cell::RefCell<IOMock>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, + http_downloader: std::rc::Rc<std::cell::RefCell<HttpDownloader>>, ) -> GitHub { - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<Config>> { +fn build_config() -> std::rc::Rc<std::cell::RefCell<Config>> { 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<MockAuthJson> { Box::new(mock) } -fn set_up(io_mock: &Rc<RefCell<IOMock>>, config: &Rc<RefCell<Config>>) { +fn set_up( + io_mock: &std::rc::Rc<std::cell::RefCell<IOMock>>, + config: &std::rc::Rc<std::cell::RefCell<Config>>, +) { 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<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<Config>> = ConfigStubBuilder::new() + let config: std::rc::Rc<std::cell::RefCell<Config>> = ConfigStubBuilder::new() .with("github-domains", PhpMixed::Array(IndexMap::new())) .with("gitlab-domains", PhpMixed::Array(IndexMap::new())) .build_shared(); - let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone(); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<BufferIO>> = Rc::new(RefCell::new( + let io: std::rc::Rc<std::cell::RefCell<BufferIO>> = std::rc::Rc::new(std::cell::RefCell::new( BufferIO::new(String::new(), VERBOSITY_NORMAL, None).unwrap(), )); - let io_dyn: Rc<RefCell<dyn IOInterface>> = io.clone(); + let io_dyn: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<String, PhpMixed> { } fn create_new_perforce_with_windows_flag(flag: bool) -> Perforce { - let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); - let io: Rc<RefCell<dyn IOInterface>> = 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::cell::RefCell<dyn IOInterface>> = + 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<RefCell<ProcessExecutor>>, - io: Rc<RefCell<dyn IOInterface>>, + process: std::rc::Rc<std::cell::RefCell<ProcessExecutor>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, ) -> 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("TEST_QUERY_USER".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("foo && calc.exe".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask(PhpMixed::String("foo; id".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<RefCell<dyn IOInterface>> = 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::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new().with_ask_and_hide_answer(Some("TEST_QUERY_PASSWORD".to_string())), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())); let mut 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<RefCell<dyn IOInterface>>)); + let mut process = ProcessExecutor::new(Some( + buffer.clone() as std::rc::Rc<std::cell::RefCell<dyn IOInterface>> + )); 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<RefCell<dyn IOInterface>>)); + let mut process = ProcessExecutor::new(Some( + buffer.clone() as std::rc::Rc<std::cell::RefCell<dyn IOInterface>> + )); 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<RefCell<dyn InputInterface>> = - Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); + let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = std::rc::Rc::new( + std::cell::RefCell::new(ArrayInput::new(vec![], None).unwrap()), + ); let console_io = ConsoleIO::new( input, - output.clone() as Rc<RefCell<dyn OutputInterface>>, + output.clone() as std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, QuestionHelper::default(), ); - let mut process = ProcessExecutor::new(Some( - Rc::new(RefCell::new(console_io)) as Rc<RefCell<dyn IOInterface>> - )); + let mut process = + ProcessExecutor::new(Some(std::rc::Rc::new(std::cell::RefCell::new(console_io)) + as std::rc::Rc<std::cell::RefCell<dyn IOInterface>>)); 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<RefCell<shirabe::config::Config>> { +fn config_mock() -> std::rc::Rc<std::cell::RefCell<shirabe::config::Config>> { ConfigStubBuilder::new() .with("github-domains", PhpMixed::List(vec![])) .with("gitlab-domains", PhpMixed::List(vec![])) @@ -25,7 +23,7 @@ fn config_mock() -> Rc<RefCell<shirabe::config::Config>> { // 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<RefCell<dyn IOInterface>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, origin_url: &str, additional_options: IndexMap<String, PhpMixed>, options: IndexMap<String, PhpMixed>, @@ -50,8 +48,9 @@ fn http_header_list(res: &IndexMap<String, PhpMixed>) -> Option<Vec<String>> { #[test] fn test_get_options_for_url() { - let io: Rc<RefCell<dyn IOInterface>> = - Rc::new(RefCell::new(IOStub::new().with_has_authentication(false))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = 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<String, Option<String>> = IndexMap::new(); auth.insert("username".to_string(), Some("login".to_string())); auth.insert("password".to_string(), Some("password".to_string())); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<String, Option<String>> = IndexMap::new(); auth.insert("username".to_string(), None); auth.insert("password".to_string(), None); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_has_authentication(true) + .with_get_authentication(auth), + )); let mut ssl: IndexMap<String, PhpMixed> = 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<String, Option<String>> = IndexMap::new(); auth.insert("username".to_string(), None); auth.insert("password".to_string(), None); - let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new( - IOStub::new() - .with_has_authentication(true) - .with_get_authentication(auth), - )); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new( + IOStub::new() + .with_has_authentication(true) + .with_get_authentication(auth), + )); let mut http: IndexMap<String, PhpMixed> = 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(IOStub::new())); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); 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<String, PhpMixed> { 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<String> = 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<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); - let config = Rc::new(RefCell::new(Config::new(true, None))); + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + 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<RefCell<dyn IOInterface>> = 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::cell::RefCell<dyn IOInterface>> = + 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