XCTest does not execute tests when using vapor and pythonkit

I am doing a simple xctest setup using Vapor (XCTVapor). But it never executes my test.

After 5 minutes it terminates saying . Test runner never began executing tests after launching.

static func main() async throws {
    var env = try Environment.detect()
    try LoggingSystem.bootstrap(from: &env)
    
    #if false
    guard let stdLibPath = Bundle.main.path(forResource: "python-stdlib", ofType: nil) else { return }
    guard let libDynloadPath = Bundle.main.path(forResource: "python-stdlib/lib-dynload", ofType: nil) else { return }
    setenv("PYTHONHOME", stdLibPath, 1)
    setenv("PYTHONPATH", "\(stdLibPath):\(libDynloadPath)", 1)
    // Temporarily disable Python
    Py_Initialize()
    print ("Py_Initialize complete")
    #endif
    
    // we now have a Python interpreter ready to be used
    let app = Application(env)
    defer { app.shutdown() }
    
    do {
        try await configure(app)
    } catch {
        app.logger.report(error: error)
        throw error
    }
    try await app.execute()
}

I am able to hit the breakpoint on app.execute but there is no progress following. I am building through xcode.

In the spindump the dispatch thread.

Thread 0x23a87 DispatchQueue "com.apple.main-thread"(1) 412 samples (1-412) priority 46 (base 46)
412 start + 1903 (dyld + 25631) [0x7ff80675441f]
412 main + 102 (entrypoint.swift in eipohub + 14630) [0x1050d4926]
412 ??? (libswift_Concurrency.dylib + 227060) [0x7ffc0beb16f4]
412 ??? (libswift_Concurrency.dylib + 227107) [0x7ffc0beb1723]
412 CFRunLoopRun + 40 (CoreFoundation + 1041893) [0x7ff806c0b5e5]
412 CFRunLoopRunSpecific + 560 (CoreFoundation + 503489) [0x7ff806b87ec1]
412 __CFRunLoopRun + 1365 (CoreFoundation + 506496) [0x7ff806b88a80]
412 __CFRunLoopServiceMachPort + 145 (CoreFoundation + 511999) [0x7ff806b89fff]
412 mach_msg + 19 (libsystem_kernel.dylib + 6282) [0x7ff806a6f88a]
412 mach_msg_overwrite + 692 (libsystem_kernel.dylib + 34260) [0x7ff806a765d4]
412 mach_msg2_trap + 10 (libsystem_kernel.dylib + 5538) [0x7ff806a6f5a2]
*411 ipc_mqueue_receive_continue + 0 (kernel + 1528192) [0xffffff8000451180]
*1 ipc_mqueue_receive_continue + 0 (kernel + 1528192) [0xffffff8000451180]

All other threads seem to be from NIO threadpool. (NIO-ELT-) and (TP-#). 16 threads each.

I'm confused by the code - you talk about testing and XCTVapor but your code is using a main function and just booting a plain Vapor app?

When Vapor creates a template default application, it creates the main and you can build your app around that. So the main is generated code from vapor. I built a .xcodeproj around the template app, and I am having trouble getting its tests to work.

Right but what tests? You're not showing any tests you're running? And why are you generating an Xcode project? That's not supported by Vapor

The tests are irrelevant because it is not even getting to the tests. It times out waiting for something before it gets to text execution. It does not hit any breakpoints , or prints even on a single test. And the message says that the test runner timed out. This is the default vapor test that fails to run.

func testHelloWorld() async throws {
let app = Application(.testing)
defer { app.shutdown() }
try await configure(app)

    try app.test(.GET, "hello", afterResponse: { res in
        XCTAssertEqual(res.status, .ok)
        XCTAssertEqual(res.body.string, "Hello, world!")
    })
}}

I need to use xcodeproj for some post build scripts that are not supported by swift package manager. Is there a reason or a blocker why vapor does not support xcodeproj? If I understand why that is maybe I can do something to work around or enable it.

Ok I think I know what's going on. You can't use your normal setup for an application - app.execute() is blocking so it will never return. I don't understand why you've configured your test runner to use that instead of the default one where you're also creating another application

You have it correct that somehow it is picking up the main instead of the test runner. But I have not specifically configured by test runner to do that. Xcode seems to be doing it automatically, once I import the app in the test file (as one does typically in order to test the app), then it automatically executes the main. I don't know what I should do to prevent that.

For now I am trying a different approach, I am having only a thin client with the main and shifting all the Vapor access into a separate swift package, so that I can test the swift package without the main getting in the way.