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

Add Cabal-tests workaround project #9923

Closed

Conversation

philderbeast
Copy link
Collaborator

A workaround for #9901 so that we can use released versions of cabal-install, such as cabal-3.8.* and cabal-3.10.*, with Cabal-tests:parser-tests and Cabal-tests:check-tests test suites when cabal run running them to accept updated test outputs.

To repeat the problem; when we run cabal test Cabal-tests, the working directory will be Cabal-tests but when we run cabal run Cabal-tests:parser-tests or Cabal-tests:check-tests it will be the current directory. To update the expected outputs we need to first change directory to Cabal-tests. That is good for the package but not for the root cabal.project that will be unable to resolve imports failing with;

$ cd Cabal-tests/
$ cabal run Cabal-tests:parser-tests -- --accept
project-cabal/pkgs/cabal.config: withBinaryFile: does not exist (No such file or directory)

I deliberately named Cabal-tests/cabal.workaround.project so that we might notice to delete it at a later time. This is at the cost of having to do the following with earlier versions of cabal;

$ cd Cabal-tests/
$ ~/.ghcup/bin/cabal run Cabal-tests:parser-tests --project-file=cabal.workaround.project -- --accept
$ ~/.ghcup/bin/cabal --version
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal library

Note

With #9578 and later versions of cabal-install, the above problem does not occur and the workaround project is not needed. I did not set out to fix this exact problem but left the comment "I also fix some bugs around project imports" on that pull request. Related, we should check the behavior before and after #9578 to see if it helps with #8795.

  • I updated the readme for Cabal-tests and put it in that package's directory, up one from where it was before.
  • I noticed that docs for cabal test and cabal run make no mention of working directory.
  • I noticed an inconsistency between Cabal-tests --accept and cabal-testsuite --accept. With the former we need to be in the Cabal-tests directory for it to work but for the later we need to be in the root of the project and running --accept from the cabal-testsuite directory fails. Currently it fails for the same reason as Cabal-tests does but prior to the project changes of Use package groups #9565, it also fails;
$ git rev-parse HEAD
1c1230ca228cc03a9ee68166243af358ab3992fc

$ cabal install cabal-install:exe:cabal --overwrite-policy=always

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.8.2

$ cabal build all --enable-tests --enable-benchmarks

$ ls cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs
cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs

$ cabal run cabal-testsuite:cabal-tests -- --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.8.2/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs --accept
...
OK

$ cd cabal-testsuite

$ cabal run cabal-testsuite:cabal-tests -- --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.8.2/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs --accept
...
<no location info>: error: [GHC-49196]
    Can't find cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs
*** Exception: ExitFailure 1
...

Template Β: This PR does not modify cabal behaviour (documentation, tests, refactoring, etc.)

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@Mikolaj
Copy link
Member

Mikolaj commented Apr 23, 2024

A ping about #9901 (comment) in case it goes under the radar. :)

@Mikolaj Mikolaj requested review from mpickering and alt-romes April 23, 2024 21:23
@philderbeast philderbeast force-pushed the test/pkg-parser-tests-9901 branch from 34bac5c to e0fcb97 Compare April 23, 2024 22:56
@philderbeast
Copy link
Collaborator Author

Note

With #9578 and later versions of cabal-install, the above problem does not occur and the workaround project is not needed. I did not set out to fix this exact problem but left the comment "I also fix some bugs around project imports" on that pull request.

@grayjay the effort we put into #9578 may be paying dividends.

@Mikolaj
Copy link
Member

Mikolaj commented Apr 24, 2024

@philderbeast: thank you for you prompt action. The reporter of the issue is on holidays, so let me add another reviewer.

@philderbeast
Copy link
Collaborator Author

@Mikolaj, I've renamed the workaround project so that it will be picked up automatically from the Cabal-tests directory, the directory that we need to be in for cabal run --accept to update expected outputs for the test suite.

@Mikolaj
Copy link
Member

Mikolaj commented Apr 25, 2024

Yay, so does this solve all plausible cases of this failure? Or is there a common workflow that does not enter that directory?

Can the reviewers/reporters comment?

@philderbeast
Copy link
Collaborator Author

philderbeast commented Apr 27, 2024

Yay, so does this solve all plausible cases of this failure?

It fixes the reproduction of #9901 for cabal run. This workaround project will only be picked up if in the Cabal-tests directory.

Or is there a common workflow that does not enter that directory?

For cabal test, there's no directory restriction as long as cabal can sight the project. We can test the parser-tests test suite from the root directory or any subdirectory of the project except those with a intercepting project such as cabal-testsuite that blocks access to the root project.

@philderbeast philderbeast force-pushed the test/pkg-parser-tests-9901 branch from ed719be to b0d85e2 Compare April 27, 2024 12:11
@mpickering
Copy link
Collaborator

I am not sure this fixes the regression, you are still unable to run cabal in a subdirectory (it partially fixes the issue with running it in one specific subdirectory).

@philderbeast philderbeast force-pushed the test/pkg-parser-tests-9901 branch from b0d85e2 to df63967 Compare May 6, 2024 18:43
@philderbeast
Copy link
Collaborator Author

@Mikolaj & @mpickering , I'm closing this now in anticipation of the imminent cabal-install-3.12.* release that will be able to cabal run from the Cabal-tests subdirectory without the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants