Skip to content

Commit 1caedf0

Browse files
committed
test.nix: Run integration tests in Nix
1 parent 0dff1ff commit 1caedf0

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
- name: Run unit tests
5050
run: nix-build -A project.kore.checks
5151

52+
- name: Run integration tests
53+
run: nix-build test.nix
54+
5255
- name: Check shell
5356
run: nix-shell --run "echo OK"
5457

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ When the `.cabal` package description file changes, run:
117117

118118
This script is also run by an automatic workflow.
119119

120+
We provide a `test.nix` for running integration tests:
121+
122+
``` sh
123+
nix-build test.nix # run all integration tests
124+
nix-build test.nix --argstr test imp # run the integration tests in test/imp
125+
nix-shell test.nix # enter a shell where we can run tests manually
126+
```
120127

121128
[git]: https://git-scm.com/
122129
[stack]: https://www.haskellstack.org/

test.nix

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
let
2+
sources = import ./nix/sources.nix;
3+
pinned = import sources."nixpkgs" { config = {}; overlays = []; };
4+
in
5+
6+
{ pkgs ? pinned
7+
, test ? null
8+
}:
9+
10+
let
11+
inherit (pkgs) stdenv lib;
12+
inherit (pkgs) bison diffutils ncurses z3;
13+
14+
ttuegel =
15+
let
16+
src = builtins.fetchGit {
17+
url = "https://github.com/ttuegel/nix-lib";
18+
rev = "66bb0ab890ff4d828a2dcfc7d5968465d0c7084f";
19+
ref = "main";
20+
};
21+
in import src { inherit pkgs; };
22+
23+
kframework =
24+
let
25+
tag = lib.fileContents ./deps/k_release;
26+
url = "https://github.com/kframework/k/releases/download/${tag}/release.nix";
27+
args = import (builtins.fetchurl { inherit url; });
28+
src = pkgs.fetchgit args;
29+
in import src {};
30+
inherit (kframework) k;
31+
32+
default = import ./. {};
33+
inherit (default) kore;
34+
in
35+
36+
stdenv.mkDerivation {
37+
name = "kore-test";
38+
src = ttuegel.cleanGitSubtree { name = "kore"; src = ./.; };
39+
preferLocalBuild = true;
40+
buildInputs = [
41+
k kore
42+
ncurses # TODO: .../lib/kframework/setenv: line 31: tput: command not found
43+
z3
44+
];
45+
configurePhase = ''
46+
export TOP=$(pwd)
47+
'';
48+
buildFlags =
49+
[
50+
"KORE_PARSER=kore-parser"
51+
"KORE_EXEC=kore-exec"
52+
"KORE_REPL=kore-repl"
53+
"--output-sync"
54+
"test"
55+
]
56+
++ lib.optional (test != null) "-C ${test}"
57+
;
58+
enableParallelBuilding = true;
59+
preBuild = ''
60+
cd test
61+
'';
62+
installPhase = ''
63+
runHook preInstall
64+
65+
touch "$out"
66+
67+
runHook postInstall
68+
'';
69+
}
70+

0 commit comments

Comments
 (0)