We're happy to Announce Thin Backend - a blazing fast, universal web app backend for making realtime SPAs

Running Consecutive Tests From ghci with hspec

montmorency BUSINESS

If I load and run a /Main/Test.hs module to ghci from an IHP app and run the test suite one I get expected behaviour. But if a test fails and then I try to run main again from ghci prompt I get a:

    # PENDING: exception in beforeAll-hook (see previous failure)

on test that run successfully previously and on subsequent test

  1) Visits Controller has no existing visits
       uncaught exception: IOException of type ResourceBusy
       openFile: resource busy (file is locked)

I'm wondering if a test fails is there a db lock due to the transaction block? Is there a way to manually release the lock?

Amitai Burstein

I saw this error when the server wasn't running. Do you have ./start running on another tab?

montmorency BUSINESS

Hey! Yes I have tried two ways. One with the dev server running in a separate tab and one where I started a postgres server with make postgres and have it as a background process. The error occurs in both cases on the second run of the tests.

Amitai Burstein

Are you able to reproduce on another computer/ Gitpod?

montmorency BUSINESS

Found source of issue. I have logging enabled. If I comment:

    logger <- liftIO $ newLogger def {
        level = Info,
        formatter = withTimeAndLevelFormatter,
        destination = File "Log/ulhg.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.

Otherwise I hit the error:

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

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

marc PRO

This has been fixed via https://github.com/digitallyinduced/ihp/pull/1319