Skip to content

Commit 4fb7d68

Browse files
ttuegelrv-jenkins
andauthored
Run integration tests with Nix (#2492)
* Makefile: Do not automatically rebuild backend Automatically rebuilding the backend makes it impossible to test an out-of-tree build with the Makefile. * test.nix: Run integration tests in Nix * test.yml: Run integration tests on Linux separately * test.nix: Override backend in kframework/k Co-authored-by: rv-jenkins <[email protected]>
1 parent d3a29df commit 4fb7d68

File tree

7 files changed

+122
-11
lines changed

7 files changed

+122
-11
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ jobs:
5252
- name: Check shell
5353
run: nix-shell --run "echo OK"
5454

55+
nix-integration:
56+
name: 'Nix / Integration'
57+
runs-on: ubuntu-latest
58+
needs: nix
59+
steps:
60+
- name: Check out code
61+
uses: actions/[email protected]
62+
with:
63+
# Check out pull request HEAD instead of merge commit.
64+
ref: ${{ github.event.pull_request.head.sha }}
65+
submodules: recursive
66+
67+
- name: Install Nix
68+
uses: cachix/install-nix-action@v12
69+
with:
70+
extra_nix_config: |
71+
substituters = http://cache.nixos.org https://hydra.iohk.io
72+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
73+
74+
- name: Install Cachix
75+
uses: cachix/cachix-action@v8
76+
with:
77+
name: kore
78+
skipPush: true
79+
extraPullNames: runtimeverification
80+
81+
- name: Run integration tests
82+
run: nix-build test.nix
83+
5584
cabal:
5685
name: 'Cabal'
5786
runs-on: ubuntu-latest

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Use `docker.sh` to run commands inside the container:
6060

6161
``` sh
6262
./docker/build.sh # run once when dependencies change
63+
./docker/run.sh make # build the backend
6364
./docker/run.sh make test # run all tests
6465
./docker/run.sh make -C test/imp test # run all tests in test/imp
6566
```
@@ -116,6 +117,13 @@ When the `.cabal` package description file changes, run:
116117

117118
This script is also run by an automatic workflow.
118119

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+
```
119127

120128
[git]: https://git-scm.com/
121129
[stack]: https://www.haskellstack.org/

include.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ KORE_REPL_OPTS = --no-bug-report
4848
export KORE_REPL
4949
export KORE_REPL_OPTS
5050

51-
$(KORE_EXEC):
51+
$(BUILD_DIR)/kore/bin/kore-exec:
5252
$(STACK) $(STACK_BUILD) $(STACK_NO_PROFILE) --copy-bins kore:exe:kore-exec
5353

54-
$(KORE_REPL):
54+
$(BUILD_DIR)/kore/bin/kore-repl:
5555
$(STACK) $(STACK_BUILD) $(STACK_NO_PROFILE) --copy-bins kore:exe:kore-repl
5656

57-
$(KORE_PARSER):
57+
$(BUILD_DIR)/kore/bin/kore-parser:
5858
$(STACK) $(STACK_BUILD) $(STACK_NO_PROFILE) --copy-bins kore:exe:kore-parser

test.nix

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
default = import ./. {};
24+
inherit (default) kore;
25+
26+
kframework =
27+
let
28+
tag = lib.fileContents ./deps/k_release;
29+
url = "https://github.com/kframework/k/releases/download/${tag}/release.nix";
30+
args = import (builtins.fetchurl { inherit url; });
31+
src = pkgs.fetchgit args;
32+
in import src {};
33+
34+
k = kframework.k.override {
35+
haskell-backend = kore;
36+
};
37+
38+
in
39+
40+
stdenv.mkDerivation {
41+
name = "kore-test";
42+
src = ttuegel.cleanGitSubtree { name = "kore"; src = ./.; };
43+
preferLocalBuild = true;
44+
buildInputs = [
45+
k kore # some tests use kore-exec directly, others run through the frontend
46+
ncurses # TODO: .../lib/kframework/setenv: line 31: tput: command not found
47+
z3
48+
];
49+
configurePhase = ''
50+
export TOP=$(pwd)
51+
'';
52+
buildFlags =
53+
[
54+
"KORE_PARSER=kore-parser"
55+
"KORE_EXEC=kore-exec"
56+
"KORE_REPL=kore-repl"
57+
"--output-sync"
58+
"test"
59+
]
60+
++ lib.optional (test != null) "-C ${test}"
61+
;
62+
enableParallelBuilding = true;
63+
preBuild = ''
64+
cd test
65+
'';
66+
installPhase = ''
67+
runHook preInstall
68+
69+
touch "$out"
70+
71+
runHook postInstall
72+
'';
73+
}
74+

test/include.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ KOMPILED := $(TEST_DIR)/$(DEF)-kompiled
1919
export KOMPILED
2020
DEF_KORE_DEFAULT = $(KOMPILED)/definition.kore
2121
DEF_KORE ?= $(DEF_KORE_DEFAULT)
22-
TEST_DEPS = $(K) $(KORE_PARSER) $(DEF_KORE) $(KORE_EXEC)
22+
TEST_DEPS = $(K) $(DEF_KORE)
2323

2424
TESTS = \
2525
$(wildcard $(DEF_DIR)/*.verify) \
@@ -44,7 +44,7 @@ KORE_EXEC_OPTS += \
4444
KPROVE_REPL_OPTS += -d $(DEF_DIR) -m $(KPROVE_MODULE)
4545
KPROVE_SPEC = $<
4646

47-
$(DEF_KORE_DEFAULT): $(DEF_DIR)/$(DEF).k $(K) $(KORE_PARSER)
47+
$(DEF_KORE_DEFAULT): $(DEF_DIR)/$(DEF).k $(K)
4848
@echo ">>>" $(CURDIR) "kompile" $<
4949
rm -fr $(KOMPILED)
5050
$(KOMPILE) $(KOMPILE_OPTS) $<
@@ -112,10 +112,10 @@ PATTERN_OPTS = --pattern "$$(cat $*.k)"
112112
%.save-proofs.kore: %.out
113113
[ -f $@ ]
114114

115-
%-spec.k.repl: $(TEST_DIR)/%-spec.k $(KORE_REPL) $(TEST_DEPS)
115+
%-spec.k.repl: $(TEST_DIR)/%-spec.k $(TEST_DEPS)
116116
$(KPROVE) $(KPROVE_REPL_OPTS) $<
117117

118-
%-spec.k.run-repl-script: $(TEST_DIR)/%-spec.k $(KORE_REPL) $(TEST_DEPS)
118+
%-spec.k.run-repl-script: $(TEST_DIR)/%-spec.k $(TEST_DEPS)
119119
$(KPROVE) $(KPROVE_REPL_OPTS) $<
120120
%-spec.k.run-repl-script: KORE_REPL_OPTS= -r --repl-script $@
121121

@@ -133,15 +133,15 @@ PATTERN_OPTS = --pattern "$$(cat $*.k)"
133133

134134
### MERGE
135135

136-
%.merge.out: $(TEST_DIR)/%.merge $(DEF_KORE) $(KORE_EXEC)
136+
%.merge.out: $(TEST_DIR)/%.merge $(DEF_KORE)
137137
@echo ">>>" $(CURDIR) "kore-exec --merge-rules" $<
138138
rm -f $@
139139
$(KORE_EXEC) $(DEF_KORE) --module $(KORE_MODULE) --merge-rules $< --output $@
140140
$(DIFF) $@.golden $@ || $(FAILED)
141141

142142
### SCRIPTS
143143

144-
test-%.sh.out: $(KORE_EXEC) $(TEST_DIR)/test-%.sh
144+
test-%.sh.out: $(TEST_DIR)/test-%.sh
145145
@echo ">>>" $(CURDIR) $(@:.out=)
146146
rm -f $@
147147
$(TEST_DIR)/$(@:.out=) > $@ || true

test/no-injection-into-hooked/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ clean:
1717

1818
.PHONY: test-k test golden clean
1919

20-
test-kompiled/definition.kore: test.k $(K) $(KORE_PARSER)
20+
test-kompiled/definition.kore: test.k $(K)
2121
@echo ">>>" $(CURDIR) "kompile" $<
2222
rm -fr $(KOMPILED)
2323
$(KOMPILE) $(KOMPILE_OPTS) $<; if [ $$? -eq 0 ]; then exit 1; fi

test/parser/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ TESTS = $(wildcard *.kore)
1313
OUTS += $(foreach TEST, $(TESTS), $(TEST).out)
1414
GOLDEN += $(foreach TEST, $(TESTS), $(TEST).golden)
1515

16-
%.kore.out : %.kore $(KORE_PARSER)
16+
%.kore.out : %.kore
1717
$(KORE_PARSER) --no-print-definition $< 2>$@ || true
1818
$(DIFF) $*.kore.golden $@ || $(FAILED)
1919

0 commit comments

Comments
 (0)