on master help sign in
Hook the new test infrastructure to cabal

- A test hook in `Setup.hs` allows using the new test infrastructure with `cabal test`. Without it, cabal couldn't find the idris libraries. - Make rules related to testing now call `cabal test`. - The `test_timed` rule is removed because timings are given by default - We introduce the `test_update` rule to update the golden files - We introduce the `test_clean` rule to remove artifacts created when running the test suite. This is far from perfect ; a careful `git clean -f` should remove whatever is left - The TEST-JOBS variable specifies the number of parallel jobs to the test program. By default, it relies on the Haskell RTS to find an optimal number. Set to 1 to disable parallelism. - The TEST-ARGS variable can be used to pass arguments to the test program. - Travis CI uses the new infrasctructure. It uses `travis_wait` to prevent timeouts because cabal only prints the output when the test suite is done running.

commit5186d6ce3ef531fb5c3a100688d7590b4197e095 authorgpyh <yacine.hmito@gmail.com> dateWed 27 Jul 2016, 14:46 (10 years ago) parent54b94b9
4 files changed+53−10
.travis.yml+3−3 Makefile+17−5 Setup.hs+29 config.mk+4−2
.travis.yml+3−3
@@ -102,7 +102,7 @@ before_script:
102102script:
103103###
104104 - echo 'Configure...' && echo -en 'travis_fold:start:script.configure\\r'
105− - cabal configure -f FFI -f CI
105+ - cabal configure -f FFI -f CI --enable-tests
106106 - echo -en 'travis_fold:end:script.configure\\r'
107107###
108108 - echo 'Build...' && echo -en 'travis_fold:start:script.build\\r'
@@ -125,8 +125,8 @@ script:
125125###
126126 - echo 'Tests...' && echo -en 'travis_fold:start:script.tests\\r'
127127 - for test in $TESTS; do
128− echo "make -j2 $test";
129− make -j2 $test;
128+ echo "make TEST-JOBS=2 $test";
129+ travis_wait make TEST-JOBS=2 $test;
130130 done
131131 - echo -en 'travis_fold:end:script.tests\\r'
132132###
Makefile+17−5
@@ -1,10 +1,15 @@
1−.PHONY: build configure doc install linecount nodefault pinstall lib_clean relib fast test_c test lib_doc lib_doc_clean user_doc_html user_doc_pdf user_docs
1+.PHONY: build configure doc install linecount nodefault pinstall lib_clean relib fast test_js test_c test test_clean lib_doc lib_doc_clean user_doc_html user_doc_pdf user_docs
2+
3+ARGS=
4+TEST-JOBS=
5+TEST-ARGS=
26
37include config.mk
48-include custom.mk
59
610ifdef CI
711CABALFLAGS += -f CI
12+TEST-ARGS += --color always
813endif
914
1015install:
@@ -20,13 +25,20 @@ build: dist/setup-config
2025test: doc test_c
2126
2227test_c:
23− echo "test_c not supported"
28+ $(CABAL) test $(ARGS) --test-options \
29+ "$(TEST-ARGS) --rerun-update +RTS -N$(TEST-JOBS) -RTS"
2430
2531test_js:
26− echo "test_js not supported"
32+ $(CABAL) test $(ARGS) --test-options \
33+ "$(TEST-ARGS) --node --rerun-update +RTS -N$(TEST-JOBS) -RTS"
34+
35+test_update:
36+ $(CABAL) test $(ARGS) --test-options \
37+ "$(TEST-ARGS) --accept +RTS -N$(TEST-JOBS) -RTS"
2738
28−test_timed:
29− echo "test_timed not supported"
39+test_clean:
40+ rm -f test/*~
41+ rm -f test/*/output
3042
3143lib_clean:
3244 $(MAKE) -C libs IDRIS=../../dist/build/idris/idris RTS=../../dist/build/rts/libidris_rts clean
Setup.hs+29
@@ -263,6 +263,30 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
263263 makeInstall src target =
264264 make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
265265
266+-- -----------------------------------------------------------------------------
267+-- Test
268+
269+-- FIXME: We use the __GLASGOW_HASKELL__ macro because MIN_VERSION_cabal seems
270+-- to be broken !
271+
272+-- There are two "dataDir" in cabal, and they don't relate to each other.
273+-- When fetching modules, idris uses the second path (in the pkg record),
274+-- which by default is the root folder of the project.
275+-- We want it to be the install directory where we put the idris libraries.
276+fixPkg pkg target = pkg { dataDir = target }
277+
278+-- The "Args" argument of the testHooks has been added in cabal 1.22.0,
279+-- and should therefore be ignored for prior versions.
280+#if __GLASGOW_HASKELL__ < 710
281+originalTestHook _ = testHook simpleUserHooks
282+#else
283+originalTestHook = testHook simpleUserHooks
284+#endif
285+
286+idrisTestHook args pkg local hooks flags = do
287+ let target = datadir $ L.absoluteInstallDirs pkg local NoCopyDest
288+ originalTestHook args (fixPkg pkg target) local hooks flags
289+
266290-- -----------------------------------------------------------------------------
267291-- Main
268292
@@ -281,4 +305,9 @@ main = defaultMainWithHooks $ simpleUserHooks
281305 NoCopyDest pkg local
282306 , preSDist = idrisPreSDist
283307 , postSDist = idrisPostSDist
308+#if __GLASGOW_HASKELL__ < 710
309+ , testHook = idrisTestHook ()
310+#else
311+ , testHook = idrisTestHook
312+#endif
284313 }
config.mk+4−2
@@ -14,9 +14,11 @@ CABAL :=cabal
1414# Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs
1515CFLAGS :=-O2 -Wall -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
1616
17−#CABALFLAGS :=
17+# CABALFLAGS :=
18+CABALFLAGS += --enable-tests
1819## Disable building of Effects
19−#CABALFLAGS :=-f NoEffects
20+#CABALFLAGS :=-f NoEffects $(CABALFLAGS)
21+
2022
2123ifneq (, $(findstring bsd, $(MACHINE)))
2224 GMP_INCLUDE_DIR :=