Skip to content

tests: make UserConfig unit tests concurrency-safe with unique tempiles#11759

Merged
mergify[bot] merged 6 commits intohaskell:masterfrom
ulysses4ever:master
Apr 25, 2026
Merged

tests: make UserConfig unit tests concurrency-safe with unique tempiles#11759
mergify[bot] merged 6 commits intohaskell:masterfrom
ulysses4ever:master

Conversation

@ulysses4ever
Copy link
Copy Markdown
Collaborator

@ulysses4ever ulysses4ever commented Apr 20, 2026

Fix #11686. Created with Copilot.


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).

@Bodigrim
Copy link
Copy Markdown
Collaborator

It adds some more cleanup than strictly what #11686 asks for (the teardown function removes some extra *.tmp files) but it looks legit: it addresses this logic in Distribution.Client.Config

Rather than work around it in the test suite, let's fix Distribution.Client.Config: the shenanigans with tmpFile are ill advised, just createDirectoryIfMissing and immediately writeFileAtomic file.

@geekosaur
Copy link
Copy Markdown
Collaborator

FWIW I agree with Bodigrim.

@ulysses4ever
Copy link
Copy Markdown
Collaborator Author

@Bodigrim done. There's also a new test that tries to concurrently create user configs. Let me know if it doesn't make sense, I can remove it.

@Bodigrim
Copy link
Copy Markdown
Collaborator

There's also a new test that tries to concurrently create user configs. Let me know if it doesn't make sense, I can remove it.

It does not make sense to me.

@ulysses4ever
Copy link
Copy Markdown
Collaborator Author

@Bodigrim very well, the test is removed. The only potentially slippery spot I can think of is the bytestring-management business that had to be added for writeFileAtomic (writeFileAtomic file $ LBS.fromStrict . toUTF8BS $ ...). If there's a beter way to get it done, let me know. Otherwise this should be ready hopefully.

@Bodigrim
Copy link
Copy Markdown
Collaborator

If there's a beter way to get it done, let me know.

One can construct StrictByteString directly (by replacing Disp.render in showConfigWithComments with Disp.fullRender), but this perhaps goes beyond the scope of the issue. I'm fine either way.

@philderbeast
Copy link
Copy Markdown
Collaborator

@ulysses4ever this seems to have fixed the problem with #11686. After a few runs, maybe the 4th, I got this error:

$ cabal test cabal-install:unit-tests
...
    getProjectRootUsability
      relative path:                                                                                                FAIL (0.02s)
        tests/UnitTests/Distribution/Client/ProjectConfig.hs:122:
        expected: ProjectRootUsabilityPresentAndUsable
         but got: ProjectRootUsabilityNotPresent
        Use -p '/relative path/' to rerun this test only.

@Bodigrim
Copy link
Copy Markdown
Collaborator

After a few runs, maybe the 4th, I got this error...

AFAICT this is not a regression caused by this PR, but rather another facet of upgrade to tasty-1.5.4: running testGetProjectRootUsability concurrently is expected to fail. I'd suggest to raise a separate ticket.

@ulysses4ever
Copy link
Copy Markdown
Collaborator Author

@Bodigrim

but this perhaps goes beyond the scope of the issue. I'm fine either way.

I'd then stick to what's there currently.

Copilot AI and others added 6 commits April 22, 2026 22:21
…iles (#26)

tests: use unique temp files in UserConfig bracketTest

Agent-Logs-Url: https://github.com/ulysses4ever/cabal/sessions/043e3696-3cda-43aa-aa50-e483ec531d13

Co-authored-by: ulysses4ever <6832600+ulysses4ever@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ulysses4ever <6832600+ulysses4ever@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ulysses4ever <6832600+ulysses4ever@users.noreply.github.com>
@ulysses4ever
Copy link
Copy Markdown
Collaborator Author

CI is green now.

@philderbeast
Copy link
Copy Markdown
Collaborator

AFAICT this is not a regression caused by this PR, but rather another facet of upgrade to tasty-1.5.4: running testGetProjectRootUsability concurrently is expected to fail. I'd suggest to raise a separate ticket.

I tried many times and couldn't reproduce this error. Leaving it for now but will log it if I see it again.

Copy link
Copy Markdown
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

LGTM

@Mikolaj Mikolaj added the squash+merge me Tell Mergify Bot to squash-merge label Apr 23, 2026
@mergify mergify Bot added the ready and waiting Mergify is waiting out the cooldown period label Apr 23, 2026
@mergify mergify Bot added merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days queued labels Apr 25, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 25, 2026

Merge Queue Status

  • Entered queue2026-04-25 17:48 UTC · Rule: squash-merge
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-25 17:58 UTC · at d09efbe76306a29938d81c301e3106d8f30d8f5e · squash

This pull request spent 10 minutes 14 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate post job
    • check-neutral = Validate post job
    • check-skipped = Validate post job
  • any of [🛡 GitHub branch protection]:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of [🛡 GitHub branch protection]:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of [🛡 GitHub branch protection]:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

@mergify mergify Bot merged commit ff9daa2 into haskell:master Apr 25, 2026
209 checks passed
@mergify mergify Bot removed the queued label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attention: needs-review merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days ready and waiting Mergify is waiting out the cooldown period squash+merge me Tell Mergify Bot to squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"resource busy (file is locked)" failures running tests locally

8 participants