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

hdevtools does not pick up test dependencies #38

Open
sol opened this issue Dec 30, 2014 · 20 comments
Open

hdevtools does not pick up test dependencies #38

sol opened this issue Dec 30, 2014 · 20 comments

Comments

@sol
Copy link

sol commented Dec 30, 2014

(this is a bug report / feature request against master of https://github.com/schell/hdevtools /cc @schell)

Currently, hdevtools does not pick up test dependencies. Here is a minimal way to reproduce this:

$ git clone https://github.com/hspec/hspec-example
$ cd hspec-example/
$ cabal install --only-dependencies --enable-tests                                                 
$ hdevtools check src/Data/String/Strip.hs 
$ hdevtools check test/Data/String/StripSpec.hs                                                 
/home/sol/sandbox/haskell/hspec-example/test/Data/String/StripSpec.hs:3:8:
    Could not find module ‘Test.Hspec’
    It is a member of the hidden package ‘hspec-2.1.2’.
    Perhaps you need to add ‘hspec’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.
@schell
Copy link

schell commented Dec 30, 2014

Thanks 😄 I'll see what I can do. If you figure it out please submit a pull request 😊

@sol
Copy link
Author

sol commented Jan 5, 2015

@shell could we just not look at the cabal file at all and use cabal exec for sandbox support?

@sol
Copy link
Author

sol commented Jan 7, 2015

^ @schell sorry, wrong mention...

@schell
Copy link

schell commented Jan 7, 2015

@sol There's already some other tickets regarding sandbox support, so dropping the current implementation would affect that work as well. I'm guessing that the easiest way to fix this is to add support for test dependencies by parsing the cabal file. @maximkulkin - do you have any input?

@jsantos17
Copy link

@schell Do you have any other input on where newcomers to hdevtools' source can start looking to implement this functionality?

@schell
Copy link

schell commented Feb 11, 2015

@jsantos17 - you can take a look at the work that @maximkulkin has done with regard to cabal sandboxes (https://github.com/schell/hdevtools/commits/master @maximkulkin's changes from Feb 15th 2014 - March 16th 2014). My guess is that hdevtools is only looking at the executable named after the cabal project and not other executables as well.

@maximkulkin
Copy link

I guess the problem is in this line https://github.com/schell/hdevtools/blob/master/src/Cabal.hs#L119: you need to pass --enable-tests option in cfgFlags (along with any other standard or custom options that you have in *.cabal file).

@maximkulkin
Copy link

This patch should fix that: maximkulkin@4806bd9

Just pass extra argument to hdevtools:

hdevtools check --cabalopts "--enable-tests" MyFile.hs

@maximkulkin
Copy link

There still could be situations when this approach won't work. Currently hdevtools merges all options from all enabled artefacts in Cabal file. It could possible be situation when two artefacts have conflicting dependencies. Then, the right thing to do is to figure out for given file which artefact it belongs to. To do that, it is needed to take an artefact root modules (either exposed modules for library artefact, main module for executable artefact, etc) and try traverse all dependencies from current package. Then find which artefact current module/file belongs to and load corresponding artefacts ghc options.

This is too much work and IMO could be rarely seen to invest in implementing that.

@jsantos17
Copy link

@maximkulkin I'll give it a whirl! Thanks!

@jsantos17
Copy link

@maximkulkin works great. Thank you very much. You just saved me a few hours of my life! I cherry picked your commit on top of Schell's fork. My own fork: https://github.com/jsantos17/hdevtools

@davidpdrsn
Copy link

Any news on this issue? I'm currently running into the problem.

@schell
Copy link

schell commented Oct 28, 2015

@davidpdrsn - @maximkulkin's changes are merged into my fork. Please tell me if that fixes your issue.

@davidpdrsn
Copy link

@schell how can I do that? I'm that experienced with cabal.

@hatashiro
Copy link

Suffering from the same issue here. Any update on the upstream?

@emptyflask
Copy link

Same problem. I'm running haskell via stack. Also, the suggested -v flag doesn't work.

$ hdevtools check list-ops_test.hs
/Users/jon/exercism/haskell/list-ops/list-ops_test.hs:3:8:
    Could not find module ‘Test.HUnit’
    Use -v to see a list of the files searched for.

$ hdevtools check -v list-ops_test.hs
Unknown flag: -v

@maximkulkin
Copy link

The message you see is from GHC itself, so in order to use "-v" flag you need to pass it via --ghcopts "-v"

@2chilled
Copy link

2chilled commented Jan 9, 2016

Problem still not fixed upstream. @schell : your fork works well for me. For the nix users like myself:

{ mkDerivation, base, bin-package-db, Cabal, cmdargs, directory
, filepath, ghc, ghc-paths, network, process, syb, time, unix, fetchFromGitHub
, stdenv
}:
mkDerivation {
  pname = "hdevtools";
  version = "0.1.2.1";
  src = fetchFromGitHub {
    owner = "schell";
    repo = "hdevtools";
    rev = "d331b7f5d98591ffceaa8306d3205b647466d25a";
    sha256 = "06qg2xg40jc77gn7ms8h9xscja3v69paa6yb54iz1pc92l19r180";
  };
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = [
    base bin-package-db Cabal cmdargs directory filepath ghc ghc-paths
    network process syb time unix
  ];
  homepage = "https://github.com/bitc/hdevtools/";
  description = "Persistent GHC powered background server for FAST haskell development tools";
  license = stdenv.lib.licenses.mit;
}

@maximkulkin
Copy link

@2chilled Yes, the original author seems like have abandoned the project and you are left with option to install it from alternative repositories like @schell

@schell
Copy link

schell commented Jan 14, 2016

@2chilled and @maximkulkin, there's a new effort at https://github.com/hdevtools/hdevtools.

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

No branches or pull requests

8 participants