Skip to content

Update documentation for running tests #3844

Open
@xsebek

Description

@xsebek

Is your enhancement request related to a problem? Please describe.

The contributing guide mentions this alternative:

cabal run haskell-language-server:func-test -- -p "hlint enables"

This is supposed to work around Cabal flushing caches when using --test-options:

But that does not work, because Cabal does not set executables to PATH for run:

And thus runSession produces this slightly confusing message:

haskell-language-server
  window/workDoneProgress
    sends indefinite progress notifications: FAIL
      Exception: haskell-language-server: createProcess: posix_spawnp: does not exist (No such file or directory)

Describe the solution you'd like

The contributing guide should probably be updated to mention this error and link to the Cabal bug.

As a temporary workaround, the tests could check that the executable exists and print more helpful error.

Describe alternatives you've considered

The users can set HLS_TEST_EXE and HLS_WRAPPER_TEST_EXE like CI does, but that seems brittle.

-- | The command to execute the version of hls for the current compiler.
--
-- Both @stack test@ and @cabal new-test@ setup the environment so @hls@ is
-- on PATH. Cabal seems to respond to @build-tool-depends@ specifically while
-- stack just puts all project executables on PATH.
hlsCommand :: String
{-# NOINLINE hlsCommand #-}
hlsCommand = unsafePerformIO $ do
testExe <- fromMaybe "haskell-language-server" <$> lookupEnv "HLS_TEST_EXE"
pure $ testExe ++ " --lsp -d -j4"

Additional context

I hit this long ago and @pepeiborra helpfully pointed out that this does not work in #2837, but I have since forgotten about it. 😅

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions