Repository navigation
Closed
Description
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
[-]Sandboxed install artifacts do not satisfy test[/-][+]Sandboxed 'install' artifacts do not satisfy 'test'[/+]ttuegel commentedon Sep 13, 2014
The error you get from
cabal test --builddir=dist/dist-sandbox-64792e4fis caused bycabal installandcabal testdetecting 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 testshould know when it's run in a sandbox.mietek commentedon Sep 14, 2014
@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.
ttuegel commentedon Sep 14, 2014
No, I can reproduce this. What I'm saying is there are two separate issues here. The first is the same as #1938;
cabal installandcabal testuse different versions ofCabal. This is separate from the issue thatcabal testdoesn't know to look for the sandbox.jonsterling commentedon Mar 20, 2015
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?
ezyang commentedon Aug 16, 2016
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!)
23Skidoo commentedon Aug 16, 2016
Like everything tagged with
sandbox, I guess.mietek commentedon Feb 14, 2019
My
foobarrepository is now namedcabal-issue-1953.mietek commentedon Jun 7, 2019
Closing as obsolete.