digitallyinduced / ihp

🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness
https://ihp.digitallyinduced.com/
MIT License
4.94k stars 196 forks source link

Running hspec Test Suites in ghci with Logging Enabled #1243

Open Montmorency opened 2 years ago

Montmorency commented 2 years ago

When running tests according to the standard configuration in IHP guide if I can run one set succesfully. However if i try to run the tests again from the same ghci prompt I hit a:

       uncaught exception: IOException of type ResourceBusy
       openFile: resource busy (file is locked)

If I comment:

    logger <- liftIO $ newLogger def {
        level = Info,
        formatter = withTimeAndLevelFormatter,
        destination = File "Log/app.log" (SizeRotate (Bytes (4 * 1024 * 1024)) 7) defaultBufSize
        }
    option logger

in /Config/Config.hs then I can run multiple tests from the same ghci prompt.

Think the logging file handle is not getting closed when running ghci Tests will check this.

mpscholten commented 2 years ago

The IHP dev server calls the cleanup function of the logger after it's done: https://github.com/digitallyinduced/ihp/blob/master/IHP/Server.hs#L63

Likely this also needs to be called here somehow?