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

make cabal-install integration tests hermetic #10205

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

geekosaur
Copy link
Collaborator

@geekosaur geekosaur commented Jul 16, 2024

They were using the user's config, which is a problem if they don't have one or if it contains settings that interfere with tests (such as documentation: True).

I'm not entirely certain of this, but it seems to work here. It's a bit of a hack, though.

Closes: #10187

Template B: This PR does not modify behaviour or interface

E.g. the PR only touches documentation or tests, does refactorings, 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).

@geekosaur
Copy link
Collaborator Author

Also, someone told me "nobody runs validate locally" — but I've needed to do so several times, and in particular I prefer to validate locally before bogging down CI when possible.

@geekosaur geekosaur force-pushed the hermetic-integrationtests2 branch 2 times, most recently from 717745c to 544c8e1 Compare July 17, 2024 00:24
@geekosaur
Copy link
Collaborator Author

Uh, weird validate error? I don't think that's me, it looks like it hadn't even reached IntegrationTests2 yet.

@geekosaur geekosaur force-pushed the hermetic-integrationtests2 branch 4 times, most recently from bf6469b to 8cbb41b Compare July 17, 2024 01:26
@geekosaur
Copy link
Collaborator Author

geekosaur commented Jul 17, 2024

I came up with a change that makes it work locally, but may make some tests unhappy. Guess we'll see. (ETA: seems to be working.)

I could argue the first version was more correct, since we should really not rely on $HOME in any way; it's not so different from why we relocate tests to /tmp now.

@geekosaur
Copy link
Collaborator Author

geekosaur commented Jul 17, 2024

Manual QA is simple: run validate.sh locally, make sure IntegrationTests2 doesn't fail. This is especially needed for non-Linux platforms.

$ cabal build all
$ ./validate.sh --cli --with-cabal $(cabal list-bin cabal)

(I'm not sure if --cli is needed there.)

@ulysses4ever
Copy link
Collaborator

If it "needs-review", it should be un-drafted, presumably...

@geekosaur
Copy link
Collaborator Author

If it "needs-review", it should be un-drafted, presumably...

I would like people to comment on it, specifically on my approach, before I commit to it.

@geekosaur geekosaur marked this pull request as ready for review July 18, 2024 01:16
@tbidne
Copy link
Contributor

tbidne commented Jul 18, 2024

Nice idea.

I have noticed when running tests locally:

cabal run cabal-testsuite:cabal-tests -- --hide-successes --with-cabal=./bin/cabal

That I receive many failures due to the following lines in the output:

+Warning: Both <ROOT>/cabal.dist/home/.cabal and /home/tommy/.config/cabal/config exist - ignoring the former.
+It is advisable to remove one of them. In that case, we will use the remaining one by default (unless '$CABAL_DIR' is explicitly set).

While the right answer in this particular situation is to delete the extra dir (it appears to be created by nix in some circumstances), it would be nice if the tests were isolated.

My issue may be out of scope for this particular PR (I tried it out and still received the errors), but I thought I'd comment since it seems related.

@geekosaur
Copy link
Collaborator Author

I don't use Nix, so I don't think that's the cause. In any case, this patch sets CABAL_DIR to a newly created configuration tree, which suppresses the extra output per the error message while ensuring that a pristine configuration is used.

@geekosaur
Copy link
Collaborator Author

geekosaur commented Jul 18, 2024

Also, my guess is you're getting them from things other than the cabal-install integration tests. That's certainly beyond the scope of this particular PR, but is probably worth reporting on its own as an indication that we have other cases of leaky configs.

Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

Copy link
Collaborator

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable.

I was bitten by this with my:

ghc-options: -optc-Wno-pragma-pack -optc-Wno-macro-redefined -optc-Wno-missing-declarations

for this: https://gitlab.haskell.org/ghc/ghc/-/issues/25031

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jul 20, 2024
They were using the user's config, which is a problem if they don't
have one or if it contains settings that interfere with tests
(such as `documentation: True`).

I'm not entirely certain of this, but it seems to work here. It's
a bit of a hack, though.
@Mikolaj Mikolaj force-pushed the hermetic-integrationtests2 branch from e46888d to cd45432 Compare July 20, 2024 15:51
@mergify mergify bot merged commit 1def827 into haskell:master Jul 20, 2024
52 checks passed
@geekosaur
Copy link
Collaborator Author

@mergify backport 3.12

Copy link
Contributor

mergify bot commented Jul 20, 2024

backport 3.12

✅ Backports have been created

mergify bot added a commit that referenced this pull request Jul 20, 2024
make cabal-install integration tests hermetic (backport #10205)
@jasagredo jasagredo added the tested-on: windows QA has been successful on Windows label Jul 22, 2024
@geekosaur geekosaur deleted the hermetic-integrationtests2 branch September 3, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: needs-manual-qa PR is destined for manual QA merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge tested-on: windows QA has been successful on Windows
Projects
Status: To Test
Development

Successfully merging this pull request may close these issues.

cabal-install/tests/IntegrationTests2.hs is sensitive to local configuration
4 participants