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.

1.8 KB
Raw Blame
import ArgumentParser
import Foundation
import Testing

@testable import lume

@Test("Run parses detached mode and a custom log path")
func detachedRunParsing() throws {
  let command = try Run.parse([
    "test-vm", "--detach", "--log-file", "~/custom-lume.log",
  ])

  #expect(command.detach)
  #expect(command.logFile == "~/custom-lume.log")
}

@Test("Detached child arguments remove the detach flag without changing VM options")
func detachedChildArguments() {
  let arguments = DetachedVMRunner.childArguments(from: [
    "/path/to/lume", "run", "test-vm", "--detach", "--display", "native",
    "--log-file", "/tmp/vm.log", "--shared-dir", "/tmp/shared",
  ])

  #expect(
    arguments == [
      "run", "test-vm", "--display", "native", "--shared-dir", "/tmp/shared",
    ])
}

@Test("Detached runs stay viewer-free when no display is explicitly requested")
func detachedRunDefaultDisplay() {
  let arguments = DetachedVMRunner.childArguments(from: [
    "/path/to/lume", "run", "test-vm", "--detach",
  ])

  #expect(arguments == ["run", "test-vm", "--display", "none"])
}

@Test("Detached runs use a per-VM log in the user Library")
func detachedDefaultLogPath() {
  let path = DetachedVMRunner.defaultLogURL(vmName: "example/vm:latest").path
  #expect(path.hasSuffix("/Library/Logs/lume/example_vm_latest.log"))
}

@Test("A Local detached run logs to lume-local's own directory, never the released Lume's")
func detachedLocalLogPath() {
  let home = URL(fileURLWithPath: "/Users/dev", isDirectory: true)
  #expect(
    DetachedVMRunner.defaultLogURL(vmName: "example/vm:latest", channel: .local, userHome: home).path
      == "/Users/dev/Library/Logs/lume-local/example_vm_latest.log")
  #expect(
    DetachedVMRunner.defaultLogURL(vmName: "example/vm:latest", channel: .stable, userHome: home).path
      == "/Users/dev/Library/Logs/lume/example_vm_latest.log")
}