Skip to content

Sandboxed 'install' artifacts do not satisfy 'test' #1953

Closed

Description

@mietek

Build artifacts generated by cabal install --enable-tests should be enough to run cabal test without having to build anything again, whether we're using a sandbox or not.

Currently, cabal install generates build artifacts in dist/dist-sandbox-$HASH, while cabal test expects build artifacts in dist:

$ cabal sandbox init
Writing a default package environment file to
/private/tmp/tmp/foobar/cabal.sandbox.config
Creating a new sandbox at /private/tmp/tmp/foobar/.cabal-sandbox

$ cabal install --enable-tests
Resolving dependencies...
Notice: installing into a sandbox located at
/private/tmp/tmp/foobar/.cabal-sandbox
Configuring foobar-0.1...
Building foobar-0.1...
Installed foobar-0.1

$ ls dist
dist-sandbox-64792e4f

$ cabal test
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring foobar-0.1...
Building foobar-0.1...
Preprocessing library foobar-0.1...
[1 of 1] Compiling Foobar           ( src/lib/Foobar.hs, dist/build/Foobar.o )
In-place registering foobar-0.1...
Preprocessing executable 'foobar' for foobar-0.1...
[1 of 1] Compiling Main             ( src/main.hs, dist/build/foobar/foobar-tmp/Main.o )
Linking dist/build/foobar/foobar ...
Preprocessing test suite 'test-foobar' for foobar-0.1...
[1 of 1] Compiling Main             ( test/main.hs, dist/build/test-foobar/test-foobar-tmp/Main.o )
Linking dist/build/test-foobar/test-foobar ...
Running 1 test suites...
Test suite test-foobar: RUNNING...
Test suite test-foobar: FAIL
Test suite logged to: dist/test/foobar-0.1-test-foobar.log
0 of 1 test suites (0 of 1 test cases) passed.

$ ls dist
build
dist-sandbox-64792e4f
hpc
package.conf.inplace
setup-config
test

Additionally, the build artifacts generated by cabal install seem to be incompatible with what cabal test expects, as shown by the following (very confused) message:

$ cabal test --builddir=dist/dist-sandbox-64792e4f
cabal: You need to re-run the 'configure' command. The version of Cabal being
used has changed (was Cabal-1.18.1.3, now Cabal-1.20.0.0). Additionally the
compiler is different (was ghc-7.8, now ghc-7.6) which is probably the cause
of the problem.

A viable workaround is never using cabal install, but either cabal install --dependencies-only && cabal configure && cabal test, or cabal install --run-tests.

Activity

  1. changed the title [-]Sandboxed install artifacts do not satisfy test[/-] [+]Sandboxed 'install' artifacts do not satisfy 'test'[/+] on Jun 26, 2014
  2. ttuegel commented on Sep 13, 2014

    @ttuegel
    Member

    The error you get from cabal test --builddir=dist/dist-sandbox-64792e4f is caused by cabal install and cabal test detecting different GHC/Cabal versions in the sandbox. I'm not sure why this happens to you, but otherwise the build artifacts in the sandbox build dir would be compatible. In either case, cabal test should know when it's run in a sandbox.

  3. self-assigned this
    on Sep 13, 2014
  4. mietek commented on Sep 14, 2014

    @mietek
    ContributorAuthor

    @ttuegel, you should be able to reproduce the error using my foobar testcase. I've just retested it with GHC 7.8.3 and cabal-install 1.20.0.3. Output attached.

  5. ttuegel commented on Sep 14, 2014

    @ttuegel
    Member

    No, I can reproduce this. What I'm saying is there are two separate issues here. The first is the same as #1938; cabal install and cabal test use different versions of Cabal. This is separate from the issue that cabal test doesn't know to look for the sandbox.

  6. jonsterling commented on Mar 20, 2015

    @jonsterling

    This is a very serious bug and periodically causes me to lose hours of work. I would like to just stick my 👍 on here for any efforts to get it fixed. Thanks!

    In the meanwhile, does anyone know of a hack I can use to get around this?

  7. added this to the milestone on Apr 24, 2015
  8. modified the milestones: cabal-install 1.24, on Feb 21, 2016
  9. modified the milestones: , cabal-install 2.0 on Aug 16, 2016
  10. ezyang commented on Aug 16, 2016

    @ezyang
    Contributor

    So, I think this bug will be obsoleted by nix-local-build, when it comes online? Not going to close because I guess this is still a real bug. (But if you're affected, try nix-local-build!)

  11. 23Skidoo commented on Aug 16, 2016

    @23Skidoo
    Member

    So, I think this bug will be obsoleted by nix-local-build, when it comes online?

    Like everything tagged with sandbox, I guess.

  12. mietek commented on Feb 14, 2019

    @mietek
    ContributorAuthor

    My foobar repository is now named cabal-issue-1953.

  13. mietek commented on Jun 7, 2019

    @mietek
    ContributorAuthor

    Closing as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions