Skip to content

Can't resolve cabal test suite dependencies with multiple test suites #4085

@Softsun2

Description

@Softsun2

Your environment

Which OS do you use?
MacOS

Which version of GHC do you use and how did you install it?
9.2.8 from nixpkgs (23.05)

How is your project built?
cabal (dependencies provided by nix). my flake.nix

Which LSP client (editor/plugin) do you use?
Neovim+LanguageClient-neovim (builtin client)

Which version of HLS do you use and how did you install it?
1.10.0.0 from nixpkgs (23.05)

Have you configured HLS in any way (especially: a hie.yaml file)?
No (unless passing the logfile flag counts)

Steps to reproduce

  1. Configure cabal project with multiple test suites. Here's my exact cabal file.
  2. Configure test suite with dependencies:
-- lumea.cabal
...
test-suite meta-test
    type: exitcode-stdio-1.0
    main-is: MetaTest.hs
    build-depends:
        base ^>=4.16.4.0,
        HUnit,
        pandoc, pandoc-types,
        Lumea,
        filepath, directory
    hs-source-dirs: test
    default-language: Haskell2010
...
  1. Import dependencies in configured test file:
-- test/MetaTest.hs
module Main where

import qualified Meta
import Test.HUnit
import Text.Pandoc
...
  1. Observe that running test suite resolves the imported dependencies and runs fine (running cabal test meta-test)
  2. Edit test file, observe dependency can not be resolved:
Screenshot 2024-02-18 at 7 18 59 PM

Expected behaviour

I'd expect hls to be able to resolve the pandoc dependencies when editing my test file if they can be compiled and run.

Debug information

Curiously, if I add pandoc as a dependency to another test suite. A test suite with the same hs-source-dirs, then when I'm editing test/MetaTest.hs the dependency is resolved and I don't get a warning.

test-suite site-test
    type: exitcode-stdio-1.0
    main-is: SiteTest.hs
    build-depends:
        base ^>=4.16.4.0,
        HUnit,
        pandoc, pandoc-types,
        Lumea,
        filepath, directory
    hs-source-dirs: test
    default-language: Haskell2010

test-suite meta-test
    type: exitcode-stdio-1.0
    main-is: MetaTest.hs
    build-depends:
        base ^>=4.16.4.0,
        HUnit,
        pandoc, pandoc-types,
        Lumea,
        filepath, directory
    hs-source-dirs: test
    default-language: Haskell2010

Nothing looks out of the ordinary in the logs. I can provide them if requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: implicit-hiemulti-componentIssues relating to multi-component supporttype: 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