aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-10 15:29:19 +0900
committernsfisis <nsfisis@gmail.com>2026-05-10 15:29:19 +0900
commit46845eff8d1398f35099a0ef914f77bcaf473287 (patch)
tree12c4850f1d2f438d0ba6c363fdc0e5036cd4601d /crates/mozart/tests
parent212506c364b2342dd9e5fa789e8cff38835dfe52 (diff)
downloadphp-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.tar.gz
php-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.tar.zst
php-mozart-46845eff8d1398f35099a0ef914f77bcaf473287.zip
refactor(io): introduce IoInterface trait mirroring Composer IOInterface
Add an `IoInterface` trait in mozart-core::console that mirrors `\Composer\IO\IOInterface`, implement it for `Console`, and switch commands, the auditor, and the suggested-packages reporter to accept the abstracted IO (typically `Arc<Mutex<Box<dyn IoInterface>>>` at the command boundary, `&dyn IoInterface` deeper down) instead of `&Console`. The console_writeln\!/write\! macros now go through `IoInterface::verbosity()` via the lock so any implementor works.
Diffstat (limited to 'crates/mozart/tests')
-rw-r--r--crates/mozart/tests/installer.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/mozart/tests/installer.rs b/crates/mozart/tests/installer.rs
index 970fce4..fbeba6d 100644
--- a/crates/mozart/tests/installer.rs
+++ b/crates/mozart/tests/installer.rs
@@ -9,11 +9,11 @@
//! Composer's PHPUnit suite uses.
use std::path::{Path, PathBuf};
-use std::sync::Arc;
+use std::sync::{Arc, Mutex};
use clap::Parser;
use mozart::commands::{Cli, Commands, install, update};
-use mozart_core::console::Console;
+use mozart_core::console::{Console, IoInterface};
use mozart_core::exit_code::MozartError;
use mozart_core::repository::installer_executor::TraceRecorderExecutor;
use mozart_core::repository::repository::RepositorySet;
@@ -108,7 +108,10 @@ async fn run_fixture_in_process(test: &ParsedTest) -> anyhow::Result<InProcessRu
// Quiet console: assertions run against the recorder + on-disk
// artifacts, not captured stdout/stderr (Console doesn't yet support
// buffered sinks). EXPECT-OUTPUT enforcement is a follow-up.
- let console = Console::new(0, true, false, true, true);
+ let console: Arc<Mutex<Box<dyn IoInterface>>> = Arc::new(Mutex::new(Box::new(Console::new(
+ 0, true, false, true, true,
+ ))
+ as Box<dyn IoInterface>));
let repositories = Arc::new(RepositorySet::empty());
let mut executor = TraceRecorderExecutor::new();
@@ -119,7 +122,7 @@ async fn run_fixture_in_process(test: &ParsedTest) -> anyhow::Result<InProcessRu
root,
Some(&path_repo_base),
args,
- &console,
+ console.clone(),
repositories,
&mut executor,
)
@@ -130,7 +133,7 @@ async fn run_fixture_in_process(test: &ParsedTest) -> anyhow::Result<InProcessRu
root,
Some(&path_repo_base),
args,
- &console,
+ console.clone(),
repositories,
&mut executor,
)