@@ -59,7 +59,7 @@ extension AllTests.AnalyzerTests {
5959 }
6060 $0. git = . liveValue
6161 $0. httpClient. mastodonPost = { @Sendable _ in }
62- $0. shell. run = { @Sendable cmd, path in
62+ $0. shell. run = { @Sendable cmd, path, _ in
6363 let trimmedPath = path. replacingOccurrences ( of: checkoutDir. value!, with: " . " )
6464 commands. withValue {
6565 $0. append ( . init( command: cmd, path: trimmedPath) !)
@@ -249,7 +249,7 @@ extension AllTests.AnalyzerTests {
249249 """
250250 }
251251 $0. httpClient. mastodonPost = { @Sendable _ in }
252- $0. shell. run = { @Sendable cmd, path in
252+ $0. shell. run = { @Sendable cmd, path, _ in
253253 if cmd. description. hasSuffix ( " package dump-package " ) {
254254 return #"""
255255 {
@@ -320,7 +320,7 @@ extension AllTests.AnalyzerTests {
320320 $0. git. hasBranch = { @Sendable _, _ in false } // simulate analysis error via branch mismatch
321321 $0. git. lastCommitDate = { @Sendable _ in . t1 }
322322 $0. git. shortlog = { @Sendable _ in " " }
323- $0. shell. run = { @Sendable _, _ in " " }
323+ $0. shell. run = { @Sendable _, _, _ in " " }
324324 } operation: {
325325 // setup
326326 do {
@@ -374,7 +374,7 @@ extension AllTests.AnalyzerTests {
374374 2 \t Person 2
375375 """
376376 }
377- $0. shell. run = { @Sendable cmd, path in
377+ $0. shell. run = { @Sendable cmd, path, _ in
378378 // first package fails
379379 if cmd. description. hasSuffix ( " swift package dump-package " ) && path. hasSuffix ( " foo-1 " ) {
380380 return " bad data "
@@ -439,7 +439,7 @@ extension AllTests.AnalyzerTests {
439439 return false
440440 }
441441 $0. git = . liveValue
442- $0. shell. run = { @Sendable cmd, path in
442+ $0. shell. run = { @Sendable cmd, path, _ in
443443 commands. withValue {
444444 $0. append ( . init( command: cmd, path: path) !)
445445 }
@@ -500,7 +500,7 @@ extension AllTests.AnalyzerTests {
500500 let commands = QueueIsolated < [ String ] > ( [ ] )
501501 try await withDependencies {
502502 $0. fileManager. fileExists = { @Sendable _ in true }
503- $0. shell. run = { @Sendable cmd, path in
503+ $0. shell. run = { @Sendable cmd, path, _ in
504504 commands. withValue { $0. append ( cmd. description) }
505505 return " "
506506 }
@@ -532,7 +532,7 @@ extension AllTests.AnalyzerTests {
532532 2 \t Person 2
533533 """
534534 }
535- $0. shell. run = { @Sendable cmd, _ in throw TestError . unknownCommand }
535+ $0. shell. run = { @Sendable cmd, _, _ in throw TestError . unknownCommand }
536536 } operation: {
537537 // setup
538538 let pkg = Package ( id: . id0, url: " 1 " . asGithubUrl. url)
@@ -641,7 +641,7 @@ extension AllTests.AnalyzerTests {
641641 if ref == . tag( 1 , 2 , 3 ) { return . init( commit: " sha.1.2.3 " , date: . t1) }
642642 fatalError ( " unknown ref: \( ref) " )
643643 }
644- $0. shell. run = { @Sendable cmd, _ in throw TestError . unknownCommand }
644+ $0. shell. run = { @Sendable cmd, _, _ in throw TestError . unknownCommand }
645645 } operation: {
646646 //setup
647647 let pkgId = UUID ( )
@@ -777,7 +777,7 @@ extension AllTests.AnalyzerTests {
777777 try await withDependencies {
778778 $0. environment. loadSPIManifest = { _ in nil }
779779 $0. fileManager. fileExists = { @Sendable _ in true }
780- $0. shell. run = { @Sendable cmd, _ in
780+ $0. shell. run = { @Sendable cmd, _, _ in
781781 commands. withValue {
782782 $0. append ( cmd. description)
783783 }
@@ -938,7 +938,7 @@ extension AllTests.AnalyzerTests {
938938 2 \t Person 2
939939 """
940940 }
941- $0. shell. run = { @Sendable cmd, path in
941+ $0. shell. run = { @Sendable cmd, path, _ in
942942 if cmd. description. hasSuffix ( " swift package dump-package " ) {
943943 return #"""
944944 {
@@ -995,7 +995,7 @@ extension AllTests.AnalyzerTests {
995995 // claim every file exists, including our ficticious 'index.lock' for which
996996 // we want to trigger the cleanup mechanism
997997 $0. fileManager. fileExists = { @Sendable path in true }
998- $0. shell. run = { @Sendable cmd, path in
998+ $0. shell. run = { @Sendable cmd, path, _ in
999999 commands. withValue { $0. append ( cmd. description) }
10001000 return " "
10011001 }
@@ -1027,7 +1027,7 @@ extension AllTests.AnalyzerTests {
10271027 // claim every file exists, including our ficticious 'index.lock' for which
10281028 // we want to trigger the cleanup mechanism
10291029 $0. fileManager. fileExists = { @Sendable path in true }
1030- $0. shell. run = { @Sendable cmd, path in
1030+ $0. shell. run = { @Sendable cmd, path, _ in
10311031 commands. withValue { $0. append ( cmd. description) }
10321032 if cmd == . gitCheckout( branch: " master " ) {
10331033 throw TestError . simulatedCheckoutError
@@ -1132,29 +1132,40 @@ extension AllTests.AnalyzerTests {
11321132 try await withDependencies {
11331133 $0. logger = . noop
11341134 } operation: {
1135- try await withTempDir { @Sendable tempDir in
1136- let fixture = fixturesDirectory ( )
1137- . appendingPathComponent ( " 5.9-Package-swift " ) . path
1138- let fname = tempDir. appending ( " /Package.swift " )
1139- try await ShellOut . shellOut ( to: . copyFile( from: fixture, to: fname) )
1140- var json = try await ShellClient . liveValue. run ( command: . swiftDumpPackage, at: tempDir)
1141- do { // "root" references tempDir's absolute path - replace it to make the test stable
1142- if var obj = try JSONSerialization . jsonObject ( with: Data ( json. utf8) ) as? [ String : Any ] ,
1143- var packageKind = obj [ " packageKind " ] as? [ String : Any ] {
1144- packageKind [ " root " ] = [ " <tempdir> " ]
1145- obj [ " packageKind " ] = packageKind
1146- let data = try JSONSerialization . data ( withJSONObject: obj,
1147- options: [ . prettyPrinted, . sortedKeys, . withoutEscapingSlashes] )
1148- json = String ( decoding: data, as: UTF8 . self)
1135+ try await withTempDir { @Sendable tempDir in
1136+ let fixture = fixturesDirectory ( )
1137+ . appendingPathComponent ( " 5.9-Package-swift " ) . path
1138+ let fname = tempDir. appending ( " /Package.swift " )
1139+ try await ShellOut . shellOut ( to: . copyFile( from: fixture, to: fname) )
1140+ var json = try await ShellClient . liveValue. run ( command: . swiftDumpPackage, at: tempDir)
1141+ do { // "root" references tempDir's absolute path - replace it to make the test stable
1142+ if var obj = try JSONSerialization . jsonObject ( with: Data ( json. utf8) ) as? [ String : Any ] ,
1143+ var packageKind = obj [ " packageKind " ] as? [ String : Any ] {
1144+ packageKind [ " root " ] = [ " <tempdir> " ]
1145+ obj [ " packageKind " ] = packageKind
1146+ let data = try JSONSerialization . data ( withJSONObject: obj,
1147+ options: [ . prettyPrinted, . sortedKeys, . withoutEscapingSlashes] )
1148+ json = String ( decoding: data, as: UTF8 . self)
1149+ }
11491150 }
1150- }
11511151#if os(macOS)
1152- assertSnapshot ( of: json, as: . init( pathExtension: " json " , diffing: . lines) , named: " macos " )
1152+ assertSnapshot ( of: json, as: . init( pathExtension: " json " , diffing: . lines) , named: " macos " )
11531153#elseif os(Linux)
1154- assertSnapshot ( of: json, as: . init( pathExtension: " json " , diffing: . lines) , named: " linux " )
1154+ assertSnapshot ( of: json, as: . init( pathExtension: " json " , diffing: . lines) , named: " linux " )
11551155#endif
1156+ }
11561157 }
11571158 }
1159+
1160+ @Test func processingEnvironmentVariable( ) async throws {
1161+ try await withDependencies {
1162+ $0. logger = . noop
1163+ $0. shell = . liveValue
1164+ } operation: {
1165+ @Dependency ( \. shell) var shell
1166+ let res = try await shell. run ( command: . init( command: " printenv " , arguments: [ " SPI_PROCESSING " ] ) , at: " /tmp " )
1167+ #expect( res == " 1 " )
1168+ }
11581169 }
11591170
11601171 @Test func issue_577( ) async throws {
@@ -1193,7 +1204,7 @@ extension AllTests.AnalyzerTests {
11931204 let commands = QueueIsolated < [ String ] > ( [ ] )
11941205 try await withDependencies {
11951206 $0. fileManager. fileExists = { @Sendable _ in true }
1196- $0. shell. run = { @Sendable cmd, _ in
1207+ $0. shell. run = { @Sendable cmd, _, _ in
11971208 commands. withValue { $0. append ( cmd. description) }
11981209 if cmd == . gitFetchAndPruneTags { throw TestError . simulatedFetchError }
11991210 return " "
@@ -1297,7 +1308,7 @@ extension AllTests.AnalyzerTests {
12971308 if path. hasSuffix ( " github.com-foo-1 " ) { return false }
12981309 return true
12991310 }
1300- $0. shell. run = { @Sendable cmd, path in
1311+ $0. shell. run = { @Sendable cmd, path, _ in
13011312 if cmd == . gitClone( url: url, to: repoDir) {
13021313 struct ShellOutError : Error { }
13031314 throw ShellOutError ( )
@@ -1355,7 +1366,7 @@ extension AllTests.AnalyzerTests {
13551366 1 \t Person 2
13561367 """
13571368 }
1358- $0. shell. run = { @Sendable _, _ in " " }
1369+ $0. shell. run = { @Sendable _, _, _ in " " }
13591370 } operation: {
13601371 let pkgId = UUID ( )
13611372 let pkg = Package ( id: pkgId, url: " 1 " . asGithubUrl. url, processingStage: . ingestion)
@@ -1427,7 +1438,7 @@ extension AllTests.AnalyzerTests {
14271438 try await withDependencies { // third scenario: everything throws
14281439 $0. git. getTags = { @Sendable _ in throw TestError . unspecifiedError }
14291440 $0. git. revisionInfo = { @Sendable _, _ in throw TestError . unspecifiedError }
1430- $0. shell. run = { @Sendable _, _ in throw TestError . unspecifiedError }
1441+ $0. shell. run = { @Sendable _, _, _ in throw TestError . unspecifiedError }
14311442 } operation: {
14321443 // MUT
14331444 try await Analyze . analyze ( client: app. client,
@@ -1464,7 +1475,7 @@ extension AllTests.AnalyzerTests {
14641475 """
14651476 }
14661477 $0. logger = . testLogger( capturingLogger)
1467- $0. shell. run = { @Sendable _, _ in return " " }
1478+ $0. shell. run = { @Sendable _, _, _ in return " " }
14681479 } operation: {
14691480 let pkgId = UUID ( )
14701481 let pkg = Package ( id: pkgId, url: " 1 " . asGithubUrl. url, processingStage: . ingestion)
@@ -1526,7 +1537,7 @@ extension AllTests.AnalyzerTests {
15261537 throw Error ( )
15271538 }
15281539 }
1529- $0. shell. run = { @Sendable cmd, path in
1540+ $0. shell. run = { @Sendable cmd, path, _ in
15301541 // simulate error in getPackageInfo by failing checkout
15311542 if cmd == . gitCheckout( branch: " main " ) {
15321543 throw Error ( )
@@ -1569,7 +1580,7 @@ extension AllTests.AnalyzerTests {
15691580 $0. git. lastCommitDate = { @Sendable _ in . t1 }
15701581 $0. git. revisionInfo = { @Sendable _, _ in . init( commit: " sha1 " , date: . t0) }
15711582 $0. git. shortlog = { @Sendable _ in " 10 \t Person 1 " }
1572- $0. shell. run = { @Sendable cmd, path in
1583+ $0. shell. run = { @Sendable cmd, path, _ in
15731584 if cmd == . swiftDumpPackage { return . packageDump( name: " foo1 " ) }
15741585 return " "
15751586 }
0 commit comments