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

"Up to date" after changing a test dependency #5547

Closed
tom-bop opened this issue Aug 24, 2018 · 4 comments
Closed

"Up to date" after changing a test dependency #5547

tom-bop opened this issue Aug 24, 2018 · 4 comments

Comments

@tom-bop
Copy link

tom-bop commented Aug 24, 2018

Apologies if this is fixed in a newer version of cabal!

 $ cabal --version
cabal-install version 1.24.0.2
compiled using version 1.24.2.0 of the Cabal library

Starting with the misbehavior:

 $ cabal new-build test:foo-tests
[...]
 $ echo 'shouldnt work!' > test/TestHelper.hs
 $ cabal new-build test:foo-tests
Up to date

test/Test.hs

import Lib
import TestHelper

main = do
   print $ x == f 5

src/Lib.hs:

module Lib where

x = 7

test/TestHelper.hs:

module TestHelper where

f :: Integer -> Integer
f = (+2)

foo.cabal:

name:               foo
version:             0.1.0.0
build-type:          Simple
cabal-version:       >=1.10

Test-suite foo-tests
  main-is: Test.hs
  type: exitcode-stdio-1.0
  default-language: Haskell2010
  build-depends:
      base
    , foo
  hs-source-dirs:      test, src

library
  exposed-modules:
      Lib
  build-depends:
      base
  hs-source-dirs:      src
  default-language:    Haskell2010
@quasicomputational
Copy link
Contributor

I think that you're seeing this because you're not passing --enable-tests. I agree that this is silly behaviour (you've explicitly asked for the test to be built and so it should be built), but at least it's predictable silly behaviour (tests are never built without --enable-tests). #3923 and #5079 are related but I don't think they're exactly the same; hopefully they can all be fixed at once.

@tom-bop
Copy link
Author

tom-bop commented Aug 24, 2018

That seems... strange!

The test:foo-tests is built - I can run ./dist-newstyle/build/foo-0.1.0.0/build/foo-tests/foo-tests.

@hvr
Copy link
Member

hvr commented Aug 24, 2018

@tom-bop generally, cabal 1.24 was the very first tech-preview of nix-style new-build which was very rought; I'd highly recommend to try using a newer cabal version; is there any particular reason you're still using cabal 1.24?

@hvr
Copy link
Member

hvr commented Oct 24, 2018

Btw, turns out this is a totally different issue; doing this with a more recent GHC version exposes the cause:

$ cabal new-build test:foo-tests
Build profile: -w ghc-8.4.4 -O1
In order, the following will be built (use -v for more details):
 - foo-0.1.0.0 (test:foo-tests) (first run)
Preprocessing test suite 'foo-tests' for foo-0.1.0.0..
Building test suite 'foo-tests' for foo-0.1.0.0..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: Lib
                                                                                                 TestHelper
[1 of 3] Compiling Lib              ( src/Lib.hs, /tmp/XXX/dist-newstyle/build/x86_64-linux/ghc-8.4.4/foo-0.1.0.0/t/foo-tests/build/foo-tests/foo-tests-tmp/Lib.o )
[2 of 3] Compiling TestHelper       ( test/TestHelper.hs, /tmp/XXX/dist-newstyle/build/x86_64-linux/ghc-8.4.4/foo-0.1.0.0/t/foo-tests/build/foo-tests/foo-tests-tmp/TestHelper.o )
[3 of 3] Compiling Main             ( test/Test.hs, /tmp/XXX/dist-newstyle/build/x86_64-linux/ghc-8.4.4/foo-0.1.0.0/t/foo-tests/build/foo-tests/foo-tests-tmp/Main.o )

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: Lib
                                                                                                 TestHelper
Linking /tmp/XXX/dist-newstyle/build/x86_64-linux/ghc-8.4.4/foo-0.1.0.0/t/foo-tests/build/foo-tests/foo-tests ...

specifically the warning about not having accurately specified the modules in other-modules; thus cabal's file tracking logic had no clue that the test:foo-tests target became dirty!

@hvr hvr closed this as completed Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants