|
34 | 34 | } |
35 | 35 | ); |
36 | 36 |
|
| 37 | + ## Runs the test suite without coverage, for clean output. 'spec.tix' is |
| 38 | + ## removed first to avoid stale HPC '.tix'/'.mix' mismatches (caused by |
| 39 | + ## '-fignore-hpc-changes' in 'package.yaml'). Extra arguments are |
| 40 | + ## forwarded to the 'tasty' test binary (e.g. '-p PATTERN'). |
| 41 | + cooked-test = pkgs.writeShellScriptBin "cooked-test" '' |
| 42 | + rm -f spec.tix |
| 43 | + opts=(--test-option=--color=always) |
| 44 | + for arg in "$@"; do opts+=("--test-option=$arg"); done |
| 45 | + cabal test all "''${opts[@]}" |
| 46 | + ''; |
| 47 | + |
| 48 | + ## Like 'cooked-test' but with coverage analysis (only checked |
| 49 | + ## punctually). The verbose "Writing: ....html" coverage lines are |
| 50 | + ## filtered out, and 'PIPESTATUS' preserves the test binary's exit status |
| 51 | + ## through that pipe. |
| 52 | + cooked-test-coverage = pkgs.writeShellScriptBin "cooked-test-coverage" '' |
| 53 | + rm -f spec.tix |
| 54 | + opts=(--test-option=--color=always) |
| 55 | + for arg in "$@"; do opts+=("--test-option=$arg"); done |
| 56 | + cabal test all --enable-coverage "''${opts[@]}" | grep -vE --color=never "^Writing:.*html$" |
| 57 | + exit "''${PIPESTATUS[0]}" |
| 58 | + ''; |
| 59 | + |
37 | 60 | pre-commit = pre-commit-hooks.lib.${system}.run { |
38 | 61 | src = ./.; |
39 | 62 | hooks = { |
|
82 | 105 | pkgs.openldap # For freer-extras‽ |
83 | 106 | pkgs.libsodium |
84 | 107 | pkgs.secp256k1 |
85 | | - pkgs.lmdb |
86 | 108 | blst-portable |
87 | 109 | ]; |
88 | 110 |
|
|
102 | 124 | pkgs.hlint |
103 | 125 | pkgs.ormolu |
104 | 126 | hpkgs.haskell-language-server |
| 127 | + cooked-test |
| 128 | + cooked-test-coverage |
105 | 129 | ]; |
106 | 130 |
|
107 | 131 | inherit LD_LIBRARY_PATH; |
108 | 132 | inherit LANG; |
109 | 133 |
|
110 | | - # In addition to the pre-commit hooks, this redefines a cabal |
111 | | - # command that gets rid of annoying "Writing: .....*.html" output |
112 | | - # when running cabal test. |
113 | | - shellHook = pre-commit.shellHook + '' |
114 | | - function cabal() { |
115 | | - if [ "$1" != "test" ]; then |
116 | | - command cabal "$@" |
117 | | - else |
118 | | - command cabal --test-option=--color=always "$@" | grep -vE --color=never "^Writing:.*html$" |
119 | | - fi |
120 | | - } |
121 | | - export -f cabal |
122 | | - ''; |
| 134 | + shellHook = pre-commit.shellHook; |
123 | 135 | }; |
124 | 136 | }; |
125 | 137 |
|
|
0 commit comments