Skip to content

Fix BuildTestSuiteDetailedV09 on GHC <7.6#1297

Merged
ttuegel merged 2 commits into
haskell:masterfrom
ttuegel:test-inplace-lib
Apr 29, 2013
Merged

Fix BuildTestSuiteDetailedV09 on GHC <7.6#1297
ttuegel merged 2 commits into
haskell:masterfrom
ttuegel:test-inplace-lib

Conversation

@ttuegel

@ttuegel ttuegel commented Apr 28, 2013

Copy link
Copy Markdown
Member

This commit fixes the new test case so that it is always built with the in-place version of Cabal. The problem was that the test package itself depends on Cabal, so build would fail with a sufficiently old version of Cabal installed. No other package tests currently do this, but I tried to make it easy to extend this behavior in case another package test needs to in the future.

@23Skidoo

Copy link
Copy Markdown
Member

No other package tests currently do this

Does this mean that they actually test the system version of Cabal?

@ttuegel

ttuegel commented Apr 28, 2013

Copy link
Copy Markdown
Member Author

@23Skidoo No, all the other tests correctly test the in-place Cabal. There are two places that the system Cabal can accidentally get involved: when Setup.hs is compiled, and when the PackageTest package is compiled. The former problem was solved some time ago. The latter is only a problem if the PackageTest package depends on Cabal. All detailed-0.9 type test suites must depend on Cabal; the problem here was that BuildTestSuiteDetailedV09 defined such a test suite. None of the other tests define packages depending on Cabal, so they were all fine, but if someone needs to add another such test in the future, they should be aware of this.

@23Skidoo

Copy link
Copy Markdown
Member

@ttuegel Can you please put this info in, say, tests/README?

@ttuegel

ttuegel commented Apr 29, 2013

Copy link
Copy Markdown
Member Author

@23Skidoo @tibbe If this added documentation is satisfactory, please commit. Sorry for the mistake!

@tibbe

tibbe commented Apr 29, 2013

Copy link
Copy Markdown
Member

You have commit access. Go ahead and commit.

ttuegel added a commit that referenced this pull request Apr 29, 2013
Fix BuildTestSuiteDetailedV09 on GHC <7.6
@ttuegel ttuegel merged commit 62b671f into haskell:master Apr 29, 2013
@idontgetoutmuch

Copy link
Copy Markdown
Member
cd tests/Distribution/Compat/
hsc2hs CreatePipe.hsc
ghc PackageTests.hs -o MyTest -package-db=../dist/package.conf.inplace

Dominics-MacBook-Pro:Cabal dom$ tests/MyTest -t BuildTestSuiteDetailedV09
Cabal test suite - testing cabal version 1.17.0
BuildTestSuiteDetailedV09:
: [Failed]
build failed!
expected: False
but got: True

I will investigate further.

@idontgetoutmuch

Copy link
Copy Markdown
Member

It seems to be somehow caused by this:

 module PackageTests.BuildTestSuiteDetailedV09.Check where

 import Test.HUnit
 import System.FilePath ((</>))

 import PackageTests.PackageTester

 suite :: PackageSpec -> Test
 suite inplaceSpec = TestCase $ do
     let dir = "PackageTests" </> "BuildTestSuiteDetailedV09"
         spec = inplaceSpec
             { directory = dir
             , configOpts = "--enable-tests" : configOpts inplaceSpec
             }
     confResult <- cabal_configure spec
     assertEqual "configure failed!" (successful confResult) True
     buildResult <- cabal_build spec
     assertEqual "build failed!" (successful buildResult) True

If I collect some debug info from: PackageTester.hs

 doCabalBuild :: PackageSpec -> IO Result
 doCabalBuild spec = do
     configResult <- doCabalConfigure spec
     if successful configResult
         then do
             res <- cabal spec ["build", "-v"]
             putStrLn $ show $ configOpts spec
             putStrLn $ show res
             return $ recordRun res BuildSuccess configResult
         else
             return configResult

I can see this command being executed:

'/usr/local/bin/ghc' '--make' '-fbuilding-cabal-package' '-O' \
'-static' '-odir' 'dist/build' '-hidir' 'dist/build' '-stubdir' \
'dist/build' '-i' '-idist/build' '-i.' '-idist/build/autogen' \
'-Idist/build/autogen' '-Idist/build' '-optP-include' \
'-optPdist/build/autogen/cabal_macros.h' '-package-name' \
'dummy-0.1' '-hide-all-packages' \
'-package-db' \
'/Users/dom/Dropbox/Private/cabal/Cabal/dist/package.conf.inplace' \
'-package-db' \
'dist/package.conf.inplace' \
'-package-id' 'Cabal-1.17.0-inplace' \
'-package-id' 'base-4.6.0.1-2514ecbfe6573e639515d3e91d6e1f29' \
'-XHaskell98' 'Dummy'

For some reason there are two package-dbs and one of them refers to a relative path. Given we are in

"PackageTests" </> "BuildTestSuiteDetailedV09"

then there is no package-db in dist and the command fails. On the other hand, if we remove
'-package-db' 'dist/package.conf.inplace'
then the compilation succeeds.

@23Skidoo

23Skidoo commented May 3, 2013

Copy link
Copy Markdown
Member

@idontgetoutmuch Strange, the test suite passes fine on Johan's build bot: http://ci.johantibell.com/job/cabal/

@ttuegel

ttuegel commented May 3, 2013

Copy link
Copy Markdown
Member Author

You must run the build phase first. The test suite is only designed to test the in-tree version of Cabal being built.

@idontgetoutmuch

Copy link
Copy Markdown
Member

I am not entirely clear what you mean. I first followed the build and test instructions and got test failures (see below). I am now trying to isolate the failure. What is the best way of doing this without having to run all the tests?

bash-3.2$ cabal build
Building Cabal-1.17.0...
Preprocessing library Cabal-1.17.0...
[ 1 of 69] Compiling Paths_Cabal ( dist/build/autogen/Paths_Cabal.hs, dist/build/Paths_Cabal.o )
stribution/Simple/Haddock.p_o )

[69 of 69] Compiling Distribution.Simple ( Distribution/Simple.hs, dist/build/Distribution/Simple.p_o )
In-place registering Cabal-1.17.0...
Preprocessing test suite 'package-tests' for Cabal-1.17.0...
[ 1 of 25] Compiling Distribution.Compat.CreatePipe ( dist/build/package-tests/package-tests-tmp/Distribution/Compat/CreatePipe.hs, dist/build/package-tests/package-tests-tmp/Distribution/Compat/CreatePipe.o )

[25 of 25] Compiling Main ( tests/PackageTests.hs, dist/build/package-tests/package-tests-tmp/Main.o )
Linking dist/build/package-tests/package-tests ...
Preprocessing test suite 'unit-tests' for Cabal-1.17.0...
[1 of 2] Compiling UnitTests.Distribution.Compat.ReadP ( tests/UnitTests/Distribution/Compat/ReadP.hs, dist/build/unit-tests/unit-tests-tmp/UnitTests/Distribution/Compat/ReadP.o )
[2 of 2] Compiling Main ( tests/UnitTests.hs, dist/build/unit-tests/unit-tests-tmp/Main.o )
Linking dist/build/unit-tests/unit-tests ...
bash-3.2$ cabal test
Running 2 test suites...
Test suite package-tests: RUNNING...
Cabal test suite - testing cabal version 1.17.0

BuildTestSuiteDetailedV09:
: [Failed]
build failed!
expected: False
but got: True

BuildDeps/InternalLibrary2:
: [Failed]
executable should have linked with the internal library
expected: "myLibFunc internal"
but got: ""
BuildDeps/InternalLibrary3:
: [Failed]
executable should have linked with the internal library
expected: "myLibFunc internal"
but got: ""
BuildDeps/InternalLibrary4:
: [Failed]
executable should have linked with the installed library
expected: "myLibFunc installed"
but got: ""
PackageTests/CMain:
: [OK]

     Test Cases   Total       

Passed 20 20
Failed 4 4
Total 24 24
Test suite package-tests: FAIL
Test suite logged to: dist/test/Cabal-1.17.0-package-tests.log
Test suite unit-tests: RUNNING...
Test suite unit-tests: PASS
Test suite logged to: dist/test/Cabal-1.17.0-unit-tests.log
1 of 2 test suites (1 of 2 test cases) passed.

On 3 May 2013, at 15:22, Thomas Tuegel notifications@github.com wrote:

You must run the build phase first. The test suite is only designed to test the in-tree version of Cabal being built.


Reply to this email directly or view it on GitHub.

@ttuegel

ttuegel commented May 3, 2013

Copy link
Copy Markdown
Member Author

Sorry, that was unclear from the error you posted. It looked to me like you were trying to build and run the test without building Cabal.

@idontgetoutmuch

Copy link
Copy Markdown
Member

@23Skidoo: Yes the only difference is that I am on a Mac but it will no doubt turn out to be something annoying with my configuration.

@23Skidoo

23Skidoo commented May 3, 2013

Copy link
Copy Markdown
Member

@idontgetoutmuch You can take a look at his build script: https://gist.github.com/tibbe/5470453

@ttuegel

ttuegel commented May 3, 2013

Copy link
Copy Markdown
Member Author

@idontgetoutmuch There should be a PackageTests/BuildTestSuiteDetailedV09/dist/package.conf.inplace because we are building a library-type test suite. Can you post the log file from PackageTests/BuildTestSuiteDetailedV09 ? I want to verify that the test suite's library is being in-place registered.

@idontgetoutmuch

Copy link
Copy Markdown
Member

Here you go. It seems to be creating a package.conf.inplace but still failing.

"/Users/dom/Dropbox/Private/cabal/Cabal/tests/Setup configure --user -w ghc --enable-tests --package-db=/Users/dom/Dropbox/Private/cabal/Cabal/dist/package.conf.inplace --constraint=Cabal == 1.17.0" in PackageTests/BuildTestSuiteDetailedV09
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Configuring BuildTestSuiteDetailedV09-0.1...

"/Users/dom/Dropbox/Private/cabal/Cabal/tests/Setup build -v" in PackageTests/BuildTestSuiteDetailedV09
Component build order: library, test suite 'dummy'
creating dist/build
creating dist/build/autogen
Building BuildTestSuiteDetailedV09-0.1...
Preprocessing library BuildTestSuiteDetailedV09-0.1...
Building library...
'/usr/local/bin/ghc' '--info'
'/usr/local/bin/ghc' '--info'
creating dist/build
'/usr/local/bin/ghc' '--make' '-fbuilding-cabal-package' '-O' '-static' '-odir' 'dist/build' '-hidir' 'dist/build' '-stubdir' 'dist/build' '-i' '-idist/build' '-i.' '-idist/build/autogen' '-Idist/build/autogen' '-Idist/build' '-optP-include' '-optPdist/build/autogen/cabal_macros.h' '-package-name' 'BuildTestSuiteDetailedV09-0.1' '-hide-all-packages' '-package-db' '/Users/dom/Dropbox/Private/cabal/Cabal/dist/package.conf.inplace' '-package-db' 'dist/package.conf.inplace' '-package-id' 'Cabal-1.17.0-inplace' '-package-id' 'base-4.6.0.1-2514ecbfe6573e639515d3e91d6e1f29' '-XHaskell98' 'Dummy'
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
Linking...
'/usr/bin/ar' '-r' '-s' 'dist/build/libHSBuildTestSuiteDetailedV09-0.1.a' 'dist/build/Dummy.o'
ar: creating archive dist/build/libHSBuildTestSuiteDetailedV09-0.1.a
In-place registering BuildTestSuiteDetailedV09-0.1...
'/usr/local/bin/ghc-pkg' 'update' '-' '--global' '--user' '--package-db=/Users/dom/Dropbox/Private/cabal/Cabal/dist/package.conf.inplace' '--package-db=dist/package.conf.inplace'
Preprocessing test suite 'dummy' for BuildTestSuiteDetailedV09-0.1...
Building test suite dummy...
'/usr/local/bin/ghc' '--info'
'/usr/local/bin/ghc' '--info'
creating dist/build
'/usr/local/bin/ghc' '--make' '-fbuilding-cabal-package' '-O' '-static' '-odir' 'dist/build' '-hidir' 'dist/build' '-stubdir' 'dist/build' '-i' '-idist/build' '-i.' '-idist/build/autogen' '-Idist/build/autogen' '-Idist/build' '-optP-include' '-optPdist/build/autogen/cabal_macros.h' '-package-name' 'dummy-0.1' '-hide-all-packages' '-package-db' '/Users/dom/Dropbox/Private/cabal/Cabal/dist/package.conf.inplace' '-package-db' 'dist/package.conf.inplace' '-package-id' 'Cabal-1.17.0-inplace' '-package-id' 'base-4.6.0.1-2514ecbfe6573e639515d3e91d6e1f29' '-XHaskell98' 'Dummy'
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
Linking...
'/usr/bin/ar' '-r' '-s' 'dist/build/libdummy.a' 'dist/build/Dummy.o'
ar: creating archive dist/build/libdummy.a
ar: dist/build/Dummy.o: No such file or directory

@ttuegel

ttuegel commented May 3, 2013

Copy link
Copy Markdown
Member Author

It's creating dist/package.conf.inplace, and it registers the package library, but it never gets around to registering the test suite library because it can't find dist/build/Dummy.o (a strange claim, since it says it just compiled that file). Can you check if that file is there? If it is, then there may be some strangeness with ar on Mac.

@idontgetoutmuch

Copy link
Copy Markdown
Member

No Dummy.o afaics:

bash-3.2$ cd tests/PackageTests/BuildTestSuiteDetailedV09/dist/build/
bash-3.2$ ls -ltr
total 24
drwxr-xr-x  4 dom  staff   136 May  3 16:44 autogen
-rw-r--r--  1 dom  staff     8 May  3 16:44 libdummy.a
-rw-r--r--  1 dom  staff  1544 May  3 16:44 libHSBuildTestSuiteDetailedV09-0.1.a
drwxr-xr-x  3 dom  staff   102 May  3 16:44 dummyStub
-rw-r--r--  1 dom  staff   890 May  3 16:44 Dummy.hi

@idontgetoutmuch

Copy link
Copy Markdown
Member

Do we need a main-is directive in the .cabal file?

@idontgetoutmuch

Copy link
Copy Markdown
Member

Ok I see we don't.

@ttuegel

ttuegel commented May 3, 2013

Copy link
Copy Markdown
Member Author

@idontgetoutmuch Does the last GHC command before the failure produce Dummy.o, and then somehow it just gets deleted before we call ar?

@idontgetoutmuch

Copy link
Copy Markdown
Member

@tteugel: I'll have to add some code to check but it's now 19:18 at odhac and we are going to the pub so it will have to wait until tomorrow.

@idontgetoutmuch

Copy link
Copy Markdown
Member

Simon Meier couldn't reproduce the build error so I did a completely fresh install.

 1669  git clone https://github.com/idontgetoutmuch/cabal.git
 1670  cd cabal/
 1671  git remote add upstream https://github.com/idontgetoutmuch/cabal.git
 1672  git fetch upstream
 1673  git merge upstream/master
 1674  cd Cabal/
 1675  cabal configure --enable-tests
 1676  cabal install --only-dependencies --enable-tests -j
 1677  cabal install --only-dependencies --enable-tests -j
 1678  cabal build
 1679  cabal test

And I can now reproduce the error more easily:

bash-3.2$ pwd
/Users/dom/cabal/Cabal/tests
bash-3.2$ cd PackageTests/BuildTestSuiteDetailedV09
bash-3.2$ ../../Setup configure --enable-tests
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Configuring BuildTestSuiteDetailedV09-0.1...
bash-3.2$ ../../Setup build
Building BuildTestSuiteDetailedV09-0.1...
Preprocessing library BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering BuildTestSuiteDetailedV09-0.1...
Preprocessing test suite 'dummy' for BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
ar: dist/build/Dummy.o: No such file or directory

But if I build the Setup in tests by hand, it works!

bash-3.2$ cd ../..
bash-3.2$ ghc Setup.hs -package-db=PackageTests/BuildTestSuiteDetailedV09/dist/package.conf.inplace
[1 of 1] Compiling Main             ( Setup.hs, Setup.o ) [Distribution.Simple changed]
Linking Setup ...
bash-3.2$ pwd
/Users/dom/cabal/Cabal/tests
bash-3.2$ cd PackageTests/BuildTestSuiteDetailedV09
bash-3.2$ ../../Setup configure --enable-tests
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Configuring BuildTestSuiteDetailedV09-0.1...
bash-3.2$ ../../Setup build
Building BuildTestSuiteDetailedV09-0.1...
Preprocessing library BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering BuildTestSuiteDetailedV09-0.1...
Preprocessing test suite 'dummy' for BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering dummy-0.1...
[1 of 1] Compiling Main             ( dist/build/dummyStub/dummyStub-tmp/dummyStub.hs, dist/build/dummyStub/dummyStub-tmp/Main.o )
Linking dist/build/dummyStub/dummyStub ...

@idontgetoutmuch

Copy link
Copy Markdown
Member

The latter success was red herring. Here is a simple reproduction of the problem.

I created a mini package and get the same problem in 1.17. If I use 1.16 I don't get the problem.

  /Users/dom/Dummy:
  total used in directory 40 available 104447508
  drwxr-xr-x   8 dom  staff   272 May  4 14:19 .
  drwxr-xr-x+ 73 dom  staff  2482 May  4 14:00 ..
  -rw-r--r--   1 dom  staff    95 May  4 14:00 Dummy.hs
  -rw-r--r--   1 dom  staff    71 May  4 14:19 OldStyle.hs
  -rw-r--r--   1 dom  staff    47 May  4 14:02 Setup.hs
  -rw-r--r--   1 dom  staff   494 May  4 14:01 my.cabal

module Dummy where

import Distribution.TestSuite (Test)

tests :: IO [Test]
tests = return []

import Distribution.Simple
main = defaultMain

name: BuildTestSuiteDetailedV09
version: 0.1
license: BSD3
author: Thomas Tuegel
stability: stable
category: PackageTests
build-type: Simple

description:
    Check that Cabal can build test suites of type detailed-0.9.

Library
    exposed-modules: Dummy
    build-depends: base, Cabal

test-suite dummy
  type:       detailed-0.9
  test-module: Dummy
  build-depends: base, Cabal

bash-3.2$ pwd
/Users/dom/Dummy
bash-3.2$ ../cabal/cabal-install/dist/build/cabal/cabal --version
cabal-install version 1.17.0
using version 1.17.0 of the Cabal library 
bash-3.2$ ../cabal/cabal-install/dist/build/cabal/cabal configure --enable-tests --package-db=../cabal/Cabal/dist/package.conf.inplace 
Warning: The package list for 'hackage.haskell.org' is 38 days old.
Run 'cabal update' to get the latest list of available packages.
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Resolving dependencies...
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Configuring BuildTestSuiteDetailedV09-0.1...
bash-3.2$ ../cabal/cabal-install/dist/build/cabal/cabal build
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Building BuildTestSuiteDetailedV09-0.1...
Preprocessing library BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering BuildTestSuiteDetailedV09-0.1...
Preprocessing test suite 'dummy' for BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
ar: dist/build/Dummy.o: No such file or directory

@idontgetoutmuch

Copy link
Copy Markdown
Member

It seems to be something to do with names. If I change the name of the test-suite from "dummy" to "Urk" then it works. I also tested changing "dummy" to "Dummy" on linux and this fails also. It looks like cabal uses the name of the test-suite for purposes it probably should not.

bash-3.2$ ../cabal/cabal-install/dist/build/cabal/cabal build
Warning: my.cabal: A package using section syntax must specify at least
'cabal-version: >= 1.2'.
Building BuildTestSuiteDetailedV09-0.1...
Preprocessing library BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering BuildTestSuiteDetailedV09-0.1...
Preprocessing test suite 'Urk' for BuildTestSuiteDetailedV09-0.1...
[1 of 1] Compiling Dummy            ( Dummy.hs, dist/build/Dummy.o )
In-place registering Urk-0.1...
[1 of 1] Compiling Main             ( dist/build/UrkStub/UrkStub-tmp/UrkStub.hs, dist/build/UrkStub/UrkStub-tmp/Main.o )
Linking dist/build/UrkStub/UrkStub ...
bash-3.2$ 

@idontgetoutmuch

Copy link
Copy Markdown
Member

Why you ask yourself did this problem show itself initially on a Mac (although it can now be reproduced on linux)?

"HFS+ (the Mac filesystem) is usually configured to be case insensitive but case preserving. This means that the file system will consider foo and FoO to be the same, but when you create a new file it will remember which letters where capitalized and which were not." See http://apple.stackexchange.com/questions/22297/is-bash-in-osx-case-insensitive for more details.

So this is a real problem even for linux users. It's not clear how to fix it though.

ttuegel added a commit to ttuegel/cabal that referenced this pull request May 4, 2013
Fixes haskell#1297 (again). Compiled object files are deleted before the detailed test
suite library is built. This is a workaround until the underlying cause is
known.
@ttuegel

ttuegel commented May 4, 2013

Copy link
Copy Markdown
Member Author

The immediate fix is to rename the test suite so it doesn't match the source file. The underlying issue is that (for reasons that are not yet clear to me) you cannot have detailed test suites with the same name as their exported module. I will open a new issue for this because we need to know if this problem affects other types of components.

@ttuegel

ttuegel commented May 4, 2013

Copy link
Copy Markdown
Member Author

@idontgetoutmuch #1310 should take care of it for now. Let me know if you continue to have trouble.

@ttuegel ttuegel deleted the test-inplace-lib branch May 4, 2013 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants