Skip to content

Add test cases that reproduce sdist --project-file. - #8226

Merged
mergify[bot] merged 1 commit into
haskell:masterfrom
cabalism:test/sdist-multiple-projects-7241
Jan 22, 2024
Merged

mergify[bot] merged 1 commit into
haskell:masterfrom
cabalism:test/sdist-multiple-projects-7241

Conversation

@philderbeast

@philderbeast philderbeast commented Jun 17, 2022 •

Copy link
Copy Markdown
Collaborator

This is a WIP. Struggling a bit to navigate the test set up, I opted instead to create a small set of tests for reproducing the problem of cabal sdist --project-file not respecting the project file option, #7241.

I'm testing this with:

> cabal --version
cabal-install version 3.8.0.20220526
compiled using version 3.8.0.20220526 of the Cabal library

@philderbeast

Copy link
Copy Markdown
Collaborator Author

If in the sdist/projects-default-no folder then any of the calls in repro.txt result is sdist going up the tree like this:

> cabal sdist all
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/cabal-testsuite-3.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-syntax-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/cabal-install-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/cabal-install-solver-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/solver-benchmarks-3.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-QuickCheck-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-tree-diff-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-described-3.9.0.0.tar.gz
Wrote tarball sdist to
/.../cabal/dist-newstyle/sdist/Cabal-tests-3.tar.gz
Wrote tarball sdist to
/./cabal/dist-newstyle/sdist/cabal-benchmarks-3.tar.gz

For the sdist/projects-default-yes folder that has a cabal.project file, a project with the default name, the behaviour is different but each time it is not respecting the --project-file option:

> cabal sdist all
Error: cabal: sdist of p-0.1: Could not find module: P with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.

> cabal sdist all --project-file=cabal.project
Error: cabal: sdist of p-0.1: Could not find module: P with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.

> cabal sdist all --project-file=cabal.sub-rs.project
Error: cabal: sdist of p-0.1: Could not find module: P with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.

> cabal sdist all --project-file=cabal.dot-uv.project
Error: cabal: sdist of p-0.1: Could not find module: P with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.

@Mikolaj

Mikolaj commented Jun 20, 2022

Copy link
Copy Markdown
Member

result is sdist going up the tree like this

If I understand what is says, perhaps it's because the place the project file is in is the root from which sdist operates, not the directory sdist was called in?

the behaviour is different but each time it is not respecting the --project-file option

Thank you for the repro. So which of the four calls should work fine? BTW, did you try moving the options before all? Before sdist?

@mergify mergify Bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Sep 1, 2022
@ulysses4ever ulysses4ever removed the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Sep 3, 2022
@Kleidukos

Copy link
Copy Markdown
Member

Marking this PR as draft 🙂

@Kleidukos
Kleidukos marked this pull request as draft May 17, 2023 06:19
@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch 2 times, most recently from 5ffaf93 to 3cc1016 Compare December 15, 2023 17:35
@philderbeast philderbeast changed the title WIP: Add test cases that reproduce sdist --project-file. Add test cases that reproduce sdist --project-file. Dec 15, 2023
@philderbeast
philderbeast marked this pull request as ready for review December 15, 2023 17:36
@philderbeast

philderbeast commented Dec 15, 2023 •

Copy link
Copy Markdown
Collaborator Author

Tests of sdist with --project-file

$ tree -P '*.project|*.test.hs' --prune
.
├── cabal.ignore-project.test.hs
├── cabal.no-project.test.hs
├── cabal.project
├── Projects-Default-No
│   ├── cabal.dot-uv.project
│   ├── cabal.dot-uv.test.hs
│   ├── cabal.ignore-project.test.hs
│   ├── cabal.no-project.test.hs
│   ├── cabal.sub-pq.project
│   ├── cabal.sub-pq.test.hs
│   ├── cabal.sub-rs.project
│   └── cabal.sub-rs.test.hs
└── Projects-Default-Yes
    ├── cabal.dot-uv.project
    ├── cabal.dot-uv.test.hs
    ├── cabal.ignore-project.test.hs
    ├── cabal.no-project.test.hs
    ├── cabal.project
    ├── cabal.project.test.hs
    ├── cabal.sub-pq.project
    ├── cabal.sub-pq.test.hs
    ├── cabal.sub-rs.project
    └── cabal.sub-rs.test.hs

3 directories, 21 files

There are of the two subdirectories, one has a cabal.project and the other doesn't. This is the default project. There are two important things to notice with these tests.

  1. All the tests with a supplied --project-file option pick up a default cabal.project instead; either the one one in the current directory or the one from the parent directory, one level up. I think this behaviour is wrong and the supplied --project-file option should be respected.

    Before I'd put a project there, one level up, the project probing had gone all the way up to Cabal's own cabal.project as can be seen by this diff after that change:

    $ git diff
    ...
    --- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-rs.out
    +++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-rs.out
    @@ -1,12 +1,2 @@
    # cabal sdist
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-testsuite-3.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-syntax-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-install-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-install-solver-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/solver-benchmarks-3.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-QuickCheck-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-tree-diff-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-described-3.11.0.0.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-tests-3.tar.gz
    -Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-benchmarks-3.tar.gz
    +Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
  2. The --ignore-project option works, as witnessed by each cabal.ignore-project.test.hs when the package in the same directory as the test is used. Note the parse failure when sublibraries are used. I think we could provide a better error message there:

    $ cabal sdist
    ...
    Errors encountered when parsing cabal file ./uv.cabal:
    
    uv.cabal:8:22: error:
    unexpected "u"
    
        7 |   visibility: public
        8 |   exposed-modules: U.u
        |                      ^
    

@philderbeast

Copy link
Copy Markdown
Collaborator Author

This was CI green but out of date with the master branch. I've just rebased.

@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch from 9c88a41 to 0393803 Compare January 8, 2024 21:14

@andreasabel andreasabel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, great to have these tests!

Would it be possible to add to each test (I guess the .hs files) a comment stating what this test is testing and what the expected outcome is (like "should fail with...", "should succeed...")?
I think this would make it easier for posterity to comprehend the tests, and to fix tests should they be failiing because of a change in cabal...

@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch 2 times, most recently from 992ad33 to 1a40ba1 Compare January 14, 2024 21:01
@philderbeast

Copy link
Copy Markdown
Collaborator Author

@andreasabel I've left notes in the *.test.hs files saying that either the test is correct or saying that the test is actually producing wrong output because cabal sdist --project-file=... is not respecting the project. In the later case I've included patches that alter the *.out file to what I would expect if cabal sdist did respect the project.

The cabal-testsuite/PackageTests/SDist/Respect-Project-File/README.md gives an overview of the tests.

@philderbeast

Copy link
Copy Markdown
Collaborator Author

Currently comparing cabal sdist output with cabal v2-sdist output and they're not the same. I thought the v2- commands (forwards-compatible aliases) are now the same as their non-prefixed sibling commands so cabal build and cabal v2-build do the same thing. That is not the case for cabal sdist and cabal v2-sdist.

@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch 2 times, most recently from 18dc465 to debfdfe Compare January 17, 2024 22:18

@andreasabel andreasabel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @philderbeast , for equipping the test with descriptions!

@andreasabel

Copy link
Copy Markdown
Member

@philderbeast : Thanks!
When ready, please apply the "squash+merge me" label so this PR gets squashed and merged by Mergify.

@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch from debfdfe to 1ad1704 Compare January 20, 2024 12:51
- Move project sdist tests to cabal-testsuite
- Add --ignore-project test
- Duplicate tests but without cabal.project
- Add a cabal.project one folder up
- Add a package Z in the root
- Rerun --accept with more immediate parent project
- Add a readme for the tests
- Fix problems with uv package, update expected output
- Add U and V modules
- Explain what is wrong with cabal.dot-uv.test.hs
- Add a note on cabal.no-project.test.hs
- Explain what is wrong with cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Explain what is wrong with cabal.dot-uv.test.hs
- Leave a note explaining cabal.no-project.test.hs
- Leave a note explaining cabal.project.test.hs
- Leave a note explaining cabal.sub-pq.test.hs
- Explain what is wrong with cabal.sub-rs.test.hs
- Patches for project respecting behaviour
- Explain root ignore-project and no-project tests
- Add *.v2.test.hs variants exercising v2-sdist
- Add v2 patches, test out not using <ROOT>
@philderbeast
philderbeast force-pushed the test/sdist-multiple-projects-7241 branch from 1ad1704 to 1e62b82 Compare January 20, 2024 12:56
@philderbeast

Copy link
Copy Markdown
Collaborator Author

@andreasabel I squashed manually.

Label merge+no rebase is necessary when the pull request is from an organisation.

@mergify mergify Bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jan 22, 2024
@mergify
mergify Bot merged commit adc283a into haskell:master Jan 22, 2024
@Mikolaj

Mikolaj commented Jan 23, 2024

Copy link
Copy Markdown
Member

@philderbeast: thank you very much again for the exotic label justification ceremony.

BTW, I think, after you squashed, you forgot to rebase just before merging, which resulted in a tangled git history (not that tangled and that's not a big deal, but helps a bit when trawling the commit list, e.g., when bisecting problems). I'm sorry about the trouble --- normally that's one of the things mergify does for us, rebasing and testing as many times as needed, if the branch moves while it's working.

@andreasabel

Copy link
Copy Markdown
Member

@philderbeast wrote:

Label merge+no rebase is necessary when the pull request is from an organisation.

Ah, I didn't know about that. Can I read up on this somewhere?
E.g. for the Agda repo I disabled the "merge commit" option for PRs.

@philderbeast philderbeast mentioned this pull request Mar 18, 2026
1 of 2 tasks
@philderbeast

Copy link
Copy Markdown
Collaborator Author

@andreasabel the normal merge me label works now for an organisation.

@andreasabel

Copy link
Copy Markdown
Member

@philderbeast Thanks for the heads up! Where can I read about this?

@philderbeast

Copy link
Copy Markdown
Collaborator Author

@andreasabel we switched to a merge queues with #11015.

BTW if this works then the next thing to try is to see if things we had to use merge+no rebase with work with merge me or squash+merge me. I think (per @TeofilC on Matrix) that Mergify cherry-picks commits into the queue PR, squashes them if it's the squash+merge queue, and rebases the result — which will be happening on Mergify's own local PR, not the one it's not allowed to rebase.
#11015 (comment)

we've configured a merge queue, so the rebase should happen on Mergify's queue PR instead
#11094 (comment).

This is using Mergify's draft pull requests.

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

Labels

Cabal: tests/package-tests merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge+no rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants