Cabal test in the sandbox

Let's say I have three of my own packages, AB and C, with dependencies on many additional packages in Hackage. I am using cabal 1.18.

  • C depends on A and B.
  • B depends on A.
  • A and B have test suites.

I installed the sandbox as follows:

cd /path/to/sandbox cabal sandbox init cabal sandbox add-source /path/to/A cabal sandbox add-source /path/to/B cabal sandbox add-source /path/to/C 

I want to create all the packages, run all the test packages on my packages, but not the dependency packages, showing the full test result. What is the best way to do this?

Option 1

 cd /path/to/sandbox cabal install --enable-tests ABC 

Problems:

  • Unable to pass --show-details=always to cabal install .
  • Test output is hidden in the log file and is not displayed.
  • If the user previously performed cabal install A , A will not be restored and tests will not run.

Option 2

 cd /path/to/A cabal sandbox init --sandbox=/path/to/sandbox/.cabal-sandbox cd /path/to/B cabal sandbox init --sandbox=/path/to/sandbox/.cabal-sandbox cd /path/to/A cabal configure --enable-tests cabal test --show-details=always cd /path/to/B cabal configure --enable-tests cabal test --show-details=always cabal install C 

Problems:

  • This leads to the need for excessive restructuring of libraries A and B.

Option 3

In the cabal.config sandbox cabal.config add the string tests: True .

Problems:

  • This will cause the tests to run for all dependent packages from Hackage, which is very slow and in some cases fails.
+6
source share
1 answer

Cabal really lacks functionality. My plan is to generalize cabal so that it has less (or not at all) the concept of a "current package." Now, many commands assume that you are in a directory with a .cabal file, and you want to do something in this package. This is less common for large projects with multiple packages, as you have seen.

I want cabal to take a list of goals for most commands like build , test , bench , etc. You can run tests from multiple packages on

 cabal test --show-details=always \ pkg-dir1:some-test1 pkg-dir1:some-test2 pkg-dir2 

(The above example shows that it should be possible to specify only some sections of the package.)

I understand that this will not help you now, but at least you know in which direction we are moving.

+8
source

Source: https://habr.com/ru/post/973746/


All Articles