chore(mac): apply swiftformat and lint fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@testable import Clawdis
|
||||
import Testing
|
||||
@testable import Clawdis
|
||||
@testable import ClawdisIPC
|
||||
|
||||
@Suite(.serialized) struct AgentRPCTests {
|
||||
|
||||
@@ -12,8 +12,9 @@ import Testing
|
||||
}
|
||||
|
||||
private func makeExec(at path: URL) throws {
|
||||
try FileManager.default.createDirectory(at: path.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true)
|
||||
try FileManager.default.createDirectory(
|
||||
at: path.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true)
|
||||
FileManager.default.createFile(atPath: path.path, contents: Data("echo ok\n".utf8))
|
||||
try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: path.path)
|
||||
}
|
||||
@@ -23,7 +24,7 @@ import Testing
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let clawdisPath = tmp.appendingPathComponent("node_modules/.bin/clawdis")
|
||||
try makeExec(at: clawdisPath)
|
||||
try self.makeExec(at: clawdisPath)
|
||||
|
||||
let cmd = CommandResolver.clawdisCommand(subcommand: "relay")
|
||||
#expect(cmd.prefix(2).elementsEqual([clawdisPath.path, "relay"]))
|
||||
@@ -35,10 +36,10 @@ import Testing
|
||||
|
||||
let nodePath = tmp.appendingPathComponent("node_modules/.bin/node")
|
||||
let scriptPath = tmp.appendingPathComponent("bin/clawdis.js")
|
||||
try makeExec(at: nodePath)
|
||||
try self.makeExec(at: nodePath)
|
||||
try "#!/bin/sh\necho v22.0.0\n".write(to: nodePath, atomically: true, encoding: .utf8)
|
||||
try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: nodePath.path)
|
||||
try makeExec(at: scriptPath)
|
||||
try self.makeExec(at: scriptPath)
|
||||
|
||||
let previous = getenv("CLAWDIS_RUNTIME").flatMap { String(validatingCString: $0) }
|
||||
setenv("CLAWDIS_RUNTIME", "node", 1)
|
||||
@@ -63,7 +64,7 @@ import Testing
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let pnpmPath = tmp.appendingPathComponent("node_modules/.bin/pnpm")
|
||||
try makeExec(at: pnpmPath)
|
||||
try self.makeExec(at: pnpmPath)
|
||||
|
||||
let cmd = CommandResolver.clawdisCommand(subcommand: "rpc")
|
||||
|
||||
@@ -75,7 +76,7 @@ import Testing
|
||||
CommandResolver.setProjectRoot(tmp.path)
|
||||
|
||||
let pnpmPath = tmp.appendingPathComponent("node_modules/.bin/pnpm")
|
||||
try makeExec(at: pnpmPath)
|
||||
try self.makeExec(at: pnpmPath)
|
||||
|
||||
let cmd = CommandResolver.clawdisCommand(subcommand: "health", extraArgs: ["--json", "--timeout", "5"])
|
||||
|
||||
|
||||
@@ -3,12 +3,10 @@ import Testing
|
||||
@testable import Clawdis
|
||||
|
||||
@Suite struct HealthDecodeTests {
|
||||
private let sampleJSON: String = {
|
||||
// minimal but complete payload
|
||||
private let sampleJSON: String = // minimal but complete payload
|
||||
"""
|
||||
{"ts":1733622000,"durationMs":420,"web":{"linked":true,"authAgeMs":120000,"connect":{"ok":true,"status":200,"error":null,"elapsedMs":800}},"heartbeatSeconds":60,"sessions":{"path":"/tmp/sessions.json","count":1,"recent":[{"key":"abc","updatedAt":1733621900,"age":120000}]},"ipc":{"path":"/tmp/ipc.sock","exists":true}}
|
||||
"""
|
||||
}()
|
||||
|
||||
@Test func decodesCleanJSON() async throws {
|
||||
let data = Data(sampleJSON.utf8)
|
||||
@@ -20,7 +18,7 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func decodesWithLeadingNoise() async throws {
|
||||
let noisy = "debug: something logged\n" + sampleJSON + "\ntrailer"
|
||||
let noisy = "debug: something logged\n" + self.sampleJSON + "\ntrailer"
|
||||
let snap = decodeHealthSnapshot(from: Data(noisy.utf8))
|
||||
|
||||
#expect(snap?.web.connect?.status == 200)
|
||||
|
||||
@@ -5,4 +5,3 @@ import Testing
|
||||
#expect(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ import Testing
|
||||
@Test func trimsAfterFirstMatchingTrigger() {
|
||||
let triggers = ["buddy", "claude"]
|
||||
let text = "hello buddy this is after trigger claude also here"
|
||||
#expect(VoiceWakeRuntime._testTrimmedAfterTrigger(text, triggers: triggers) == "this is after trigger claude also here")
|
||||
#expect(VoiceWakeRuntime
|
||||
._testTrimmedAfterTrigger(text, triggers: triggers) == "this is after trigger claude also here")
|
||||
}
|
||||
|
||||
@Test func hasContentAfterTriggerFalseWhenOnlyTrigger() {
|
||||
|
||||
Reference in New Issue
Block a user