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

Update documentation for running tests #3844

Open
xsebek opened this issue Oct 15, 2023 · 2 comments
Open

Update documentation for running tests #3844

xsebek opened this issue Oct 15, 2023 · 2 comments
Labels
documentation level: easy The issue is suited for beginners type: enhancement New feature or request

Comments

@xsebek
Copy link
Contributor

xsebek commented Oct 15, 2023

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. 😅

@fendor
Copy link
Collaborator

fendor commented Oct 18, 2023

Another great way to filter tests is to use the TASTY_PATTERN environment variable.

For example:

TASTY_PATTERN="hlint enables" cabal test haskell-language-server:func-test

@fendor fendor added level: easy The issue is suited for beginners documentation and removed status: needs triage labels Oct 18, 2023
@xsebek
Copy link
Contributor Author

xsebek commented Oct 22, 2023

As another alternative, I attempted to fix the bug in Cabal so this will one day not be an Issue. 😄

This documentation definitely needs an update though, as the "hlint enables" test does not exist after the refactor. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation level: easy The issue is suited for beginners type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants