Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Source in subdirectory of git repository #27

Closed
xaviershay opened this Issue · 7 comments

2 participants

Xavier Shay Greg Weber
Xavier Shay

I am trying to use a custom version of test-framework that supports QuickCheck 2.6.

batterseapower/test-framework#50
https://github.com/yairchu/test-framework

My sources.txt is:

https://github.com/yairchu/test-framework.git

I have run into two problems running `cabal-meta --dev install:

  1. Exception: vendor/test-framework/sources.txt: openBinaryFile: does not exist (No such file or directory). It's true, that file doesn't exist, and I wouldn't expect it to for the vast majority of packages. I tried just creating this file with a single entry of ./ to see if it would continue past.
  2. cabal: No cabal file found.. This file is inside the core subdirectory of test-framework. Is this supported at all? Can you point me in the right direction in the code to submit a patch?

I'm very new to haskell, so apologies if I have things all mixed up. (I'm familiar with bundler though, if that helps at all.)

Thanks!
Xavier

Xavier Shay

Ah, so if I add the following to sources.txt it looks in the subdirectory:

./core

Is the suggested approach to fork test-framework and add a sources.txt, or can I provide it in my own source tree somehow?

Xavier Shay

cabal-meta --dev install doesn't seem to install any of the required deps specified in my .cabal file, but then neither does cabal-dev install or cabal install. I'm guessing this isn't the equivalent of bundle install, but then I can't find the right command, nor the right search term to find others with this problem. I can just install the deps by hand and everything works, but that seems kind of stupid. cabal-dev install-deps says everything is already installed.

I feel like I'm straying into "not cabal-meta's problem territory"... Any assistance or pointers to docs welcome.

Xavier Shay

Ok, I have some tests running. My current understanding is that sources.txt is equivalent to a Gemfile, and myapp.cabal is equivalent to myapp.gemspec. The problem is cabal-meta doesn't have a directive equivalent to bundler's gemspec that says "load all deps from myapp.cabal". As such, I've duplicated my dependencies.

-- sources.txt
./
https://github.com/yairchu/test-framework.git
QuickCheck
test-framework-th
-- vendor/test-framework/sources.txt
./core
./hunit
./quickcheck2
-- hsdeps.cabal
Name:                hsdeps
Version:             0.0
Description:         TODO
Author:              Xavier Shay
Build-Type:          Simple
Cabal-Version:       >=1.2

Test-Suite hunit
  type: exitcode-stdio-1.0
  main-is: hunit.hs
  hs-source-dirs: src
  build-depends:   base
                 , containers
                 , test-framework
                 , test-framework-th
                 , test-framework-hunit
                 , test-framework-quickcheck2
                 , QuickCheck == 2.6
                 , HUnit

Executable hsdeps
  Main-is:           Main.hs
  Build-Depends:     base
  hs-source-dirs:    src

I still have to place the test-framework sources file by keeping my own fork.

Now, cabal-dev build and cabal-dev test work as expected.

So in summary the questions I have:

  1. Are my assertions above correct? (Ignore if you don't know Ruby/bundler)
  2. Do I have to duplicate my dependencies? Is this how you would set this up?
  3. Is keeping my own test-framework fork the recommended approach?
Greg Weber
Owner

Can you download the latest version of cabal and use the sandbox features and stop using cabal-dev? cabal-meta will probably drop cabal-dev support soon.

In a hurry now, will look at the rest soon.

Greg Weber
Owner

I should make some of the error messages nicer, but it looks like you figured out how to use cabal-meta :)

Analogies with Bundler are dificult to make. sources.txt only helps enhance/override the .cabal file, it can act like a Gemfile to the extent that you use it to specify more exact (sometimes github) versions, but it does not peg everything the way the Gemfile system does. The .cabal file is a gemspec for a Library section of a .cabal file, and an Executable section can be considered a Gemfile without a Gemfile.lock.

The ./ should effectively source your .cabal file, so you shouldn't need QuickCheck & test-framework-th there.

You are using a Test-Suite section, so you need to give --enable-tests to cabal.

cabal-meta --dev install --enable-tests

You can build the tests individually with the latest version of cabal by typing cabal build hunit.
If you find it more convenient you can also use the cabal-sandbox add-source feature rather than cabal-meta, there are trade-offs between the 2 approaches.

Xavier Shay

thanks for the explanation! I'll try out sandbox.

Xavier Shay

Got sandbox working, I also needed this: cabal install --only-dependencies --enable-test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.