Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-cli): treat provisionable Mac engines as usable in runtime checks

injaneityb31ff4332cbd
diff --git a/docs/content/docs/cua-cli/reference/cli/sandboxes.mdx b/docs/content/docs/cua-cli/reference/cli/sandboxes.mdx
index a9d69c7ce1..29a761a547 100644
--- a/docs/content/docs/cua-cli/reference/cli/sandboxes.mdx
+++ b/docs/content/docs/cua-cli/reference/cli/sandboxes.mdx
@@ -1070,7 +1070,7 @@ cua runtime [OPTIONS] <COMMAND>
### `cua runtime doctor`
-Inspect local runtimes (read-only).
+Inspect local runtimes (read-only). Exit 1 if any check is Error; warnings exit 0.
```text output
cua runtime doctor [OPTIONS]
@@ -1084,7 +1084,7 @@ cua runtime doctor
### `cua runtime setup`
-Provision local runtimes.
+Provision local runtimes. Exit 1 if any step is Error; warnings exit 0.
```text output
cua runtime setup [OPTIONS] [COMPONENTS]...
diff --git a/libs/cua/crates/cua-cli/src/lib.rs b/libs/cua/crates/cua-cli/src/lib.rs
index 595029db95..08ee6196bd 100644
--- a/libs/cua/crates/cua-cli/src/lib.rs
+++ b/libs/cua/crates/cua-cli/src/lib.rs
@@ -670,11 +670,11 @@ enum DaemonCmd {
#[derive(Subcommand, Debug)]
enum RuntimeCmd {
- /// Inspect local runtimes (read-only).
+ /// Inspect local runtimes (read-only). Exit 1 if any check is Error; warnings exit 0.
#[command(after_help = "Examples:
cua runtime doctor")]
Doctor,
- /// Provision local runtimes.
+ /// Provision local runtimes. Exit 1 if any step is Error; warnings exit 0.
#[command(after_help = "Examples:
# See what would be installed
cua runtime setup --dry-run
@@ -1889,30 +1889,21 @@ async fn run_sdk(cli: Cli, out: &mut dyn Write) -> Result<i32, CuaError> {
}
Command::Runtime(RuntimeCmd::Doctor) => {
let report = cua.local().doctor().await?;
- if json {
- line(out, &report.report_json);
- } else {
- for c in report.checks {
- line(
- out,
- format!(
- "{:<10} {:<12} {}{}",
- c.name,
- format!("{:?}", c.status).to_lowercase(),
- c.version.map(|v| format!("[{v}] ")).unwrap_or_default(),
- c.detail
- ),
- );
- }
- }
+ return Ok(runtime_doctor_output_with(
+ out,
+ &report,
+ json,
+ &runtime_optional(&report.report_json),
+ ));
}
Command::Runtime(RuntimeCmd::Setup {
dry_run,
components,
}) => {
- for s in cua.local().setup(components, dry_run).await? {
- line(out, format!("{:<10} {:?}: {}", s.name, s.status, s.detail));
- }
+ let steps = cua.local().setup(components.clone(), dry_run).await?;
+ let report = cua.local().doctor().await?;
+ let optional = runtime_optional(&report.report_json);
+ return Ok(runtime_setup_output(out, steps, &optional, &components));
}
Command::Image(cmd) => {
let local = cua.local();
@@ -2541,6 +2532,103 @@ pub fn main() {
std::process::exit(code);
}
+fn runtime_optional(report_json: &str) -> Vec<String> {
+ runtime_optional_with(
+ report_json,
+ cua_vmm::managed::supported(),
+ cua_vmm::managed::LinuxSource::current(),
+ )
+}
+
+fn runtime_optional_with(
+ report_json: &str,
+ managed_supported: bool,
+ source: cua_vmm::managed::LinuxSource,
+) -> Vec<String> {
+ use cua_vmm::{BackendKind as B, host::HostOs, managed::LinuxSource};
+ let Ok(r) = serde_json::from_str::<cua_vmm::auto::DoctorReport>(report_json) else {
+ return Vec::new();
+ };
+ let linux_ready = r.backends.iter().any(|b| {
+ b.ready && matches!(b.backend, B::Qemu | B::Container)
+ || b.backend == B::Managed && r.host.os == HostOs::Macos && (b.ready || b.provisionable)
+ });
+ let mut optional: Vec<String> = r
+ .backends
+ .iter()
+ .filter(|b| {
+ !b.ready
+ && match b.backend {
+ B::Lume => !r.lume.supported_host,
+ B::Managed => {
+ linux_ready || !managed_supported || source == LinuxSource::System
+ }
+ _ => linux_ready,
+ }
+ })
+ .map(|b| b.backend.as_str().to_string())
+ .collect();
+ if linux_ready && !r.backends.iter().any(|b| b.backend == B::Qemu && b.ready) {
+ optional.push("kvm".into());
+ }
+ optional
+}
+
+fn runtime_doctor_output_with(
+ out: &mut dyn std::io::Write,
+ report: &cua_sdk::DoctorReport,
+ json: bool,
+ optional: &[String],
+) -> i32 {
+ use cua_sdk::RuntimeCheckStatus as S;
+ let mut checks = report.checks.clone();
+ for check in &mut checks {
+ if check.status == S::Error && optional.contains(&check.name) {
+ check.status = S::NotApplicable;
+ }
+ }
+ if json {
+ line(out, &report.report_json);
+ } else {
+ for c in &checks {
+ line(
+ out,
+ format!(
+ "{:<10} {:<12} {}{}",
+ c.name,
+ format!("{:?}", c.status).to_lowercase(),
+ c.version
+ .as_ref()
+ .map(|v| format!("[{v}] "))
+ .unwrap_or_default(),
+ c.detail
+ ),
+ );
+ }
+ }
+ i32::from(checks.iter().any(|c| c.status == S::Error))
+}
+
+fn runtime_setup_output(
+ out: &mut dyn std::io::Write,
+ mut steps: Vec<cua_sdk::SetupStep>,
+ optional: &[String],
+ components: &[String],
+) -> i32 {
+ use cua_sdk::RuntimeCheckStatus as S;
+ for s in &mut steps {
+ if s.status == S::Error
+ && optional.contains(&s.name)
+ && !components.contains(&s.name)
+ && !(s.name == "kvm" && components.iter().any(|c| c == "qemu"))
+ {
+ s.status = S::NotApplicable;
+ }
+ line(out, format!("{:<10} {:?}: {}", s.name, s.status, s.detail));
+ }
+ i32::from(steps.iter().any(|s| s.status == S::Error))
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -2807,11 +2895,238 @@ mod tests {
assert!(out.starts_with('{'));
}
+ #[test]
+ fn runtime_optional_backends_preserve_sdk_contract() {
+ use cua_vmm::{
+ BackendKind as B,
+ auto::{BackendStatus, DoctorReport, HostReport},
+ host::HostOs,
+ managed::LinuxSource,
+ };
+ for (os, ready, supported, source, running) in [
+ (HostOs::Linux, B::Qemu, false, LinuxSource::Auto, true),
+ (HostOs::Linux, B::Container, false, LinuxSource::Auto, true),
+ (HostOs::Macos, B::Container, true, LinuxSource::System, true),
+ (HostOs::Macos, B::Managed, true, LinuxSource::Builtin, true),
+ (HostOs::Macos, B::Managed, true, LinuxSource::Builtin, false),
+ ] {
+ let mut r = DoctorReport {
+ host: HostReport {
+ os,
+ arch: cua_vmm::Arch::X86_64,
+ kvm: true,
+ accel: Default::default(),
+ },
+ backends: [B::Qemu, B::Lume, B::Managed, B::Container]
+ .into_iter()
+ .map(|backend| BackendStatus {
+ backend,
+ ready: backend == ready && running,
+ provisionable: matches!(backend, B::Lume | B::Managed),
+ detail: String::new(),
+ missing: vec![],
+ provisioning: vec![],
+ })
+ .collect(),
+ qemu: Default::default(),
+ lume: Default::default(),
+ container: Default::default(),
+ };
+ let raw = cua_daemon::local::doctor_checks(&r);
+ assert_eq!(
+ raw[1].status,
+ cua_proto::daemon::v1::CheckStatus::Installable as i32
+ );
+ if ready != B::Qemu {
+ assert_eq!(
+ raw[0].status,
+ cua_proto::daemon::v1::CheckStatus::Error as i32
+ );
+ }
+ let optional = super::runtime_optional_with(
+ &serde_json::to_string(&r).unwrap(),
+ supported,
+ source,
+ );
+ for (b, c) in r.backends.iter().zip(&raw) {
+ assert!(b.ready || optional.contains(&c.name));
+ }
+ let report = cua_sdk::DoctorReport {
+ checks: raw.into_iter().map(Into::into).collect(),
+ report_json: serde_json::to_string(&r).unwrap(),
+ };
+ for json in [false, true] {
+ let mut out = Vec::new();
+ assert_eq!(
+ super::runtime_doctor_output_with(&mut out, &report, json, &optional),
+ 0
+ );
+ if !json {
+ let text = String::from_utf8(out).unwrap();
+ assert!(!text.contains("error"));
+ assert!(
+ text.lines()
+ .any(|l| l.starts_with("lume") && l.contains("installable"))
+ );
+ }
+ }
+ if os == HostOs::Macos && ready == B::Container {
+ let mut mac = r.clone();
+ mac.lume.supported_host = true;
+ mac.backends
+ .iter_mut()
+ .find(|b| b.backend == B::Lume)
+ .unwrap()
+ .provisionable = false;
+ let report_json = serde_json::to_string(&mac).unwrap();
+ let optional = super::runtime_optional_with(&report_json, supported, source);
+ let report = cua_sdk::DoctorReport {
+ checks: cua_daemon::local::doctor_checks(&mac)
+ .into_iter()
+ .map(Into::into)
+ .collect(),
+ report_json,
+ };
+ for json in [false, true] {
+ assert_eq!(
+ super::runtime_doctor_output_with(
+ &mut Vec::new(),
+ &report,
+ json,
+ &optional
+ ),
+ 1
+ );
+ }
+ assert_eq!(
+ super::runtime_setup_output(
+ &mut Vec::new(),
+ vec![cua_sdk::SetupStep {
+ name: "lume".into(),
+ status: cua_sdk::RuntimeCheckStatus::Error,
+ detail: "unavailable".into(),
+ }],
+ &optional,
+ &[]
+ ),
+ 1
+ );
+ }
+ if ready == B::Container {
+ assert_eq!(
+ super::runtime_setup_output(
+ &mut Vec::new(),
+ vec![cua_sdk::SetupStep {
+ name: "kvm".into(),
+ status: cua_sdk::RuntimeCheckStatus::Error,
+ detail: "permission denied".into(),
+ }],
+ &optional,
+ &["qemu".into()]
+ ),
+ 1
+ );
+ let steps = || {
+ vec![cua_sdk::SetupStep {
+ name: "qemu".into(),
+ status: cua_sdk::RuntimeCheckStatus::Error,
+ detail: "install failed".into(),
+ }]
+ };
+ let mut out = Vec::new();
+ assert_eq!(
+ super::runtime_setup_output(&mut out, steps(), &optional, &["qemu".into()]),
+ 1
+ );
+ assert_eq!(
+ super::runtime_setup_output(&mut out, steps(), &optional, &[]),
+ 0
+ );
+ }
+ r.backends.iter_mut().for_each(|b| {
+ b.ready = false;
+ b.provisionable = false;
+ });
+ let optional = super::runtime_optional_with(
+ &serde_json::to_string(&r).unwrap(),
+ supported,
+ source,
+ );
+ assert!(!optional.contains(&"qemu".into()));
+ assert!(!optional.contains(&"kvm".into()));
+ let report = cua_sdk::DoctorReport {
+ checks: cua_daemon::local::doctor_checks(&r)
+ .into_iter()
+ .map(Into::into)
+ .collect(),
+ report_json: serde_json::to_string(&r).unwrap(),
+ };
+ let mut out = Vec::new();
+ assert_eq!(
+ super::runtime_doctor_output_with(&mut out, &report, false, &optional),
+ 1
+ );
+ assert!(String::from_utf8(out).unwrap().contains("error"));
+ }
+ }
+
+ #[test]
+ fn runtime_output_exit_codes() {
+ use cua_sdk::{DoctorReport, RuntimeCheck, RuntimeCheckStatus as S, SetupStep};
+ for (status, expected) in [(S::Ok, 0), (S::Installable, 0), (S::Error, 1)] {
+ let checks = vec![
+ RuntimeCheck {
+ name: "kvm".into(),
+ status,
+ version: None,
+ detail: "first".into(),
+ },
+ RuntimeCheck {
+ name: "later".into(),
+ status: S::Ok,
+ version: None,
+ detail: "last".into(),
+ },
+ ];
+ let report = DoctorReport {
+ checks,
+ report_json: "{\"checks\":[]}".into(),
+ };
+ for json in [false, true] {
+ let mut out = Vec::new();
+ assert_eq!(
+ super::runtime_doctor_output_with(&mut out, &report, json, &[]),
+ expected
+ );
+ if json {
+ serde_json::from_slice::<serde_json::Value>(&out).unwrap();
+ } else {
+ assert!(String::from_utf8(out).unwrap().contains("last"));
+ }
+ }
+ let steps = report
+ .checks
+ .iter()
+ .map(|c| SetupStep {
+ name: c.name.clone(),
+ status: c.status,
+ detail: c.detail.clone(),
+ })
+ .collect::<Vec<_>>();
+ let mut out = Vec::new();
+ assert_eq!(
+ super::runtime_setup_output(&mut out, steps, &[], &[]),
+ expected
+ );
+ assert!(String::from_utf8(out).unwrap().contains("last"));
+ }
+ }
+
#[tokio::test]
#[ignore = "host: probes the developer's lume, qemu and Docker; run with --ignored"]
async fn runtime_doctor_is_read_only_and_reports_backends() {
let (r, out) = cli(&["--embedded", "runtime", "doctor"]).await;
- assert_eq!(r.unwrap(), 0);
+ assert!([0, 1].contains(&r.unwrap()));
assert!(out.contains("qemu") && out.contains("container"), "{out}");
let (r, out) = cli(&["--embedded", "runtime", "setup", "--dry-run", "qemu"]).await;
assert_eq!(r.unwrap(), 0);
diff --git a/libs/cua/crates/cua-daemon/src/local.rs b/libs/cua/crates/cua-daemon/src/local.rs
index 82e83c1971..2ca397941d 100644
--- a/libs/cua/crates/cua-daemon/src/local.rs
+++ b/libs/cua/crates/cua-daemon/src/local.rs
@@ -1998,6 +1998,21 @@ mod tests {
}
}
+ #[test]
+ fn doctor_preserves_backend_contract() {
+ use cua_proto::daemon::v1::CheckStatus;
+ let mut report = qemu_report(false);
+ assert_eq!(
+ super::doctor_checks(&report)[0].status,
+ CheckStatus::Installable as i32
+ );
+ report.backends[0].provisionable = false;
+ assert_eq!(
+ super::doctor_checks(&report)[0].status,
+ CheckStatus::Error as i32
+ );
+ }
+
fn kvm_step() -> Option<cua_proto::daemon::v1::SetupStep> {
Some(cua_proto::daemon::v1::SetupStep {
name: "kvm".into(),
diff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.json
index 5f8e7ef38b..19e326b3e4 100644
--- a/scripts/docs-generators/cli-specs/cua.json
+++ b/scripts/docs-generators/cli-specs/cua.json
@@ -8301,7 +8301,7 @@
"subcommand_optional": false,
"subcommands": [
{
- "abstract": "Inspect local runtimes (read-only)",
+ "abstract": "Inspect local runtimes (read-only). Exit 1 if any check is Error; warnings exit 0",
"after_help": "Examples:\n cua runtime doctor",
"aliases": [],
"arguments": [],
@@ -8315,7 +8315,7 @@
"usage": "cua runtime doctor [OPTIONS]"
},
{
- "abstract": "Provision local runtimes",
+ "abstract": "Provision local runtimes. Exit 1 if any step is Error; warnings exit 0",
"after_help": "Examples:\n # See what would be installed\n cua runtime setup --dry-run\n cua runtime setup qemu",
"aliases": [],
"arguments": [
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 987240b0c9..9e6f106a31 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -1181,7 +1181,8 @@ linux_runtime() {
return
fi
fi
- die "Cua Spaces on Linux needs QEMU or Docker; install QEMU with: $(qemu_install_command) (or install Docker), then rerun the installer"
+ warn "Cua Spaces on Linux needs QEMU or Docker; install QEMU with: $(qemu_install_command) (or install Docker), then rerun the installer"
+ runtime_failed=1
}
write_mode() {
@@ -1418,9 +1419,13 @@ main() {
tel_stage=cli
install_cli
fi
+ runtime_failed=0
tel_stage=runtime
if [ "$os" = linux ] && [ "$sel_spaces" = 1 ] && { [ "$dry_run" = 1 ] || has "$cua_bin"; }; then
linux_runtime
+ if [ "$dry_run" != 1 ] && { [ "$want_cli" = 1 ] || [ -n "$existing_cua" ]; }; then
+ "$cua_bin" runtime doctor || runtime_failed=1
+ fi
fi
if [ "$sel_spaces" = 1 ]; then
tel_stage=app
@@ -1444,13 +1449,19 @@ main() {
tel_stage=host
host_setup
fi
- tel_stage=other
- tel_send installer_completed
+ if [ "$runtime_failed" = 1 ]; then
+ tel_stage=runtime
+ tel_send installer_failed "$tel_stage" other
+ else
+ tel_stage=other
+ tel_send installer_completed
+ fi
summary
if [ -n "$path_hint" ]; then
say ""
say "$path_hint"
fi
+ return "$runtime_failed"
}
main "$@"
diff --git a/scripts/install/tests/run.sh b/scripts/install/tests/run.sh
index 524fc08664..3060bbfa67 100755
--- a/scripts/install/tests/run.sh
+++ b/scripts/install/tests/run.sh
@@ -60,6 +60,10 @@ if [ "\${1:-} \${2:-} \${3:-}" = "host setup --help" ]; then
exit 0
fi
echo "\$*" >>"\${CUA_FAKE_LOG:-/dev/null}"
+if [ "\$*" = "runtime doctor" ]; then
+ echo 'runtime doctor diagnostic'
+ exit "\${CUA_FAKE_DOCTOR_STATUS:-0}"
+fi
if [ "\$*" = "runtime setup qemu" ]; then
[ -z "\${CUA_FAKE_QEMU_DIR:-}" ] || for t in qemu-img qemu-system-\$(uname -m); do
printf '#!/bin/sh\n' >"\$CUA_FAKE_QEMU_DIR/\$t" && chmod +x "\$CUA_FAKE_QEMU_DIR/\$t"
@@ -181,7 +185,7 @@ check "linux default: installs the Electron AppImage" sh -c "[ -x '$work/p1/bin/
check "linux default: writes the desktop entry" exists "$work/p1/share/applications/cua-spaces.desktop"
check "linux default: no cua-driver" absent "$home/driver.log"
check "linux x64: uses the rolling latest manifest" has_out "cua-install-latest/release-artifacts.json"
-check "non-interactive: prints next steps, no login" sh -c "grep -q 'cua auth login' '$work/out' && [ ! -e '$home/cua.log' ]"
+check "non-interactive: prints next steps, no login" sh -c "grep -q 'cua auth login' '$work/out' && ! grep -q 'auth login' '$home/cua.log'"
check "prefix bin not on PATH: prints a hint" has_out "is not on your PATH"
check "no --modify-path: profile untouched" absent "$home/.profile"
check "--verbose: shows the platform and manifest" has_out "cua-install: platform linux-x64, manifest "
@@ -215,12 +219,15 @@ mkdir -p "$work/qemu-r1"
inst PATH="$work/qemu-r1:$host_path" CUA_FAKE_QEMU_DIR="$work/qemu-r1" -- --yes --no-onboarding --prefix "$work/r1"
check "VM runtime missing, setup succeeds: installs the app" sh -c "[ $status = 0 ] && grep -qx 'runtime setup qemu' '$home/cua.log' && [ -x '$work/r1/bin/cua-spaces' ]"
inst PATH="$host_path" CUA_FAKE_RUNTIME_STATUS=1 -- --yes --no-onboarding --prefix "$work/r2"
-check "VM runtime setup fails: exits with the fix before the app download" sh -c "[ $status != 0 ] && grep -q 'needs QEMU or Docker; install QEMU with: sudo .* install -y qemu' '$work/out' && ! grep -q 'cua-spaces-$version' '$work/out' && [ ! -e '$work/r2/bin/cua-spaces' ]"
+check "VM runtime setup fails: finishes with fix and doctor even when doctor succeeds" sh -c "[ $status = 1 ] && grep -q 'needs QEMU or Docker; install QEMU with: sudo .* install -y qemu' '$work/out' && grep -q 'runtime doctor diagnostic' '$work/out' && grep -q '^Next:' '$work/out' && [ -x '$work/r2/bin/cua-spaces' ]"
inst PATH="$host_path" -- --yes --no-onboarding --prefix "$work/r3"
-check "VM runtime setup leaves QEMU missing: exits with the fix" sh -c "[ $status != 0 ] && grep -q 'needs QEMU or Docker' '$work/out' && [ ! -e '$work/r3/bin/cua-spaces' ]"
+check "VM runtime setup leaves QEMU missing: exits with the fix" sh -c "[ $status != 0 ] && grep -q 'needs QEMU or Docker' '$work/out' && [ -x '$work/r3/bin/cua-spaces' ]"
inst PATH="$host_path" -- --dry-run --no-onboarding --prefix "$work/r4"
check "VM runtime missing, --dry-run: prints the setup only" sh -c "[ $status = 0 ] && grep -q 'dry-run. $work/r4/bin/cua runtime setup qemu' '$work/out' && [ ! -e '$work/r4' ] && [ ! -e '$home/cua.log' ]"
+inst CUA_FAKE_DOCTOR_STATUS=1 -- --yes --no-onboarding --prefix "$work/r5"
+check "doctor-only failure finishes installation" sh -c "[ $status = 1 ] && grep -q 'runtime doctor diagnostic' '$work/out' && grep -q '^Next:' '$work/out' && [ -x '$work/r5/bin/cua-spaces' ]"
+
# ------------------------------------------------------------ selection
# Cua Spaces ships for macOS and Linux; the manifest also lists Windows.
diff --git a/scripts/install/tests/test_install_telemetry.py b/scripts/install/tests/test_install_telemetry.py
index 867e147b0e..c7c223c9d6 100644
--- a/scripts/install/tests/test_install_telemetry.py
+++ b/scripts/install/tests/test_install_telemetry.py
@@ -139,6 +139,60 @@ class InstallTelemetry(unittest.TestCase):
self.assertNotIn(str(self.home), raw)
self.assertNotIn(os.environ.get("USER", "nobody-here"), raw)
+ def test_healthy_qemu_host_sends_completed(self):
+ self.check_runtime_completion(0)
+
+ def test_deferred_runtime_failure_sends_failed_not_completed(self):
+ self.check_runtime_completion(1)
+
+ def test_healthy_docker_host_without_qemu_sends_completed(self):
+ self.check_runtime_completion(0, docker=True)
+
+ def check_runtime_completion(self, doctor_status, docker=False):
+ cli = self.home / "cua"
+ cli.write_text(f'#!/bin/sh\nif [ "$1" = --version ]; then echo "cua {VERSION}"; fi\nif [ "$*" = "runtime doctor" ]; then echo "doctor status {doctor_status}"; exit {doctor_status}; fi\necho "$*" >> "{self.home}/cli.log"\nexit 0\n')
+ cli.chmod(0o755)
+ names = ("docker",) if docker else ("qemu-img", f"qemu-system-{os.uname().machine}")
+ for name in names:
+ binary = self.home / name
+ binary.write_text("#!/bin/sh\nexit 0\n")
+ binary.chmod(0o755)
+ script = self.home / "install.sh"
+ script.write_text(SCRIPT.read_text().replace(
+ 'main "$@"',
+ f'install_cli() {{ cua_bin="{cli}"; }}\ninstall_app_linux() {{ :; }}\nmain "$@"',
+ ))
+ e = {
+ "PATH": f'{self.home}:{os.environ["PATH"]}',
+ "HOME": str(self.home),
+ "CUA_HOME": str(self.home / ".cua"),
+ "CUA_INSTALL_OS": "linux",
+ "CUA_INSTALL_ARCH": "x86_64",
+ "CUA_INSTALL_MANIFEST_URL": self.manifest,
+ "CUA_TELEMETRY_FORBID_NETWORK": "1",
+ "CUA_TELEMETRY_ENDPOINT": f"{self.base}/batch/",
+ "CUA_POSTHOG_KEY": "phc_test",
+ }
+ if docker:
+ self.assertFalse((self.home / "qemu-img").exists())
+ script.write_text(script.read_text().replace(
+ 'main "$@"',
+ 'has() { case "$1" in qemu-img|qemu-system-*) return 1;; *) command -v "$1" >/dev/null 2>&1;; esac; }\nmain "$@"',
+ ))
+ p = subprocess.run(["sh", str(script), "--yes", "--verbose", "--no-onboarding", "--select", "spaces"],
+ env=e, capture_output=True, text=True, timeout=120)
+ self.assertEqual(p.returncode, doctor_status, p.stdout + p.stderr)
+ self.assertIn(f"doctor status {doctor_status}", p.stdout)
+ self.assertIn("Next:", p.stdout)
+ if docker:
+ self.assertIn("VM runtime ok", p.stdout + p.stderr)
+ log = self.home / "cli.log"
+ self.assertNotIn("runtime setup qemu", log.read_text() if log.exists() else "")
+ evs = self.events()
+ self.assertEqual([e["properties"]["step"] for e in evs],
+ ["installer_started", "installer_failed" if doctor_status else "installer_completed"])
+ self.assertEqual(evs[-1]["properties"]["install_stage"], "runtime" if doctor_status else "none")
+
def test_an_existing_install_id_is_kept(self):
d = self.home / ".cua" / "telemetry"
d.mkdir(parents=True)