-
Notifications
You must be signed in to change notification settings - Fork 697
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
Access the executable build by cabal build
(with a custom Setup.hs
) from cabal test
#7577
Comments
There are three ways of doing this
The canonical way of testing an executable via I'm tagging with Cabal: cmd/test since this should be independent from the tool |
I was wrong about PRs to further improve the docs (eg. link to https://cabal.readthedocs.io/en/3.4/cabal-package.html#pkg-field-build-tool-depends from https://cabal.readthedocs.io/en/3.4/cabal-package.html#example-package-using-exitcode-stdio-1-0-interface) are welcome! |
Unfortunately, I discovered that this only works with custom-setup
setup-depends: base, Cabal and a standard import Distribution.Simple
main = defaultMain then
Likewise, which @fgaz Is this a bug or is there a trick to get it to work? |
In communication with @fgaz, we can demonstrate that this is problem is present in
UPDATE: According to an experiment, |
This looks like an instance of FWIW, I don't think |
I found that this specific problem only occurs between components in a single monolithic package. Separating the test and the exe in two packages works independently from the |
Could it be this? why are intra-package dependencies not collected? cabal/Cabal/src/Distribution/Simple/Configure.hs Lines 553 to 563 in 7d4ce47
|
here is when it was originally done, but the commit message does not explain why and it's from ten years ago. @dcoutts? 70196d5#diff-5df11a3bbf4660041725cd6c42025edefbf6e601774e4214e333a08a947048d7L432-R444 |
Might be related to EDIT: IMHO such special cases don't need to be supported. That's complexity which everyone has to pay, and |
An attempt to get `cabal test` to run after *installing* Agda rather than just building it.
An attempt to get `cabal test` to run after *installing* Agda rather than just building it.
* [ fix #5302 ] make 'cabal test' work for part of the test-suite 'cabal test' will run only the tests defined by 'agda-tests' * [ #5302 ] CI: work around haskell/cabal#7577 An attempt to get `cabal test` to run after *installing* Agda rather than just building it. * [ #5302 ] disable latex-tests for `cabal test` Mainly for CI, so that we do not have to install LaTeX. * [ #5302 ] disable compiler-stdlib tests for `cabal test` Do not work out of the box, need installation of the stdlib (for `Everything.agda`). * [ #5302 ] CI: `cabal test` also on macOS and Windows * [ #5302 ] `cabal test` macOS: work around haskell/cabal#7209 Cabal removes lower-case vowels from package names on macOS, see haskell/cabal#7209. Thus Agda might be just Agd in error messages reporting source locations. * [ #5302 ] giving up on `cabal test` under Windows The testsuite fails but does not display diffs. tasty-silver might not yet be portable, see phile314/tasty-silver#16 * [ #5302 ] fix the alert printed by `cabal test` Correct reference is `v1-install` in `cabal v1-install --run-tests`. * PR #5536: final polishing
* [ fix #5302 ] make 'cabal test' work for part of the test-suite 'cabal test' will run only the tests defined by 'agda-tests' * [ #5302 ] CI: work around haskell/cabal#7577 An attempt to get `cabal test` to run after *installing* Agda rather than just building it. * [ #5302 ] disable latex-tests for `cabal test` Mainly for CI, so that we do not have to install LaTeX. * [ #5302 ] disable compiler-stdlib tests for `cabal test` Do not work out of the box, need installation of the stdlib (for `Everything.agda`). * [ #5302 ] CI: `cabal test` also on macOS and Windows * [ #5302 ] `cabal test` macOS: work around haskell/cabal#7209 Cabal removes lower-case vowels from package names on macOS, see haskell/cabal#7209. Thus Agda might be just Agd in error messages reporting source locations. * [ #5302 ] giving up on `cabal test` under Windows The testsuite fails but does not display diffs. tasty-silver might not yet be portable, see phile314/tasty-silver#16 * [ #5302 ] fix the alert printed by `cabal test` Correct reference is `v1-install` in `cabal v1-install --run-tests`. * PR #5536: final polishing
myabe it should be closed (or the title changed) as you can access the executable inthegeneral case |
cabal build
from cabal test
cabal build
(with a custom Setup.hs
) from cabal test
I changed the title to be more precise. |
Question: What is the canonical way to write a
test-suite
that calls theexecutable
as process, e.g. viasystem
?While writing up the question, I discovered an answer that I want to share here, since I could not discover it so far by googling (despite many tries). This answer could possibly find its way into the documentation, e.g. near https://cabal.readthedocs.io/en/3.4/cabal-package.html#example-package-using-exitcode-stdio-1-0-interface.
Here is a minimal test-suite code
Test.hs
that tries to call the executablehello-world
defined in the same cabal project:We can run
hello-world
viacabal run -- hello-world
.However, without special provision,
cabal test
fails:The solution is to add the executable to the
test-suite
stanza, via fieldbuild-tool-depends
:For completeness, here is
Main.hs
:Now
cabal test
works!Context: agda/agda#5302 (comment)
Please tag this issue with
cabal-install: cmd/test
andtype: user question
.The text was updated successfully, but these errors were encountered: