Skip to content

Commit 7bfcbb5

Browse files
committed
Code review feedback
1 parent 6c548c3 commit 7bfcbb5

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

Sources/SwiftlyCore/Commands.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import Foundation
22
import SystemPackage
33

4+
public enum SystemCommand {}
5+
6+
// This file contains a set of system commands that's used by Swiftly and its related tests and tooling
7+
48
// Directory Service command line utility for macOS
5-
public enum SystemCommand {
9+
// See dscl(1) for details
10+
extension SystemCommand {
611
public static func dscl(executable: Executable = DsclCommand.defaultExecutable, datasource: String? = nil) -> DsclCommand {
712
DsclCommand(executable: executable, datasource: datasource)
813
}
@@ -30,7 +35,7 @@ public enum SystemCommand {
3035

3136
return Configuration(
3237
executable: self.executable,
33-
arguments: .init(args),
38+
arguments: Arguments(args),
3439
environment: .inherit
3540
)
3641
}

Sources/SwiftlyCore/ModeledCommandLine.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,6 @@ public struct Arguments: Sendable, ExpressibleByArrayLiteral, Hashable {
121121
}
122122
}
123123

124-
extension Executable {
125-
public func exists() async throws -> Bool {
126-
switch self.storage {
127-
case let .path(p):
128-
return (try await FileSystem.exists(atPath: p))
129-
case let .executable(e):
130-
let path = ProcessInfo.processInfo.environment["PATH"]
131-
132-
guard let path else { return false }
133-
134-
for p in path.split(separator: ":") {
135-
if try await FileSystem.exists(atPath: FilePath(String(p)) / e) {
136-
return true
137-
}
138-
}
139-
140-
return false
141-
}
142-
}
143-
}
144-
145124
public protocol Runnable {
146125
func config() -> Configuration
147126
}

Tests/SwiftlyTests/SwiftlyTests.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ extension Tag {
2525
@Tag static var large: Self
2626
}
2727

28+
extension Executable {
29+
public func exists() async throws -> Bool {
30+
switch self.storage {
31+
case let .path(p):
32+
return (try await FileSystem.exists(atPath: p))
33+
case let .executable(e):
34+
let path = ProcessInfo.processInfo.environment["PATH"]
35+
36+
guard let path else { return false }
37+
38+
for p in path.split(separator: ":") {
39+
if try await FileSystem.exists(atPath: FilePath(String(p)) / e) {
40+
return true
41+
}
42+
}
43+
44+
return false
45+
}
46+
}
47+
}
48+
2849
let unmockedMsg = "All swiftly test case logic must be mocked in order to prevent mutation of the system running the test. This test must either run swiftly components inside a SwiftlyTests.with... closure, or it must have one of the @Test traits, such as @Test(.testHome), or @Test(.mock...)"
2950

3051
actor OutputHandlerFail: OutputHandler {

0 commit comments

Comments
 (0)