cabal-testsuite bare versus v2-prefixed command handling

Open
#12,501 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
testing, tooling

Research direction

Start by reading cabal-testsuite/src/Test/Cabal/Prelude.hs around the linked cabalGArgs code, then run the provided PackageTests/SDist/Respect-Project-File/cabal.no-project.test.hs reproduction. Check how the test helper recognizes Cabal commands and aliases. Done means the test can use sdist and behaves like v2-sdist, with the expected output and location.

Written by the indexing model from the issue text.

Description

needs triage type: bug

Describe the bug
I used sdist in a cabal-testsuite test in #12499 and it failed the validate step. Changing this to v2-dist fixed the test failure but v2-sdist is a synonym for sdist, isn't it?

$ cabal --help

[sanity checks and shipping]
...
  sdist                  Generate a source distribution file (.tar.gz).
...
[new-style projects (forwards-compatible aliases)]
...
  v2-sdist               Generate a source distribution file (.tar.gz).

 [legacy command aliases]
  v1-build               Compile all/specific components.
  v1-configure           Prepare to build the package.
  v1-repl                Open an interpreter session for the given component.
  v1-run                 Builds and runs an executable.
  v1-test                Run all/specific tests in the test suite.
  v1-bench               Run all/specific benchmarks.
  v1-freeze              Freeze dependencies.
  v1-haddock             Generate Haddock HTML documentation.
  v1-install             Install packages.
  v1-clean               Clean up after a build.
  v1-copy                Copy the files of all/specific components to install locations.
  v1-register            Register this package with the compiler.
  v1-reconfigure         Reconfigure the package if necessary.
  v1-gen-bounds          Generate dependency bounds.

Note there is no v1-sdist included with the help.

Perhaps the command matching in cabalGArgs is out of step with cabal's commands and command aliases?

https://github.com/haskell/cabal/blob/07e003b333424d6557a3ffd396895e5147eeb6d8/cabal-testsuite/src/Test/Cabal/Prelude.hs#L397-L415

To Reproduce
On master from the root:

cabal build cabal-install:exe:cabal cabal-testsuite:cabal-tests
CABAL=$(cabal list-bin cabal-install:exe:cabal)
TESTS=$(cabal list-bin cabal-testsuite:cabal-tests)
cd cabal-testsuite
$TESTS --with-cabal=$CABAL --intree-cabal-lib=$PWD/.. \
  --test-tmp=/tmp/cabal-testdb \
  PackageTests/SDist/Respect-Project-File/cabal.no-project.test.hs
...
Error: cabal: unrecognized 'sdist' option
`--package-db=/tmp/cabal-testdb/intree/store/ghc-9.14.1-c6c3/package.db'

Now change the test:

--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/cabal.no-project.test.hs
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/cabal.no-project.test.hs
-    cabal "sdist" ["all"]
+    cabal "v2-sdist" ["all"]

The test has different output when run again with this diff:

CABAL=$(cabal list-bin cabal-install:exe:cabal)
TESTS=$(cabal list-bin cabal-testsuite:cabal-tests)
cd cabal-testsuite
$TESTS --with-cabal=$CABAL --intree-cabal-lib=$PWD/.. \
  --test-tmp=/tmp/cabal-testdb \
  PackageTests/SDist/Respect-Project-File/cabal.no-project.test.hs
...
# STDERR:
--- /tmp/cabal-testsuite-3454100/cabal.no-project.dist/cabal.no-project.out.normalized	2026-10-30 12:09:13.663990497 -0400
+++ /tmp/cabal-testsuite-3454100/cabal.no-project.dist/cabal.no-project.comp.out.normalized	2026-10-30 12:09:13.663929684 -0400
@@ -1,2 +1,2 @@
-# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.no-project.dist/work/./dist/sdist/p-0.1.tar.gz
+# cabal v2-sdist
+Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
cabal.no-project.test.hs: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:

FAIL
...

Expected behavior
That I can use the current command vocabulary in tests. In this case that I can usesdist for a test and that behaves the same as if I'd used v2-sdist.

Dominant language
Haskell
Stars
1.8k
Forks
766
Avg merge
5d 21h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/cabal

All issues in haskell/cabal

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.