Skip to content

[ new ] golden testing framework #1518

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

Merged
merged 84 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
dbc1ad3
[ new ] System.Clock
gallais Jun 8, 2021
a0af28f
[ cleanup ] Thin System.Exit.Primitive's dependencies
gallais Jun 8, 2021
4296a0e
[ new ] various IO utility functions
gallais Jun 8, 2021
5f40d59
[ cleanup ] make lift′ available to everyone
gallais Jun 8, 2021
ff61450
[ more ] Exit code conversion function
gallais Jun 8, 2021
8b4e676
[ new ] System.Process
gallais Jun 8, 2021
e5f21ca
[ new ] tests for exit codes
gallais Jun 8, 2021
ac56119
[ new ] golden testing framework
gallais Jun 8, 2021
b653654
[ cosmetic ] nicer printing of timing
gallais Jun 9, 2021
2051198
[ new ] System.FilePath.Posix
gallais Jun 9, 2021
02c5e4f
[ new ] System.Directory
gallais Jun 9, 2021
a0e92be
[ new ] System.Directory.Tree
gallais Jun 9, 2021
6e6f3c7
[ fix ] missing files & missing unsafe declarations
gallais Jun 9, 2021
01a1b13
[ fix ] checking filepaths exist before opening
gallais Jun 9, 2021
c240c44
[ revert ] the addition of System.Directory.Tree
gallais Jun 10, 2021
e9999b2
[ more ] flipped IO monad combinators
gallais Jun 10, 2021
f2b83d1
[ new ] test suite for the stdlib
gallais Jun 10, 2021
d10c95b
[ test ] new test for showing rose trees
gallais Jun 10, 2021
eeb7093
[ test ] new test showing nums
gallais Jun 10, 2021
fa7b6aa
[ cosmetic ] change package names
gallais Jun 10, 2021
9df96f0
[ fix ] exit codes can be negative
gallais Jun 10, 2021
bee453c
[ caching ] use a shared `--compile-dir` for all tests
gallais Jun 10, 2021
9467206
[ fix ] no need for sized types in the num case
gallais Jun 10, 2021
6067858
[ fix ] better matches!
gallais Jun 11, 2021
4bb0ba7
[ fix ] caching mechanism
gallais Jun 11, 2021
8688aae
[ test ] for regular expression matcher!
gallais Jun 11, 2021
8b25aff
[ fix ] even better matches!
gallais Jun 11, 2021
79eb43c
[ fix ] better regex example & logging for building phase
gallais Jun 11, 2021
f47971e
[ cleanup ] drop the numeric suffixes
gallais Jun 11, 2021
e634081
[ admin ] ignore log files
gallais Jun 11, 2021
c6be7fc
[ test ] for reflection machinery
gallais Jun 11, 2021
4139438
[ cleanup ] remove more numeric suffixes
gallais Jun 11, 2021
934d9b3
[ test ] for tabular primitives
gallais Jun 11, 2021
936a4be
[ test ] for printf
gallais Jun 11, 2021
e861b3e
[ test ] for sytem environment
gallais Jun 11, 2021
26d4296
[ more ] dependencies to force more module compilations :D
gallais Jun 11, 2021
9a6ca32
[ cosmetic ] drop the 100th of seconds
gallais Jun 11, 2021
ac461f8
[ test ] for zipper & sort
gallais Jun 11, 2021
530525a
[ more ] chaotic nats
gallais Jun 11, 2021
f623406
[ test ] for Trie (and AVL trees too)
gallais Jun 11, 2021
56a2c91
[ test ] for colist
gallais Jun 11, 2021
241bf54
[ test ] more dependencies for the colist example
gallais Jun 11, 2021
0d60499
[ ci ] run the testsuite
gallais Jun 11, 2021
678876b
[ fix ] ignore missing runtests
gallais Jun 11, 2021
bd2ae47
Merge branch 'master' into testing
gallais Jun 11, 2021
a7ed768
[ ci ] run golden tests before the HTML generation
gallais Jun 11, 2021
7035025
[ ci ] explicitly pass the PATH & add clock dependency
gallais Jun 11, 2021
c85d922
[ ci ] install dependencies first
gallais Jun 12, 2021
0f45017
make ->
gallais Jun 12, 2021
74a889a
try v1-install
gallais Jun 13, 2021
a3925c2
drop overwrite with v1-install
gallais Jun 13, 2021
33bff62
[ ci ] trying "install --lib"
gallais Jun 14, 2021
c99f59a
[ revert ] bad changes
gallais Jun 17, 2021
870913a
[ cleanup ] System.Clock
gallais Jun 17, 2021
d4c246c
[ format ] put `public' first
gallais Jun 17, 2021
150e4e1
[ doc ] explaining the use of coerce
gallais Jun 17, 2021
b3f36f8
[ cleanup ] whitespace in System.Process.Primitive
gallais Jun 17, 2021
cc42689
[ cleanup ] remove ASCII arrows
gallais Jun 17, 2021
0accb4d
[ doc ] change name to match the record field
gallais Jun 17, 2021
bee04ff
[ cosmetic ] indent nested with
gallais Jun 17, 2021
26f2917
[ ci ] move golden test after typechecking test
gallais Jun 17, 2021
d8adaf0
[ ci ] support for INTERACTIVE
gallais Jun 18, 2021
ebc257e
[ fix ] make test more robust by sorting directory names
gallais Jun 18, 2021
610c447
[ fix ] bug in the option parser
gallais Jun 18, 2021
7b70015
[ new ] test for pretty printer
gallais Jun 18, 2021
de27986
Merge branch 'master' into testing
gallais Jun 18, 2021
4076ff1
[ fix ] update expected output
gallais Jun 18, 2021
da99cb9
[ fix ] Agda stdlib uses lowercase names for constructors
gallais Jun 19, 2021
de76a08
[ cleanup ] use Agda.Builtin.IO
gallais Jun 19, 2021
3a24887
[ new ] define and use ANSI escape codes
gallais Jun 19, 2021
c5eee77
[ cleanup ] spacing
gallais Jun 19, 2021
36a4f3f
[ more ] ANSI codes & test case for it!
gallais Jun 19, 2021
0859cf4
[ ci ] use 2.6.2 for integration
gallais Jun 20, 2021
c938e52
[ GNUmakefile ] Updated a comment.
asr Jun 19, 2021
7c049e5
[ .gitignore ] Added `.stack-work` directory.
asr Jun 19, 2021
bb562ed
Tested with GHC 8.10.5.
asr Jun 19, 2021
a35c9f2
[ ci ] GHC 8.10.5 is not supported yet when using `haskell-ci`.
asr Jun 19, 2021
2410cab
Fix CHANGELOG entry
MatthewDaggitt Jun 20, 2021
2cf869f
Add algebra morphism identity and composition constructions (#1502)
Taneb Jun 20, 2021
0fefd23
Setup admin-y things for next version
MatthewDaggitt Jun 20, 2021
fed2299
[ new ] add --no-colour flag
gallais Jun 20, 2021
74800f0
Merge branch 'master' into testing
gallais Jun 20, 2021
e6ca792
[ changelog ] document the changes
gallais Jun 20, 2021
7e44e3f
Merge branch 'master' into testing
MatthewDaggitt Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ jobs:
if [[ '${{ github.ref }}' == 'refs/heads/master' \
|| '${{ github.base_ref }}' == 'master' ]]; then
# Pick Agda version for master
echo "AGDA_COMMIT=tags/v2.6.1.3.20210524" >> $GITHUB_ENV;
echo "AGDA_COMMIT=tags/v2.6.2" >> $GITHUB_ENV;
echo "AGDA_HTML_DIR=html" >> $GITHUB_ENV
elif [[ '${{ github.ref }}' == 'refs/heads/experimental' \
|| '${{ github.base_ref }}' == 'experimental' ]]; then
# Pick Agda version for experimental
echo "AGDA_COMMIT=tags/v2.6.1.3.20210524" >> $GITHUB_ENV;
echo "AGDA_COMMIT=tags/v2.6.2" >> $GITHUB_ENV;
echo "AGDA_HTML_DIR=html/experimental" >> $GITHUB_ENV
fi

Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
cd ..

########################################################################
## TESTING AND DEPLOYMENT
## TESTING
########################################################################

# By default github actions do not pull the repo
Expand All @@ -139,13 +139,22 @@ jobs:

- name: Test stdlib
run: |
${{ env.CABAL_INSTALL }} agda-stdlib-utils.cabal
cabal run GenerateEverything
cp travis/* .
./index.sh
${{ env.AGDA }} --safe EverythingSafe.agda
${{ env.AGDA }} index.agda

- name: Golden testing
run: |
${{ env.CABAL_INSTALL }} --lib clock
make testsuite INTERACTIVE='' AGDA_EXEC='~/.cabal/bin/agda'


########################################################################
## DOC DEPLOYMENT
########################################################################

# We start by retrieving the currently deployed docs
# We remove the content that is in the directory we are going to populate
# so that stale files corresponding to deleted modules do not accumulate.
Expand All @@ -157,25 +166,11 @@ jobs:
rm -f '${{ env.AGDA_HTML_DIR }}'/*.css
${{ env.AGDA }} --html --html-dir ${{ env.AGDA_HTML_DIR }} index.agda

# This is a massive hack at the moment
# - name: Compile stdlib
# run: |
# ${{ env.AGDA }} -c --no-main --ghc-dont-call-ghc --compile-dir=tmp Everything.agda
# cd tmp
# yes | cabal init --interactive
# head -n -17 tmp.cabal > tmp
# mv tmp tmp.cabal
# cat ../travis/ghc-options >> tmp.cabal
# cabal build

## ${{ env.AGDA }} -c README/Foreign/Haskell.agda && ./Haskell


- name: Deploy HTML
uses: JamesIves/[email protected]
if: ${{ success() && env.AGDA_DEPLOY }}

with:
branch: gh-pages
folder: html
git-config-name: Github Actions
git-config-name: Github Actions
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Everything.agda
EverythingSafe.agda
EverythingSafeGuardedness.agda
EverythingSafeSizedTypes.agda
failures
GenerateEverything
Haskell
html
log
MAlonzo
output
runtests
100 changes: 100 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,53 @@ The library has been tested using Agda 2.6.2.
Highlights
----------

* A golden testing library in `Test.Golden`. This allows you to run a set
of tests and make sure their output matches an expected `golden' value.
The test runner has many options: filtering tests by name, dumping the
list of failures to a file, timing the runs, coloured output, etc.
Cf. the comments in `Test.Golden` and the standard library's own tests
in `tests/` for documentation on how to use the library.

Bug-fixes
---------

* In `System.Exit`, the `ExitFailure` constructor is now carrying an integer
rather than a natural. The previous binding was incorrectly assuming that
all exit codes where non-negative.

Non-backwards compatible changes
--------------------------------

* In `Text.Pretty`, `Doc` is now a record rather than a type alias. This
helps Agda reconstruct the `width` parameter when the module is opened
without it being applied. In particular this allows users to write
width-generic pretty printers and only pick a width when calling the
renderer by using this import style:
```
open import Text.Pretty using (Doc; render)
-- ^-- no width parameter for Doc & render
open module Pretty {w} = Text.Pretty w hiding (Doc; render)
-- ^-- implicit width parameter for the combinators

pretty : Doc w
pretty = ? -- you can use the combinators here and there won't be any
-- issues related to the fact that `w` cannot be reconstructed
-- anymore

main = do
-- you can now use the same pretty with different widths:
putStrLn $ render 40 pretty
putStrLn $ render 80 pretty
```

* In `Text.Regex.Search` the `searchND` function finding infix matches has
been tweaked to make sure the returned solution is a local maximum in terms
of length. It used to be that we would make the match start as late as
possible and finish as early as possible. It's now the reverse.

So `[a-zA-Z]+.agdai?` run on "the path _build/Main.agdai corresponds to"
will return "Main.agdai" when it used to be happy to just return "n.agda".

Deprecated modules
------------------

Expand All @@ -27,6 +68,29 @@ New modules
Algebra.Morphism.Construct.Identity
```

* Show module for unnormalised rationals:
```
Data.Rational.Unnormalised.Show
```

* Various system types and primitives:
```
System.Clock.Primitive
System.Clock
System.Console.ANSI
System.Directory.Primitive
System.Directory
System.FilePath.Posix.Primitive
System.FilePath.Posix
System.Process.Primitive
System.Process
```

* A golden testing library with test pools, an options parser, a runner:
```
Test.Golden
```

Other minor additions
---------------------

Expand All @@ -53,3 +117,39 @@ Other minor additions
∧-isCommutativeSemigroup : IsCommutativeSemigroup ∧
```
and their corresponding algebraic substructures.

* In `Data.String.Properties`:
```
≤-isDecTotalOrder-≈ : IsDecTotalOrder _≈_ _≤_
≤-decTotalOrder-≈ : DecTotalOrder _ _ _
```

* In `IO`:
```
Colist.forM : Colist A → (A → IO B) → IO (Colist B)
Colist.forM′ : Colist A → (A → IO B) → IO ⊤

List.forM : List A → (A → IO B) → IO (List B)
List.forM′ : List A → (A → IO B) → IO ⊤
```

* In `IO.Base`:
```
lift! : IO A → IO (Lift b A)
_<$_ : B → IO A → IO B
_=<<_ : (A → IO B) → IO A → IO B
_<<_ : IO B → IO A → IO B
lift′ : Prim.IO ⊤ → IO {a} ⊤

when : Bool → IO {a} ⊤ → IO ⊤
unless : Bool → IO {a} ⊤ → IO ⊤

whenJust : Maybe A → (A → IO {a} ⊤) → IO ⊤
untilJust : IO (Maybe A) → IO A
```

* In `System.Exit`:
```
isSuccess : ExitCode → Bool
isFailure : ExitCode → Bool
```
3 changes: 3 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ AGDA=$(AGDA_EXEC) $(RTS_OPTIONS)
test: Everything.agda check-whitespace
$(AGDA) -i. -isrc README.agda

testsuite:
$(MAKE) -C tests test AGDA="$(AGDA)" AGDA_EXEC="$(AGDA_EXEC)" only=$(only)

check-whitespace:
cabal exec -- fix-whitespace --check

Expand Down
9 changes: 9 additions & 0 deletions GenerateEverything.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,19 @@ unsafeModules = map modToFile
, "IO.Primitive.Infinite"
, "IO.Primitive.Finite"
, "Relation.Binary.PropositionalEquality.TrustMe"
, "System.Clock"
, "System.Clock.Primitive"
, "System.Directory"
, "System.Directory.Primitive"
, "System.Environment"
, "System.Environment.Primitive"
, "System.Exit"
, "System.Exit.Primitive"
, "System.FilePath.Posix"
, "System.FilePath.Posix.Primitive"
, "System.Process"
, "System.Process.Primitive"
, "Test.Golden"
, "Text.Pretty.Core"
, "Text.Pretty"
] ++ sizedTypesModules
Expand Down
16 changes: 16 additions & 0 deletions src/Data/Rational/Unnormalised/Show.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Showing unnormalised rational numbers
------------------------------------------------------------------------

{-# OPTIONS --without-K --safe #-}

module Data.Rational.Unnormalised.Show where

import Data.Integer.Show as ℤ
open import Data.Rational.Unnormalised.Base
open import Data.String.Base using (String; _++_)

show : ℚᵘ → String
show p = ℤ.show (↥ p) ++ "/" ++ ℤ.show (↧ p)
12 changes: 12 additions & 0 deletions src/Data/String/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ x <? y = StrictLex.<-decidable Charₚ._≟_ Charₚ._<?_ (toList x) (toList y)
toList
(StrictLex.≤-isDecPartialOrder Charₚ.<-isStrictTotalOrder)

≤-isDecTotalOrder-≈ : IsDecTotalOrder _≈_ _≤_
≤-isDecTotalOrder-≈ =
On.isDecTotalOrder
toList
(StrictLex.≤-isDecTotalOrder Charₚ.<-isStrictTotalOrder)

≤-decTotalOrder-≈ : DecTotalOrder _ _ _
≤-decTotalOrder-≈ =
On.decTotalOrder
(StrictLex.≤-decTotalOrder Charₚ.<-strictTotalOrder)
toList

≤-decPoset-≈ : DecPoset _ _ _
≤-decPoset-≈ =
On.decPoset
Expand Down
14 changes: 13 additions & 1 deletion src/IO.agda
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open import Codata.Musical.Costring
open import Data.Unit.Polymorphic.Base
open import Data.String.Base
import Data.Unit.Base as Unit0
open import Function.Base using (_∘_)
open import Function.Base using (_∘_; flip)
import IO.Primitive as Prim
open import Level

Expand Down Expand Up @@ -54,6 +54,12 @@ module Colist where
mapM′ : (A → IO B) → Colist A → IO ⊤
mapM′ f = sequence′ ∘ map f

forM : Colist A → (A → IO B) → IO (Colist B)
forM = flip mapM

forM′ : Colist A → (A → IO B) → IO ⊤
forM′ = flip mapM′

module List where

open import Data.List.Base
Expand All @@ -75,6 +81,12 @@ module List where
mapM′ : (A → IO B) → List A → IO ⊤
mapM′ f = sequence′ ∘ map f

forM : List A → (A → IO B) → IO (List B)
forM = flip mapM

forM′ : List A → (A → IO B) → IO ⊤
forM′ = flip mapM′

------------------------------------------------------------------------
-- Simple lazy IO

Expand Down
Loading