Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the tests that require Postgres by default #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chris-martin
Copy link
Contributor

I'm running into trouble building Opaleye as a Nix package because the tests fail when there is no running Postgres server, so I was thinking it might be nice if these tests were disabled by default and re-enabled by a flag.

@tomjaguarpaw
Copy link
Owner

Thanks Chris. I'd like to minimise the additional complexity to Opaleye as much as possible. My first question is, would it be satisfactory to simply disable tests when building Opaleye for Nix? If not, my second proposal would be to add a command-line flag to the test suite which enables or disables the Postgres tests. Would that be satisfactory? I'm not sure how setting that flag would be done in the cabal file.

Do any other Nix users want to chime in? @ocharles perhaps?

@expipiplus1
Copy link
Collaborator

-- From https://github.com/input-output-hk/ouroboros-network
-- | Infer from environment variables whether we are running within a Nix build
-- (and not just a nix-shell).
inNixBuild :: IO Bool
inNixBuild = do
  let testEnv = fmap (maybe False (not . null)) . System.Environment.lookupEnv
  haveNixBuildDir <- testEnv "NIX_BUILD_TOP"
  inNixShell      <- testEnv "IN_NIX_SHELL"
  pure (haveNixBuildDir && not inNixShell)

Something like this can be used to determine when to run such tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants