Skip to content

hspec-discover file fails with "could not execute: hspec-discover" #544

Closed
@ProofOfKeags

Description

@ProofOfKeags

Subject of the issue

Problems tab has a persistent issue (sometimes 2 copies) of
haskell-language-server-8.10.2: could not execute: hspec-discover

Background

Hspec-Discover is a "magic" tool that allows you to just have test files that get auto-assembled into a main method such that the "spec :: Spec" signature is evaluated in Hspec's environment. I do not understand in the slightest how it works under the hood, but it involves a single {-# OPTIONS_GHC ... #-} pragma that can discover all these test modules.

My Details

{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}

Relevant stanza in package.yaml

tests:
  agent-test:
    source-dirs: test
    main: Main.hs
    ghc-options:
    - -Wall
    - -fdefer-typed-holes
    dependencies:
    - ambassador-agent
    - hspec >=2.0.0
    - hspec-expectations
    - hedgehog
    - yesod-test
    - random
    when:
    - condition: false
      other-modules: Paths_ambassador_agent

Your environment

  • HLS: 0.5.1 on ghc8.10.2
  • Editor: VSCode
  • Project base: stack / resolver = nightly-2020-09-29
  • hie.yaml:
cradle:
  stack:
    - path: "./src"
      component: "ambassador-agent:lib"

    - path: "./app/main.hs"
      component: "ambassador-agent:exe:agent"

    - path: "./test"
      component: "ambassador-agent:test:agent-test"

    - path: "./"
      component: "ambassador-agent:lib"

Steps to reproduce

I have not put together a minimal repro, but I suspect this can be done by having a "trivial" library, and a test module that follows the instructions here: https://hspec.github.io/hspec-discover.html

Expected behaviour

I'd expect that there was no error in my problems tab.

Actual behaviour

There is an error in my problems tab, enumerated in the subject

Speculation

I'm guessing based on how the error is worded, that hls is attempting to execute hspec-discover itself. If it is not in hls's "PATH" then it could just not be finding it. That said, my project is stack based, and a stack exec hspec-discover yields usage info, so it is definitely available inside the stack environment which I'd imagine hls has access to.

The next guess is that for some reason the arguments aren't being properly given to it by hls. But I would have guessed that this would be delegated to GHC and GHC has well defined semantics around how arguments are supplied to these sorts of pragmas: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/phases.html#ghc-flag--F

I don't have any ideas besides that. Open to thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    can-workaroundcomponent: hie-biosstatus: blockedNot actionable, because blocked by upstream/GHC etc.type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions