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

Mention possible need to put library itself in test-suite's build-depends to avoid a bug? #5

Closed
RyanGlScott opened this issue Feb 4, 2017 · 1 comment

Comments

@RyanGlScott
Copy link
Collaborator

I tripped over this when upgrading bits to use cabal-doctest. If I uses the following build-depends in the doctests test-suite:

    build-depends:
      base,
      doctest >= 0.11.1 && < 0.12

Then cabal test fails!

$ cabal configure --enable-tests
Resolving dependencies...
[1 of 1] Compiling Main             ( dist/setup/setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring bits-0.5...
$ cabal test
Preprocessing test suite 'doctests' for bits-0.5...
[1 of 2] Compiling Build_doctests   ( dist/build/autogen/Build_doctests.hs, dist/build/doctests/doctests-tmp/Build_doctests.o )
[2 of 2] Compiling Main             ( tests/doctests.hs, dist/build/doctests/doctests-tmp/Main.o )
Linking dist/build/doctests/doctests ...
Running 1 test suites...
Test suite doctests: RUNNING...
### Failure in /home/rgscott/Documents/Hacking/Haskell/bits/src/Data/Bits/Coded.hs:37: expression `runPutL . runEncode $ encode (Unary 1) >> flush'
expected: "\128"
 but got: 
          ByteCodeLink: can't find label
          During interactive linking, GHCi couldn't find the following symbol:
            debruijn_lsb64
          This may be due to you not asking GHCi to load extra object files,
          archives or DLLs needed by your current session.  Restart GHCi, specifying
          the missing library using the -L/path/to/object/dir and -lmissinglibname
          flags, or simply by naming the relevant files on the GHCi command line.
          Alternatively, this link failure might indicate a bug in GHCi.
          If you suspect the latter, please send a bug report to:
            glasgow-haskell-bugs@haskell.org
          
Examples: 2  Tried: 1  Errors: 0  Failures: 1
-i/home/rgscott/Documents/Hacking/Haskell/bits/dist/build/autogen
-i/home/rgscott/Documents/Hacking/Haskell/bits/src
-hide-all-packages
-package-db=dist/package.conf.inplace
-optP-include
-optPdist/build/autogen/cabal_macros.h
-package-id=base-4.9.1.0
-package-id=bytes-0.15.2-D9QILzOcmbYG6aOpzK9Wp5
-package-id=mtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6
-package-id=transformers-0.5.2.0
-package-id=doctest-0.11.1-A85NJCxz1CxFJY7u28Ku7R
Data.Bits.Coding
Data.Bits.Coded
Data.Bits.Extras
Test suite doctests: FAIL
Test suite logged to: dist/test/bits-0.5-doctests.log
0 of 1 test suites (0 of 1 test cases) passed.

That's because cabal hadn't compiled debruijn.c (which defines debruijn_lsb64) into an object file! It turns out that bytes (another library like bits which has a C dependency) doesn't suffer from this issue because the doctests test-suite adds a dependency on the bytes library. Or, to use the earlier example of bits, if you change the build-depends in the doctests test-suite to this:

    build-depends:
      base,
      bits,
      doctest >= 0.11.1 && < 0.12

Then cabal test works without issue, because the library dependency forces cabal to build the library (and therefore debruijn.c) beforehand:

rgscott@gearloose:~/.../Hacking/Haskell/bits$ cabal configure --enable-tests
Resolving dependencies...
[1 of 1] Compiling Main             ( dist/setup/setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring bits-0.5...
rgscott@gearloose:~/.../Hacking/Haskell/bits$ cabal test
Preprocessing library bits-0.5...
[1 of 3] Compiling Data.Bits.Extras ( src/Data/Bits/Extras.hs, dist/build/Data/Bits/Extras.o )
[2 of 3] Compiling Data.Bits.Coding ( src/Data/Bits/Coding.hs, dist/build/Data/Bits/Coding.o )
[3 of 3] Compiling Data.Bits.Coded  ( src/Data/Bits/Coded.hs, dist/build/Data/Bits/Coded.o )
Preprocessing test suite 'doctests' for bits-0.5...
[1 of 2] Compiling Build_doctests   ( dist/build/autogen/Build_doctests.hs, dist/build/doctests/doctests-tmp/Build_doctests.o )
[2 of 2] Compiling Main             ( tests/doctests.hs, dist/build/doctests/doctests-tmp/Main.o )
Linking dist/build/doctests/doctests ...
Running 1 test suites...
Test suite doctests: RUNNING...
Test suite doctests: PASS
Test suite logged to: dist/test/bits-0.5-doctests.log
1 of 1 test suites (1 of 1 test cases) passed.

Perhaps we should mention this gotcha in the cabal-doctest README?

RyanGlScott added a commit to ekmett/bits that referenced this issue Feb 4, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`, making it
compatible with `Cabal-1.25` (shipped with GHC 8.2). See
ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite to avoid
ulidtko/cabal-doctest#5
@phadej
Copy link
Collaborator

phadej commented Feb 4, 2017

We should. Have to investigate whether this is Cabal/ghc bug of feature (it's not obvious to me how cbits work with ghci).

@phadej phadej closed this as completed Feb 5, 2017
phadej added a commit to phadej/bound that referenced this issue Feb 6, 2017
compatible with `Cabal-1.25` (shipped with GHC 8.2). See
ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite to
avoid
ulidtko/cabal-doctest#5

Also lifts directory upper bound
phadej added a commit to phadej/ad that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/approximate that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/ersatz that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/folds that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/gc that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/heaps that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/hyperloglog that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/hyphenation that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/lens-action that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/parsers that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/structs that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
phadej added a commit to phadej/hashable-extras that referenced this issue Feb 6, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
RyanGlScott pushed a commit to ekmett/gc that referenced this issue Apr 27, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
RyanGlScott pushed a commit to ekmett/folds that referenced this issue Apr 27, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
RyanGlScott pushed a commit to ekmett/hyphenation that referenced this issue Apr 27, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
RyanGlScott pushed a commit to ekmett/heaps that referenced this issue Apr 27, 2017
This upgrades the `Setup.hs` harness to use `cabal-doctest`,
making it compatible with `Cabal-1.25` (shipped with GHC 8.2).
See ekmett/lens#709

Make sure to add a dependency on bits in the doctests test-suite
to avoid ulidtko/cabal-doctest#5
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

2 participants