bitc / hdevtools

REPO UNMAINTAINED!!! Try this: https://github.com/hdevtools/hdevtools/
MIT License
171 stars 42 forks source link

hdevtools does not pick up test dependencies #38

Open sol opened 9 years ago

sol commented 9 years ago

(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 commented 9 years ago

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

sol commented 9 years ago

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

sol commented 9 years ago

^ @schell sorry, wrong mention...

schell commented 9 years ago

@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 commented 9 years ago

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

schell commented 9 years ago

@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 commented 9 years ago

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 commented 9 years ago

This patch should fix that: https://github.com/maximkulkin/hdevtools/commit/4806bd9d152261bf3c71673af2647bd75288040f

Just pass extra argument to hdevtools:

hdevtools check --cabalopts "--enable-tests" MyFile.hs
maximkulkin commented 9 years ago

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 commented 9 years ago

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

jsantos17 commented 9 years ago

@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 commented 9 years ago

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

schell commented 9 years ago

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

davidpdrsn commented 9 years ago

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

hatashiro commented 8 years ago

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

emptyflask commented 8 years ago

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 commented 8 years ago

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

2chilled commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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