Skip to content

cabal test sees the executable, but cabal run does not. #8391

@kindaro

Description

@kindaro

There is a package called fourmolu that is going to be my example here. The relevant issue is fourmolu/fourmolu#231. The appropriate commit is 12af899611cea08c5d9a1f547d432edfbce38be4 — the current main.

See for yourself:

  1. Remove all instances of fourmolu on the path. You should have this:

    % where fourmolu
    fourmolu not found
    
  2. See that the tests pass:

    % cabal test
    Build profile: -w ghc-8.10.7 -O1
    In order, the following will be built (use -v for more details):
     - fourmolu-0.8.1.0 (test:fixity-tests) (ephemeral targets)
     - fourmolu-0.8.1.0 (test:region-tests) (ephemeral targets)
     - fourmolu-0.8.1.0 (test:tests) (ephemeral targets)
    Preprocessing test suite 'fixity-tests' for fourmolu-0.8.1.0..
    Building test suite 'fixity-tests' for fourmolu-0.8.1.0..
    Preprocessing test suite 'region-tests' for fourmolu-0.8.1.0..
    Building test suite 'region-tests' for fourmolu-0.8.1.0..
    Preprocessing test suite 'tests' for fourmolu-0.8.1.0..
    Building test suite 'tests' for fourmolu-0.8.1.0..
    Running 1 test suites...
    Running 1 test suites...
    Test suite region-tests: RUNNING...
    Test suite fixity-tests: RUNNING...
    Test suite region-tests: PASS
    Test suite logged to:
    /home/kindaro/projects/haskell/fourmolu/dist-newstyle/build/x86_64-linux/ghc-8.10.7/fourmolu-0.8.1.0/t/region-tests/test/fourmolu-0.8.1.0-region-tests.log
    1 of 1 test suites (1 of 1 test cases) passed.
    Test suite fixity-tests: PASS
    Test suite logged to:
    /home/kindaro/projects/haskell/fourmolu/dist-newstyle/build/x86_64-linux/ghc-8.10.7/fourmolu-0.8.1.0/t/fixity-tests/test/fourmolu-0.8.1.0-fixity-tests.log
    1 of 1 test suites (1 of 1 test cases) passed.
    Running 1 test suites...
    Test suite tests: RUNNING...
    Test suite tests: PASS
    Test suite logged to:
    /home/kindaro/projects/haskell/fourmolu/dist-newstyle/build/x86_64-linux/ghc-8.10.7/fourmolu-0.8.1.0/t/tests/test/fourmolu-0.8.1.0-tests.log
    1 of 1 test suites (1 of 1 test cases) passed.
    
  3. See that the tests fail if run with cabal run:

    % grep 'test-suite' fourmolu.cabal | cut -d ' ' -f 2 | while read name; do cabal run test:"$name"; done
    Build profile: -w ghc-8.10.7 -O1
    In order, the following will be built (use -v for more details):
     - fourmolu-0.8.1.0 (test:tests) (additional components to build)
    Preprocessing test suite 'tests' for fourmolu-0.8.1.0..
    Building test suite 'tests' for fourmolu-0.8.1.0..
    …
    Finished in 4.1124 seconds
    985 examples, 1 failure, 2 pending
    Build profile: -w ghc-8.10.7 -O1
    In order, the following will be built (use -v for more details):
     - fourmolu-0.8.1.0 (test:region-tests) (additional components to build)
    Preprocessing test suite 'region-tests' for fourmolu-0.8.1.0..
    Building test suite 'region-tests' for fourmolu-0.8.1.0..
    …
    Finished in 0.0011 seconds
    8 examples, 1 failure, 7 pending
    Build profile: -w ghc-8.10.7 -O1
    In order, the following will be built (use -v for more details):
     - fourmolu-0.8.1.0 (test:fixity-tests) (additional components to build)
    Preprocessing test suite 'fixity-tests' for fourmolu-0.8.1.0..
    Building test suite 'fixity-tests' for fourmolu-0.8.1.0..
    …
    Finished in 0.0015 seconds
    6 examples, 1 failure, 5 pending
    
  4. See that the tests pass if run with cabal run after cabal install:

    % cabal install
    …
    Symlinking 'fourmolu' to '/home/kindaro/.cabal/bin/fourmolu'
    % grep 'test-suite' fourmolu.cabal | cut -d ' ' -f 2 | while read name; do cabal run test:"$name"; done
    Resolving dependencies...
    Up to date
    …
    Finished in 6.4715 seconds
    985 examples, 0 failures
    Up to date
    …
    Finished in 0.3642 seconds
    8 examples, 0 failures
    Up to date
    …
    Finished in 0.7731 seconds
    6 examples, 0 failures
    

Expected:

Either the tests fail, or the tests pass. It does not matter which way I run them. In particular, Cabal makes the same executables available in the same way: either the fourmolu executable is made available to both cabal run and cabal test or to neither.

Actual:

The executable fourmolu is made available to the test programs when they are run with cabal test but not with cabal run.

System information:

% uname --all
Linux kindrom-silverheart 5.18.13-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 22 Jul 2022 13:05:04 +0000 x86_64 GNU/Linux
% cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library 
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions