@@ -59,7 +59,7 @@ extension AllTests.AnalyzerTests {
59
59
}
60
60
$0. git = . liveValue
61
61
$0. httpClient. mastodonPost = { @Sendable _ in }
62
- $0. shell. run = { @Sendable cmd, path in
62
+ $0. shell. run = { @Sendable cmd, path, _ in
63
63
let trimmedPath = path. replacingOccurrences ( of: checkoutDir. value!, with: " . " )
64
64
commands. withValue {
65
65
$0. append ( . init( command: cmd, path: trimmedPath) !)
@@ -249,7 +249,7 @@ extension AllTests.AnalyzerTests {
249
249
"""
250
250
}
251
251
$0. httpClient. mastodonPost = { @Sendable _ in }
252
- $0. shell. run = { @Sendable cmd, path in
252
+ $0. shell. run = { @Sendable cmd, path, _ in
253
253
if cmd. description. hasSuffix ( " package dump-package " ) {
254
254
return #"""
255
255
{
@@ -320,7 +320,7 @@ extension AllTests.AnalyzerTests {
320
320
$0. git. hasBranch = { @Sendable _, _ in false } // simulate analysis error via branch mismatch
321
321
$0. git. lastCommitDate = { @Sendable _ in . t1 }
322
322
$0. git. shortlog = { @Sendable _ in " " }
323
- $0. shell. run = { @Sendable _, _ in " " }
323
+ $0. shell. run = { @Sendable _, _, _ in " " }
324
324
} operation: {
325
325
// setup
326
326
do {
@@ -374,7 +374,7 @@ extension AllTests.AnalyzerTests {
374
374
2 \t Person 2
375
375
"""
376
376
}
377
- $0. shell. run = { @Sendable cmd, path in
377
+ $0. shell. run = { @Sendable cmd, path, _ in
378
378
// first package fails
379
379
if cmd. description. hasSuffix ( " swift package dump-package " ) && path. hasSuffix ( " foo-1 " ) {
380
380
return " bad data "
@@ -439,7 +439,7 @@ extension AllTests.AnalyzerTests {
439
439
return false
440
440
}
441
441
$0. git = . liveValue
442
- $0. shell. run = { @Sendable cmd, path in
442
+ $0. shell. run = { @Sendable cmd, path, _ in
443
443
commands. withValue {
444
444
$0. append ( . init( command: cmd, path: path) !)
445
445
}
@@ -500,7 +500,7 @@ extension AllTests.AnalyzerTests {
500
500
let commands = QueueIsolated < [ String ] > ( [ ] )
501
501
try await withDependencies {
502
502
$0. fileManager. fileExists = { @Sendable _ in true }
503
- $0. shell. run = { @Sendable cmd, path in
503
+ $0. shell. run = { @Sendable cmd, path, _ in
504
504
commands. withValue { $0. append ( cmd. description) }
505
505
return " "
506
506
}
@@ -532,7 +532,7 @@ extension AllTests.AnalyzerTests {
532
532
2 \t Person 2
533
533
"""
534
534
}
535
- $0. shell. run = { @Sendable cmd, _ in throw TestError . unknownCommand }
535
+ $0. shell. run = { @Sendable cmd, _, _ in throw TestError . unknownCommand }
536
536
} operation: {
537
537
// setup
538
538
let pkg = Package ( id: . id0, url: " 1 " . asGithubUrl. url)
@@ -641,7 +641,7 @@ extension AllTests.AnalyzerTests {
641
641
if ref == . tag( 1 , 2 , 3 ) { return . init( commit: " sha.1.2.3 " , date: . t1) }
642
642
fatalError ( " unknown ref: \( ref) " )
643
643
}
644
- $0. shell. run = { @Sendable cmd, _ in throw TestError . unknownCommand }
644
+ $0. shell. run = { @Sendable cmd, _, _ in throw TestError . unknownCommand }
645
645
} operation: {
646
646
//setup
647
647
let pkgId = UUID ( )
@@ -777,7 +777,7 @@ extension AllTests.AnalyzerTests {
777
777
try await withDependencies {
778
778
$0. environment. loadSPIManifest = { _ in nil }
779
779
$0. fileManager. fileExists = { @Sendable _ in true }
780
- $0. shell. run = { @Sendable cmd, _ in
780
+ $0. shell. run = { @Sendable cmd, _, _ in
781
781
commands. withValue {
782
782
$0. append ( cmd. description)
783
783
}
@@ -938,7 +938,7 @@ extension AllTests.AnalyzerTests {
938
938
2 \t Person 2
939
939
"""
940
940
}
941
- $0. shell. run = { @Sendable cmd, path in
941
+ $0. shell. run = { @Sendable cmd, path, _ in
942
942
if cmd. description. hasSuffix ( " swift package dump-package " ) {
943
943
return #"""
944
944
{
@@ -995,7 +995,7 @@ extension AllTests.AnalyzerTests {
995
995
// claim every file exists, including our ficticious 'index.lock' for which
996
996
// we want to trigger the cleanup mechanism
997
997
$0. fileManager. fileExists = { @Sendable path in true }
998
- $0. shell. run = { @Sendable cmd, path in
998
+ $0. shell. run = { @Sendable cmd, path, _ in
999
999
commands. withValue { $0. append ( cmd. description) }
1000
1000
return " "
1001
1001
}
@@ -1027,7 +1027,7 @@ extension AllTests.AnalyzerTests {
1027
1027
// claim every file exists, including our ficticious 'index.lock' for which
1028
1028
// we want to trigger the cleanup mechanism
1029
1029
$0. fileManager. fileExists = { @Sendable path in true }
1030
- $0. shell. run = { @Sendable cmd, path in
1030
+ $0. shell. run = { @Sendable cmd, path, _ in
1031
1031
commands. withValue { $0. append ( cmd. description) }
1032
1032
if cmd == . gitCheckout( branch: " master " ) {
1033
1033
throw TestError . simulatedCheckoutError
@@ -1132,29 +1132,40 @@ extension AllTests.AnalyzerTests {
1132
1132
try await withDependencies {
1133
1133
$0. logger = . noop
1134
1134
} 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
+ }
1149
1150
}
1150
- }
1151
1151
#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 " )
1153
1153
#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 " )
1155
1155
#endif
1156
+ }
1156
1157
}
1157
1158
}
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
+ }
1158
1169
}
1159
1170
1160
1171
@Test func issue_577( ) async throws {
@@ -1193,7 +1204,7 @@ extension AllTests.AnalyzerTests {
1193
1204
let commands = QueueIsolated < [ String ] > ( [ ] )
1194
1205
try await withDependencies {
1195
1206
$0. fileManager. fileExists = { @Sendable _ in true }
1196
- $0. shell. run = { @Sendable cmd, _ in
1207
+ $0. shell. run = { @Sendable cmd, _, _ in
1197
1208
commands. withValue { $0. append ( cmd. description) }
1198
1209
if cmd == . gitFetchAndPruneTags { throw TestError . simulatedFetchError }
1199
1210
return " "
@@ -1297,7 +1308,7 @@ extension AllTests.AnalyzerTests {
1297
1308
if path. hasSuffix ( " github.com-foo-1 " ) { return false }
1298
1309
return true
1299
1310
}
1300
- $0. shell. run = { @Sendable cmd, path in
1311
+ $0. shell. run = { @Sendable cmd, path, _ in
1301
1312
if cmd == . gitClone( url: url, to: repoDir) {
1302
1313
struct ShellOutError : Error { }
1303
1314
throw ShellOutError ( )
@@ -1355,7 +1366,7 @@ extension AllTests.AnalyzerTests {
1355
1366
1 \t Person 2
1356
1367
"""
1357
1368
}
1358
- $0. shell. run = { @Sendable _, _ in " " }
1369
+ $0. shell. run = { @Sendable _, _, _ in " " }
1359
1370
} operation: {
1360
1371
let pkgId = UUID ( )
1361
1372
let pkg = Package ( id: pkgId, url: " 1 " . asGithubUrl. url, processingStage: . ingestion)
@@ -1427,7 +1438,7 @@ extension AllTests.AnalyzerTests {
1427
1438
try await withDependencies { // third scenario: everything throws
1428
1439
$0. git. getTags = { @Sendable _ in throw TestError . unspecifiedError }
1429
1440
$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 }
1431
1442
} operation: {
1432
1443
// MUT
1433
1444
try await Analyze . analyze ( client: app. client,
@@ -1464,7 +1475,7 @@ extension AllTests.AnalyzerTests {
1464
1475
"""
1465
1476
}
1466
1477
$0. logger = . testLogger( capturingLogger)
1467
- $0. shell. run = { @Sendable _, _ in return " " }
1478
+ $0. shell. run = { @Sendable _, _, _ in return " " }
1468
1479
} operation: {
1469
1480
let pkgId = UUID ( )
1470
1481
let pkg = Package ( id: pkgId, url: " 1 " . asGithubUrl. url, processingStage: . ingestion)
@@ -1526,7 +1537,7 @@ extension AllTests.AnalyzerTests {
1526
1537
throw Error ( )
1527
1538
}
1528
1539
}
1529
- $0. shell. run = { @Sendable cmd, path in
1540
+ $0. shell. run = { @Sendable cmd, path, _ in
1530
1541
// simulate error in getPackageInfo by failing checkout
1531
1542
if cmd == . gitCheckout( branch: " main " ) {
1532
1543
throw Error ( )
@@ -1569,7 +1580,7 @@ extension AllTests.AnalyzerTests {
1569
1580
$0. git. lastCommitDate = { @Sendable _ in . t1 }
1570
1581
$0. git. revisionInfo = { @Sendable _, _ in . init( commit: " sha1 " , date: . t0) }
1571
1582
$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
1573
1584
if cmd == . swiftDumpPackage { return . packageDump( name: " foo1 " ) }
1574
1585
return " "
1575
1586
}
0 commit comments