tasty-leancheck 0.0.1 → 0.0.2
raw patch · 16 files changed
+345/−176 lines, 16 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- .github/workflows/build.yml +122/−0
- .gitignore +2/−0
- .travis.yml +0/−65
- Makefile +8/−6
- README.md +8/−8
- mk/depend.mk +11/−8
- mk/ghcdeps +2/−1
- mk/haddock-i +20/−8
- mk/haskell.mk +35/−6
- mk/install-on +33/−0
- src/Test/Tasty/LeanCheck.hs +12/−0
- tasty-leancheck.cabal +13/−7
- test/sdist +40/−0
- test/test.hs +39/−0
- tests/test-sdist +0/−28
- tests/test.hs +0/−39
+ .github/workflows/build.yml view
@@ -0,0 +1,122 @@+# Builds and tests this Haskell project on "GitHub Actions"+#+# 2021 Rudy Matela+#+# some docs: https://github.com/haskell/actions/tree/main/setup+name: build+on: [push]+jobs:+ build-and-test:+ runs-on: ubuntu-latest+ steps:++ - name: Cache ~/.cabal/packages+ uses: actions/cache@v2+ with:+ path: ~/.cabal/packages+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-packages-++ - name: Cache ~/.cabal and ~/.ghc+ uses: actions/cache@v2+ with:+ path: |+ ~/.cabal+ !~/.cabal/packages+ ~/.ghc+ key: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-ghc-latest-++ - run: du -hd3 ~/.cabal ~/.ghc || true++ - run: haddock --version || sudo apt-get install ghc-haddock+ - run: ghc --version+ - run: cabal --version++ - name: Check out repository+ uses: actions/checkout@v2++ - run: cabal update+ - run: make install-dependencies++ - run: make+ - run: make test+ - run: make haddock+ - run: make test-sdist+ - run: make test-via-cabal+++ test-with-ghc:+ strategy:+ matrix:+ ghc:+ - '9.0'+ - '8.10'+ - '8.8'+ - '8.6'+ - '8.4'+ - '8.2'+ - '8.0'+ - '7.10'+ - '7.8'+ runs-on: ubuntu-latest+ needs: build-and-test+ container: haskell:${{ matrix.ghc }}+ steps:+ - name: Cache ~/.cabal/packages+ uses: actions/cache@v2+ with:+ path: ~/.cabal/packages+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-packages-++ - name: Cache ~/.cabal and ~/.ghc+ uses: actions/cache@v2+ with:+ path: |+ ~/.cabal+ !~/.cabal/packages+ ~/.ghc+ key: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-++ - run: du -hd3 ~/.cabal ~/.ghc || true++ - run: make --version || rm /etc/apt/sources.list.d/*.list # faster update+ - run: make --version || apt-get update+ - run: make --version || apt-get install make++ - run: ghc --version+ - run: cabal --version++ - name: Check out repository+ uses: actions/checkout@v2++ - run: cabal update+ - run: make install-dependencies++ - run: make+ - run: make test+ - run: make haddock+ - run: make test-sdist+ - run: make test-via-cabal++ test-with-stack:+ runs-on: ubuntu-latest+ needs: build-and-test+ steps:+ - name: Setup Haskell's GHC and Cabal as required by current Stackage LTS+ uses: haskell/actions/setup@v1+ with: # lts-17.9+ ghc-version: '8.10.4'+ cabal-version: '3.2'++ - uses: actions/cache@v2+ with:+ path: ~/.stack+ key: v1-${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}+ restore-keys: v1-${{ runner.os }}-stack-++ - name: Check out repository+ uses: actions/checkout@v2+ - run: make test-via-stack
.gitignore view
@@ -3,6 +3,7 @@ .stack-work idx/ dist/+dist-newstyle log/ doc/ *.swp@@ -21,4 +22,5 @@ doc/*.gif mk/toplibs eg/minimal+test/test README.html
− .travis.yml
@@ -1,65 +0,0 @@-# .travis.yml file for tasty-leancheck-#-# Copyright: (c) 2017-2018 Rudy Matela-# License: 3-Clause BSD (see the file LICENSE)-# Maintainer: Rudy Matela <rudy@matela.com.br>--language: c # not really--notifications:- email:- on_failure: change--sudo: false--cache:- directories:- - $HOME/.ghc- - $HOME/.cabal- - $HOME/.stack--before_install:-- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH-- ghc --version-- cabal --version-- haddock --version-- rm -f ~/.cabal/config && cabal update-# Download and unpack the stack executable-# "Once Travis whitelists the stack.dev files," simply include stack in the-# addons section. -- https://docs.haskellstack.org/en/stable/travis_ci/-- mkdir -p ~/.local/bin-- export PATH=$HOME/.local/bin:$PATH-- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'-- stack config set system-ghc --global true-- stack --version-- cabal install tasty leancheck--script:-- make && make test && make haddock-- make test-sdist-- cabal test --ghc-option=-O0-- stack $STACKR --no-terminal --skip-ghc-check test --ghc-options=-O0--matrix:- allow_failures:- - ghc: 'head'- include:- - ghc: 'head'- env: GHCVER=head CABALVER=head- addons: {apt: {packages: [ghc-head, cabal-install-head], sources: hvr-ghc}}- - ghc: '8.4'- env: GHCVER=8.4.3 CABALVER=2.2- addons: {apt: {packages: [ghc-8.4.3, cabal-install-2.2], sources: hvr-ghc}}- - ghc: '8.2'- env: GHCVER=8.2.2 CABALVER=2.0 STACKR=--resolver=lts-11- addons: {apt: {packages: [ghc-8.2.2, cabal-install-2.0], sources: hvr-ghc}}- - ghc: '8.0'- env: GHCVER=8.0.2 CABALVER=1.24 STACKR=--resolver=lts-11- addons: {apt: {packages: [ghc-8.0.2, cabal-install-1.24], sources: hvr-ghc}}- - ghc: '7.10'- env: GHCVER=7.10.3 CABALVER=1.22- addons: {apt: {packages: [ghc-7.10.3, cabal-install-1.22], sources: hvr-ghc}}- script:- - make && make test && make haddock- - make test-sdist- - cabal test --ghc-option=-O0
Makefile view
@@ -4,13 +4,13 @@ # License: 3-Clause BSD (see the file LICENSE) # Maintainer: Rudy Matela <rudy@matela.com.br> TESTS = \- tests/test+ test/test EGS = \ eg/minimal BENCHS = GHCIMPORTDIRS = src GHCFLAGS = -O2 $(shell grep -q "Arch Linux" /etc/lsb-release && echo -dynamic)-HADDOCKFLAGS = --no-print-missing-docs \+HADDOCKFLAGS = \ $(shell grep -q "Arch Linux" /etc/lsb-release && echo --optghc=-dynamic) all: mk/toplibs@@ -31,13 +31,15 @@ @echo "use \`cabal install' instead" test-sdist:- ./tests/test-sdist+ ./test/sdist test-via-cabal:- cabal test+ cabal configure --enable-tests --enable-benchmarks --ghc-options="$(GHCFLAGS) -O0"+ cabal build+ cabal test test test-via-stack:- stack test+ stack test tasty-leancheck:test:test --ghc-options="$(GHCFLAGS) -O0" --system-ghc --no-install-ghc --no-terminal test-via-everything: test test-via-cabal test-via-stack @@ -72,7 +74,7 @@ # NOTE: (very hacky!) the following target allows parallel compilation (-jN) of # eg and tests programs so long as they don't share dependencies _not_ stored-# in src/ and tests/. Runnable binaries should depend on mk/toplibs instead of+# in src/ and test/. Runnable binaries should depend on mk/toplibs instead of # actual Haskell source files mk/toplibs: mk/Toplibs.o touch mk/toplibs
README.md view
@@ -94,19 +94,19 @@ [LeanCheck's Haddock documentation]: https://hackage.haskell.org/package/leancheck/docs/Test-LeanCheck.html [Tasty's Haddock documentation]: https://hackage.haskell.org/package/tasty/docs/Test-Tasty.html [LeanCheck's README]: https://github.com/rudymatela/leancheck#readme-[Tasty's README]: https://github.com/rudymatela/tasty#readme+[Tasty's README]: https://github.com/feuerbach/tasty#readme [tutorial on property-based testing with LeanCheck]: https://github.com/rudymatela/leancheck/blob/master/doc/tutorial.md [Tasty's official example]: https://github.com/feuerbach/tasty#example [Tasty]: https://github.com/feuerbach/tasty [LeanCheck]: https://github.com/rudymatela/leancheck -[build-status]: https://travis-ci.org/rudymatela/tasty-leancheck.svg?branch=master-[build-log]: https://travis-ci.org/rudymatela/tasty-leancheck+[build-log]: https://github.com/rudymatela/tasty-leancheck/actions/workflows/build.yml+[build-status]: https://github.com/rudymatela/tasty-leancheck/actions/workflows/build.yml/badge.svg [hackage-version]: https://img.shields.io/hackage/v/tasty-leancheck.svg [tasty-leancheck-on-hackage]: https://hackage.haskell.org/package/tasty-leancheck-[stackage-lts-badge]: http://stackage.org/package/tasty-leancheck/badge/lts-[stackage-nightly-badge]: http://stackage.org/package/tasty-leancheck/badge/nightly-[tasty-leancheck-on-stackage]: http://stackage.org/package/tasty-leancheck-[tasty-leancheck-on-stackage-lts]: http://stackage.org/lts/package/tasty-leancheck-[tasty-leancheck-on-stackage-nightly]: http://stackage.org/nightly/package/tasty-leancheck+[stackage-lts-badge]: https://stackage.org/package/tasty-leancheck/badge/lts+[stackage-nightly-badge]: https://stackage.org/package/tasty-leancheck/badge/nightly+[tasty-leancheck-on-stackage]: https://stackage.org/package/tasty-leancheck+[tasty-leancheck-on-stackage-lts]: https://stackage.org/lts/package/tasty-leancheck+[tasty-leancheck-on-stackage-nightly]: https://stackage.org/nightly/package/tasty-leancheck
mk/depend.mk view
@@ -1,19 +1,22 @@+eg/minimal: \+ eg/minimal.hs \+ mk/toplibs+eg/minimal.o: \+ src/Test/Tasty/LeanCheck.hs \+ eg/minimal.hs mk/All.o: \ src/Test/Tasty/LeanCheck.hs \ mk/All.hs mk/Toplibs.o: \ src/Test/Tasty/LeanCheck.hs \ mk/Toplibs.hs-Setup.o: \- Setup.hs-Setup: \- Setup.hs \+src/Test/Tasty/LeanCheck: \ mk/toplibs src/Test/Tasty/LeanCheck.o: \ src/Test/Tasty/LeanCheck.hs-tests/test.o: \- tests/test.hs \+test/test.o: \+ test/test.hs \ src/Test/Tasty/LeanCheck.hs-tests/test: \- tests/test.hs \+test/test: \+ test/test.hs \ mk/toplibs
mk/ghcdeps view
@@ -2,7 +2,7 @@ # # ghcdeps: generate Haskell make dependencies for compiling with GHC. #-# Copyright (c) 2015-2018 Rudy Matela.+# Copyright (c) 2015-2021 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # From a list of files provided on standard input,@@ -46,4 +46,5 @@ rm -f tmp.mk done | sort |+grep -v "^Loaded package environment from " | sed -e 's, *, \\\n ,g'
mk/haddock-i view
@@ -2,7 +2,7 @@ # # haddock-i: list haddock's -i parameters. #-# Copyright (c) 2015-2018 Rudy Matela.+# Copyright (c) 2015-2021 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # $ haddock-i <package1> <package2> ... <packageN>@@ -11,14 +11,26 @@ # documentation installed on your system, so you can: # # $ haddock-i base template-haskell | xargs haddock <files>-errxit() {+err() { echo "$@" > /dev/stderr+}++errxit() {+ err "$@" exit 1 } -for pkg in "$@"; do- ghc-pkg field $pkg haddock-html,haddock-interfaces ||- errxit "error: haddock-i: cannot find package $pkg (ghc-pkg)"-done |-sed "s/.*: //" |-sed "N;s/\n/,/;s/^/-i/"+iface-for() {+ ghc-pkg field $1 haddock-interfaces | sort -rV | head -1 | sed "s/.*: //"+}++html-for() {+ ghc-pkg field $1 haddock-html | sort -rV | head -1 | sed "s/.*: //"+}++for pkg in "$@"+do+ iface=$(iface-for $pkg)+ html=$(html-for $pkg)+ [ -d "$html" -a -f "$iface" ] && echo "-i$html,$iface" || err "haddock-i: warning: could not find interface file for $pkg"+done
mk/haskell.mk view
@@ -1,6 +1,6 @@ # Implicit rules for compiling Haskell code. #-# Copyright (c) 2015-2018 Rudy Matela.+# Copyright (c) 2015-2021 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # You can optionally configure the "Configuration variables" below in your main@@ -20,6 +20,8 @@ GHCFLAGS ?= GHC ?= ghc GHCCMD = $(GHC) -i$(GHCIMPORTDIRS) $(GHCFLAGS)+HADDOCK ?= haddock+CABAL_INSTALL = $(shell cabal --version | grep -q "version [0-2]\." && echo 'cabal install' || echo 'cabal v1-install') # Hugs Parameters HUGSIMPORTDIRS ?= "/usr/lib/hugs/packages/*"@@ -38,14 +40,20 @@ # ALL_HSS: all Haskell files # You can override ALL/LIB_HSS in your main Makefile LIST_LIB_HSS ?= find src -name "*.hs"-LIST_ALL_HSS ?= find \( -path "./dist" -o -path "./.stack-work" \) -prune \+LIST_ALL_HSS ?= find \( -path "./dist*" -o -path "./.stack-work" -o -path "./Setup.hs" \) -prune \ -o -name "*.*hs" -print LIB_HSS ?= $(shell $(LIST_LIB_HSS)) ALL_HSS ?= $(shell $(LIST_ALL_HSS)) +LIB_DEPS ?= base+ALL_DEPS ?= $(LIB_DEPS)+INSTALL_DEPS ?=+ PKGNAME = $(shell cat *.cabal | grep "^name:" | sed -e "s/name: *//") +HADDOCK_HAS = haddock --help | grep -q -- + # Implicit rules %.hi %.o: %.hs $(GHCCMD) $< && touch $@@@ -67,7 +75,8 @@ # Cleaning rule (add as a clean dependency)-.PHONY: clean-hi-o+clean-hs: clean-hi-o clean-haddock clean-cabal clean-stack+ clean-hi-o: find $(ALL_HSS) | sed -e 's/hs$$/o/' | xargs rm -f find $(ALL_HSS) | sed -e 's/hs$$/hi/' | xargs rm -f@@ -80,11 +89,14 @@ depend: find $(ALL_HSS) | ./mk/ghcdeps -i$(GHCIMPORTDIRS) $(GHCFLAGS) > $(DEPMK) +install-dependencies:+ $(CABAL_INSTALL) $(INSTALL_DEPS)+ # haddock rules haddock: doc/index.html clean-haddock:- rm -f doc/*.{html,css,js,png,gif,json} README.html+ rm -f doc/*.{html,css,js,png,gif,json} doc/src/* README.html upload-haddock: @echo "use \`cabal upload -d' instead"@@ -93,9 +105,20 @@ @echo "(on Arch Linux, use: cabal haddock --for-hackage --haddock-options=--optghc=-dynamic)" doc/index.html: $(LIB_HSS)- ./mk/haddock-i base template-haskell | xargs \- haddock --html -odoc $(LIB_HSS) $(HADDOCKFLAGS) --title=$(PKGNAME)+ ./mk/haddock-i $(LIB_DEPS) | xargs \+ $(HADDOCK) --html -odoc $(LIB_HSS) \+ --title=$(PKGNAME) \+ $(shell $(HADDOCK_HAS) --package-name && echo "--package-name=$(PKGNAME)" ) \+ $(shell $(HADDOCK_HAS) --hyperlinked-source && echo "--hyperlinked-source" ) \+ $(shell $(HADDOCK_HAS) --no-print-missing-docs && echo --no-print-missing-docs ) \+ $(HADDOCKFLAGS) +clean-cabal:+ rm -rf dist/ dist-newstyle/ cabal.project.local cabal.project.local~++clean-stack:+ rm -rf .stack-work/ stack.yaml.lock+ # lists all Haskell source files list-all-hss: @find $(ALL_HSS)@@ -103,6 +126,12 @@ # lists library Haskell source files list-lib-hss: @find $(LIB_HSS)++bootstrap-haskell-mk:+ @[ -d "$(DEST)" ] || (echo -e "error: no destination found\nusage: \`make bootstrap-haskell-mk DEST=path/to/prj'"; exit 1)+ mkdir -p mk+ cp mk/{haskell.mk,ghcdeps,haddock-i} $(DEST)/mk+ touch $(DEST)/mk/depend.mk show-pkgname: @echo $(PKGNAME)
+ mk/install-on view
@@ -0,0 +1,33 @@+#!/bin/bash+#+# mk/install-on: install or updates the mk folder on a Haskell project+#+# Copyright (c) 2019-2021 Rudy Matela.+# Distributed under the 3-Clause BSD licence.+#+# usage: ./mk/install-on path/to/project+#+# This script assumes that:+#+# * tests are stored in a "test/" folder+# * sources are stored in a "src/" folder+set -e++errxit() {+ echo "$@" > /dev/stderr+ exit 1+}++src=`dirname $0`/..+dst="$1"++[ -n "$dst" ] || errxit "destination folder not provided"++mkdir -p $dst/mk+mkdir -p $dst/test++cp $src/mk/ghcdeps $dst/mk/ghcdeps+cp $src/mk/haddock-i $dst/mk/haddock-i+cp $src/mk/haskell.mk $dst/mk/haskell.mk+cp $src/mk/install-on $dst/mk/install-on+cp $src/test/sdist $dst/test/sdist
src/Test/Tasty/LeanCheck.hs view
@@ -47,6 +47,10 @@ -- Please see the documentation of -- "Test.LeanCheck" and Tasty -- for more details.+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ == 708+{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-}+#endif module Test.Tasty.LeanCheck ( testProperty , LeanCheckTests (..)@@ -58,7 +62,15 @@ import Test.Tasty.Options import Test.LeanCheck import Data.Proxy+import Control.Applicative (pure) import Control.Exception (SomeException, catch, evaluate)+#if __GLASGOW_HASKELL__ == 708+import Data.Typeable (Typeable)++deriving instance Typeable Results+deriving instance Typeable Result+deriving instance Typeable LeanCheckTests+#endif newtype Results = Results [([String],Bool)]
tasty-leancheck.cabal view
@@ -1,12 +1,12 @@ -- Cabal file for tasty-leancheck name: tasty-leancheck-version: 0.0.1+version: 0.0.2 synopsis: LeanCheck support for the Tasty test framework. description: LeanCheck support for the Tasty test framework. . This package can be used to incorporate LeanCheck tests into Tasty test- suites by means of the @Test.Tasty.LeanCheck.testProperty@ function.+ suites. . Please see the Haddock documentation and README for more details. @@ -30,13 +30,19 @@ , mk/haddock-i , mk/All.hs , mk/Toplibs.hs+ , mk/install-on , stack.yaml- , tests/test-sdist- , .travis.yml-tested-with: GHC==8.4+ , test/sdist+ , .github/workflows/build.yml+tested-with: GHC==9.0+ , GHC==8.10+ , GHC==8.8+ , GHC==8.6+ , GHC==8.4 , GHC==8.2 , GHC==8.0 , GHC==7.10+ , GHC==7.8 source-repository head@@ -46,7 +52,7 @@ source-repository this type: git location: https://github.com/rudymatela/tasty-leancheck- tag: v0.0.1+ tag: v0.0.2 library exposed-modules: Test.Tasty.LeanCheck@@ -57,6 +63,6 @@ test-suite test type: exitcode-stdio-1.0 main-is: test.hs- hs-source-dirs: tests+ hs-source-dirs: test build-depends: base >= 4 && < 5, tasty, leancheck, tasty-leancheck default-language: Haskell2010
+ test/sdist view
@@ -0,0 +1,40 @@+#!/bin/bash+#+# test/sdist: tests the package generated by "cabal sdist".+#+# Copyright (c) 2015-2021 Rudy Matela.+# Distributed under the 3-Clause BSD licence.++set -xe++export LC_ALL=C # consistent sort++pkgver=` cat *.cabal | grep "^version:" | sed -e "s/version: *//"`+pkgname=`cat *.cabal | grep "^name:" | sed -e "s/name: *//"`+pkgbase=$pkgname-$pkgver++cabal sdist++# Try to find the package generated by cabal.+pkg=`find dist* -name $pkgbase.tar.gz`+[ -f "$pkg" ]+# If the script fails here, either:+# * no package was generated+# * there are packages in both dist and dist-newstyle folders.++tmp=`mktemp -d /tmp/test-sdist-XXXXXXXXXX`++# Test if our file is compatible with case-insensitive filesystems.+tar -tf $pkg | sort --ignore-case > $tmp/ls-cabal-i+tar -tf $pkg | sort --ignore-case --unique > $tmp/ls-cabal-iu+diff -rud $tmp/ls-cabal-i $tmp/ls-cabal-iu++if [ -d .git ]+then+ # Test if files included by cabal are the same as files tracked in git.+ git ls-files | sort > $tmp/ls-git+ tar -tf $pkg | grep -v "/$" | sed -e "s,$pkgbase/,," | sort > $tmp/ls-cabal+ diff -rud $tmp/ls-git $tmp/ls-cabal+fi++rm -r $tmp
+ test/test.hs view
@@ -0,0 +1,39 @@+-- Copyright (c) 2018 Rudy Matela.+-- Distributed under the 3-Clause BSD licence (see the file LICENSE).+{-# LANGUAGE CPP #-}+import Test.Tasty+import Test.Tasty.LeanCheck as LC++import Data.List (sort)++main :: IO ()+main = defaultMain tests++tests :: TestTree+tests = testGroup "Tests (checked by LeanCheck)" [passing]+-- tests = testGroup "Tests (checked by LeanCheck)" [passing,failing,erroring]++-- tests that pass+passing :: TestTree+passing = testGroup "Passing tests"+ [ LC.testProperty "sort . sort == sort" $+ \xs -> sort (sort xs :: [Int]) == sort xs+ , LC.testProperty "Fermat's little theorem" $+ \x -> ((x :: Integer)^7 - x) `mod` 7 == 0+ , LC.testProperty "divMod" $+ \x y -> y /= 0 ==> y * (x `div` y) + x `mod` y == (x :: Int)+ ]++-- tests that fail (and should)+failing :: TestTree+failing = testGroup "Failing tests"+ [ LC.testProperty "Fermat's last theorem" $+ \x y z n -> (n :: Integer) >= 3 ==> x^n + y^n /= (z^n :: Integer)+ ]++-- tests that err (and should)+erroring :: TestTree+erroring = testGroup "Erroring tests"+ [ LC.testProperty "divMod (unguarded)" $+ \x y -> y * (x `div` y) + x `mod` y == (x :: Int)+ ]
− tests/test-sdist
@@ -1,28 +0,0 @@-#!/bin/bash-#-# test-sdist: tests the package generated by "cabal sdist".-#-# Copyright (c) 2015-2018 Rudy Matela.-# Distributed under the 3-Clause BSD licence.-pkgver=` cat *.cabal | grep "^version:" | sed -e "s/version: *//"`-pkgname=`cat *.cabal | grep "^name:" | sed -e "s/name: *//"`-pkg=$pkgname-$pkgver-set -x-cabal sdist &&-cd dist &&-if [ -d ../.git ]-then- # on git repo, test if files are the same- git -C .. ls-files | sort > ls-git &&- tar -tf $pkg.tar.gz | grep -v "/$" | sed -e "s,$pkg/,," | sort > ls-cabal &&- diff -rud ls-git ls-cabal &&- rm -f ls-git ls-cabal-else- # outside of git repo, test build- rm -rf $pkg/ &&- tar -xzf $pkg.tar.gz &&- cd $pkg/ &&- cabal configure --enable-tests --enable-benchmarks &&- cabal build &&- cabal test-fi
− tests/test.hs
@@ -1,39 +0,0 @@--- Copyright (c) 2018 Rudy Matela.--- Distributed under the 3-Clause BSD licence (see the file LICENSE).-{-# LANGUAGE CPP #-}-import Test.Tasty-import Test.Tasty.LeanCheck as LC--import Data.List (sort)--main :: IO ()-main = defaultMain tests--tests :: TestTree-tests = testGroup "Tests (checked by LeanCheck)" [passing]--- tests = testGroup "Tests (checked by LeanCheck)" [passing,failing,erroring]---- tests that pass-passing :: TestTree-passing = testGroup "Passing tests"- [ LC.testProperty "sort . sort == sort" $- \xs -> sort (sort xs :: [Int]) == sort xs- , LC.testProperty "Fermat's little theorem" $- \x -> ((x :: Integer)^7 - x) `mod` 7 == 0- , LC.testProperty "divMod" $- \x y -> y /= 0 ==> y * (x `div` y) + x `mod` y == (x :: Int)- ]---- tests that fail (and should)-failing :: TestTree-failing = testGroup "Failing tests"- [ LC.testProperty "Fermat's last theorem" $- \x y z n -> (n :: Integer) >= 3 ==> x^n + y^n /= (z^n :: Integer)- ]---- tests that err (and should)-erroring :: TestTree-erroring = testGroup "Erroring tests"- [ LC.testProperty "divMod (unguarded)" $- \x y -> y * (x `div` y) + x `mod` y == (x :: Int)- ]