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

building tests with cabal #5302

Closed
rdck opened this issue Apr 4, 2021 · 12 comments · Fixed by #5536
Closed

building tests with cabal #5302

rdck opened this issue Apr 4, 2021 · 12 comments · Fixed by #5536
Assignees
Labels
cabal Build problems specifically related to cabal-install infra: test suite Issues relating to the test suite (not in changelog) type: enhancement Issues and pull requests about possible improvements
Milestone

Comments

@rdck
Copy link

rdck commented Apr 4, 2021

What's the correct way to build the tests with cabal?

AFAIK, the install-bin target should create agda-tests in the build directory, if everything is working correctly. But it doesn't. I noticed that there aren't any test suites defined in Agda.cabal, but I'm not sure if that's the reason.

Here's the log for make test:

cd src/fix-agda-whitespace && cabal v1-clean && cabal v1-build
======================================================================
===================== Suite of successful tests ======================
======================================================================
make[1]: Entering directory '/home/river/sources/op/aports/testing/agda/src/agda-2.6.1.3/test/Common'
cleaning...
Bool.agda
Char.agda
Coinduction.agda
Equality.agda
Resolving dependencies...
Configuring fix-agda-whitespace-0.0.4...
Float.agda
Preprocessing executable 'fix-agda-whitespace' for fix-agda-whitespace-0.0.4..
Building executable 'fix-agda-whitespace' for fix-agda-whitespace-0.0.4..
[1 of 1] Compiling Main             ( FixWhitespace.hs, dist/build/fix-agda-whitespace/fix-agda-whitespace-tmp/Main.o )
Linking dist/build/fix-agda-whitespace/fix-agda-whitespace ...
IO.agda
======================================================================
======================= Suite of failing tests =======================
======================================================================
bash: line 1: /home/river/sources/op/aports/testing/agda/src/agda-2.6.1.3/dist/dist-sandbox-6c72f0e1/build/agda-tests/agda-tests: No such file or directory
make: *** [Makefile:280: fail] Error 127
make: *** Waiting for unfinished jobs....
Integer.agda
Irrelevance.agda
Issue481ParametrizedModule.agda
Issue964/UnsolvedMetas.agda
Level.agda
List.agda
MAlonzo.agda
Maybe.agda
Nat.agda
Prelude.agda
Product.agda
Reflection.agda
Size.agda
String.agda
Sum.agda
Unit.agda
make[1]: Leaving directory '/home/river/sources/op/aports/testing/agda/src/agda-2.6.1.3/test/Common'
bash: line 1: /home/river/sources/op/aports/testing/agda/src/agda-2.6.1.3/dist/dist-sandbox-6c72f0e1/build/agda-tests/agda-tests: No such file or directory
make: *** [Makefile:274: succeed] Error 127
>>> ERROR: agda: check failed

I'm on the latest release (2.6.1.3).

@andreasabel
Copy link
Member

agda-tests is only for running the internal test suite, i.e., QuickCheck tests. The other tests are run, as you correctly tried, via make test.
It seems that your make does things in parallel, at least the log is wildly mixing different execution threads, so it is hard to make sense of it. What is the log with a sequential execution of make test?

@andreasabel andreasabel added agda-tests status: info-needed More information is needed from the bug reporter to confirm the issue. infra: test suite Issues relating to the test suite (not in changelog) labels Aug 19, 2021
@asr
Copy link
Member

asr commented Aug 19, 2021

I noticed that there aren't any test suites defined in Agda.cabal.

The tests are not included in the released version.

@andreasabel
Copy link
Member

@asr: Is there a strong reason why cabal test cannot run the testsuite?

If I try this, I get an error that AGDA_BIN is not set. Is there maybe a way to get the agda binary that was created in connection with cabal test?

On a practical side, running the whole testsuite may be too much, but cabal test could at least run a selection of tests.

@andreasabel andreasabel added type: enhancement Issues and pull requests about possible improvements and removed status: info-needed More information is needed from the bug reporter to confirm the issue. labels Aug 23, 2021
@mouse07410
Copy link

This problem is only a tip of the iceberg, and reflects that Cabal places the built binaries to where the subsequent tests don't look for it - aka, can't find.

Here's my way of solving it by creating a wrapper shell script that does the right magic for the complete rebuild. It ensures (by setting appropriate env vars and removing stale binaries) that at least the right binaries are correctly located and used:

#!/bin/bash

DATE_START="`date`"

export GHC_ENVIRONMENT=-

VER=`head -4 mk/versions.mk | grep VERSION | cut -f2 -d '='`
DAT=`date "+%Y-%m-%d"`
GHCVER=`ghc --numeric-version`

HOM="${PWD}"
if [[ "$OSTYPE" == "darwin"* ]]; then
    # MacOS
    export AGDA_BIN=${HOM}/dist-${VER}-ghc-${GHCVER}/build/Agda/agda
    MAKE=gmake
else
    # Linux
    export AGDA_BIN=${HOM}/dist-${VER}-ghc-${GHCVER}/build/agda/agda
    MAKE=make
fi
export AGDA_TESTS=${HOM}/dist-${VER}-ghc-${GHCVER}/build/agda-tests/agda-tests

echo ""
echo "GHC_ENVIRONMENT: ${GHC_ENVIRONMENT}"
echo "AGDA_bin:   ${AGDA_BIN}"
echo "AGDA_TESTS: ${AGDA_TESTS}"
echo "CABAL_OPTS: ${CABAL_OPTS}"
echo ""

# Remove the leftovers from previous (successful) installs
# that may interfere with this build
find ~/.cabal/lib -name '*[Aa]gda*' -print -exec rm -rf {} \;
rm -f ~/.cabal/bin/AllNonAsciiChars ~/.cabal/bin/GenerateEverything

# Remove potentially stale "fix-whitespaces", as it's quicker to rebuild
# than to figure if it's built with the correct GHC and such
rm -rf ${HOM}/src/fix-whitespace/dist/build

# Remove stale size-solver from the past
rm -rf ${HOM}/src/size-solver/dist*

${MAKE} clean || true

${MAKE} install 2>&1 | tee make-out-${DAT}.txt
if [ $? != 0 ]; then
	echo "Agda-${VER} build failed!"
	exit 1
fi

${MAKE} bugs 2>&1 | tee make-bugs-${DAT}.txt
${MAKE} bugs 2>&1 | tee make-bugs-${DAT}.txt
time ${MAKE} test 2>&1 | tee make-test-${DAT}.txt 
if [ $? != 0 ]; then
        echo "Agda-${VER} tests failed!"
        exit 1
fi

${MAKE} user-manual-pdf 2>&1 | tee make-pdf-${DAT}.txt

DATE_END="`date`"
echo ""
echo "Start: ${DATE_START}"
echo "End:   ${DATE_END}"

#

@mouse07410
Copy link

Note that once you get through this issue (e.g., by adopting the above script), you'll have to apply the workarounds from #5528 in order for your tests to actually run and pass.

andreasabel added a commit that referenced this issue Aug 26, 2021
Reorganized into

    LaTeXAndHTML
    - HTML
    - LaTeX
    - QuickLaTeX

rather than having LaTeXAndHTML being the union of the three subgroup
next to them.

This is removing duplicates from the TestTree, useful when running
simply the root (`all` tests).
@andreasabel
Copy link
Member

agda-tests is only for running the internal test suite, i.e., QuickCheck tests. The other tests are run, as you correctly tried, via make test.

Er, this was many years ago, before @phile314 integrated other parts of the test suite into agda-tests. :$

I started working on having cabal test run parts of the test suite. I think it would make sense that this only runs a small fraction, just to see whether Agda is operational. Could be as little as type-checking a "hello world" program or the like...

andreasabel added a commit that referenced this issue Aug 26, 2021
'cabal test' will run only the tests defined by 'agda-tests'
andreasabel added a commit that referenced this issue Aug 26, 2021
'cabal test' will run only the tests defined by 'agda-tests'
andreasabel added a commit that referenced this issue Aug 26, 2021
'cabal test' will run only the tests defined by 'agda-tests'
andreasabel added a commit that referenced this issue Aug 26, 2021
'cabal test' will run only the tests defined by 'agda-tests'
andreasabel added a commit that referenced this issue Aug 26, 2021
'cabal test' will run only the tests defined by 'agda-tests'
@mouse07410
Copy link

I'd say, as long as the entire build and test-run works with Cabal, without the need to use Stack - it's not crucial whether make is involved or not. make test is simple enough - I wouldn't kill myself over trying to port it to cabal test.

@andreasabel
Copy link
Member

Yeah, maybe a standalone cabal test isn't possible due to haskell/cabal#7577 (comment).
Maybe cabal install --run-tests can be made to work, but this isn't a good developer option, as cabal install rebuilds from scratch, see haskell/cabal#6919. But actually, cabal install --run-tests doesn't work either, see haskell/cabal#7267.

andreasabel added a commit that referenced this issue Aug 27, 2021
An attempt to get `cabal test` to run after *installing* Agda rather
than just building it.
andreasabel added a commit that referenced this issue Aug 27, 2021
An attempt to get `cabal test` to run after *installing* Agda rather
than just building it.
andreasabel added a commit that referenced this issue Aug 27, 2021
Mainly for CI, so that we do not have to install LaTeX.
andreasabel added a commit that referenced this issue Aug 28, 2021
Do not work out of the box, need installation of the stdlib (for
`Everything.agda`).
andreasabel added a commit that referenced this issue Aug 28, 2021
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.
andreasabel added a commit that referenced this issue Aug 28, 2021
The testsuite fails but does not display diffs.
tasty-silver might not yet be portable, see

  phile314/tasty-silver#16
@andreasabel andreasabel self-assigned this Aug 28, 2021
@andreasabel andreasabel added this to the 2.6.2.1 milestone Aug 28, 2021
@andreasabel
Copy link
Member

andreasabel commented Aug 28, 2021

In PR #5536 I set up a CI (ubuntu, macOS) that runs cabal test after cabal install.
Atm, too much of the testsuite is included to have it serve as a simple check that Agda is operational. However, the technology is in place now, and if there is interest, we can design a sensible subset of the testsuite to be run with cabal test.

A flaw in the ointment is that cabal {v1|v2}-install Agda --run-tests will not run the tests. However, a small testsuite could be included still; it could at least be run by stack.

@andreasabel andreasabel added the cabal Build problems specifically related to cabal-install label Aug 28, 2021
andreasabel added a commit that referenced this issue Aug 28, 2021
Correct reference is `v1-install` in `cabal v1-install --run-tests`.
@mouse07410
Copy link

As I said earlier, I see a lot of value in being able to build using Cabal without Stack (just like it is important to be able to build using Stack without Cabal). I also think that switching to cabal v2-install would be a huge advantage over the current cabal v1-install.

But I see little benefit in replacing make test with cabal test or cabal install --run-tests.

make (already) does a good enough job, as far as I'm concerned, and I suspect many users would concur.

@andreasabel
Copy link
Member

@mouse07410 wrote:

switching to cabal v2-install

The new CI (cabal-test) in this PR ensures that cabal v2-install and cabal v2-test succeed without build errors (such as you experience). The existing Build (cabal) workflow already tested cabal v2-build.

Atm, we cannot fully switch the Makefile to v2 since e.g. the type-check goal does not work sensibly with v2-cabal (see haskell/cabal#1176).

@mouse07410
Copy link

Atm, we cannot fully switch the Makefile to v2 since . . .

Understood. This was not intended as a criticism - you guys are doing good IMHO! - but as an attempt to "help" with prioritization of efforts.

andreasabel added a commit that referenced this issue Sep 2, 2021
* [ 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
andreasabel added a commit that referenced this issue Nov 17, 2021
Reorganized into

    LaTeXAndHTML
    - HTML
    - LaTeX
    - QuickLaTeX

rather than having LaTeXAndHTML being the union of the three subgroup
next to them.

This is removing duplicates from the TestTree, useful when running
simply the root (`all` tests).
andreasabel added a commit that referenced this issue Nov 17, 2021
* [ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal Build problems specifically related to cabal-install infra: test suite Issues relating to the test suite (not in changelog) type: enhancement Issues and pull requests about possible improvements
Projects
Development

Successfully merging a pull request may close this issue.

4 participants