@@ -33,6 +33,7 @@ class AnalyzerTests: AppTestCase {
3333 // End-to-end test, where we mock at the shell command level (i.e. we
3434 // don't mock the git commands themselves to ensure we're running the
3535 // expected shell commands for the happy path.)
36+ let checkoutDir = QueueIsolated < String ? > ( nil )
3637 try await withDependencies {
3738 $0. date. now = . now
3839 $0. environment. allowSocialPosts = { true }
@@ -43,6 +44,7 @@ class AnalyzerTests: AppTestCase {
4344 return nil
4445 }
4546 }
47+ $0. fileManager. createDirectory = { @Sendable path, _, _ in checkoutDir. setValue ( path) }
4648 $0. httpClient. mastodonPost = { @Sendable _ in }
4749 } operation: {
4850 // setup
@@ -62,7 +64,6 @@ class AnalyzerTests: AppTestCase {
6264 owner: " foo " ,
6365 stars: 100 ) . save ( on: app. db)
6466
65- let checkoutDir = QueueIsolated < String ? > ( nil )
6667 let commands = QueueIsolated < [ Command ] > ( [ ] )
6768 let firstDirCloned = QueueIsolated ( false )
6869 Current . fileManager. fileExists = { @Sendable path in
@@ -75,7 +76,6 @@ class AnalyzerTests: AppTestCase {
7576 if path. hasSuffix ( " Package.resolved " ) { return true }
7677 return false
7778 }
78- Current . fileManager. createDirectory = { @Sendable path, _, _ in checkoutDir. setValue ( path) }
7979 Current . git = . live
8080 Current . shell. run = { @Sendable cmd, path in
8181 let trimmedPath = path. replacingOccurrences ( of: checkoutDir. value!, with: " . " )
@@ -409,26 +409,26 @@ class AnalyzerTests: AppTestCase {
409409
410410 func test_continue_on_exception( ) async throws {
411411 // Test to ensure exceptions don't interrupt processing
412+ let checkoutDir : NIOLockedValueBox < String ? > = . init( nil )
412413 try await withDependencies {
413414 $0. date. now = . now
414415 $0. environment. allowSocialPosts = { true }
415416 $0. environment. loadSPIManifest = { _ in nil }
417+ $0. fileManager. createDirectory = { @Sendable path, _, _ in checkoutDir. withLockedValue { $0 = path } }
416418 } operation: {
417419 // setup
418420 let urls = [ " https://github.com/foo/1 " , " https://github.com/foo/2 " ]
419421 let pkgs = try await savePackages ( on: app. db, urls. asURLs, processingStage: . ingestion)
420422 for p in pkgs {
421423 try await Repository ( package : p, defaultBranch: " main " ) . save ( on: app. db)
422424 }
423- let checkoutDir : NIOLockedValueBox < String ? > = . init( nil )
424425
425426 Current . fileManager. fileExists = { @Sendable path in
426427 if let outDir = checkoutDir. withLockedValue ( { $0 } ) , path == " \( outDir) /github.com-foo-1 " { return true }
427428 if let outDir = checkoutDir. withLockedValue ( { $0 } ) , path == " \( outDir) /github.com-foo-2 " { return true }
428429 if path. hasSuffix ( " Package.swift " ) { return true }
429430 return false
430431 }
431- Current . fileManager. createDirectory = { @Sendable path, _, _ in checkoutDir. withLockedValue { $0 = path } }
432432
433433 Current . git = . live
434434
0 commit comments