Skip to content

Commit

Permalink
test: add regression test for ITree.iter fix; simplify organization o…
Browse files Browse the repository at this point in the history
…f tests
  • Loading branch information
Lysxia committed Jul 20, 2020
1 parent 2b8d6a6 commit dd22ebb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
11 changes: 9 additions & 2 deletions tests/Makefile
@@ -1,11 +1,18 @@
.PHONY: all build extraction clean
.PHONY: all extraction clean

all: coq extraction

coq: output

EXTRDIR:=output

$(EXTRDIR):
mkdir -p $(EXTRDIR)

include ../common.mk

extraction: coq
ocamlbuild extraction/MetaModule.native -no-links
sh extraction-test.sh

clean: clean-coq
$(RM) -rf _build/
Expand Down
14 changes: 5 additions & 9 deletions tests/_CoqProject
@@ -1,17 +1,13 @@
-Q ../theories ITree
-Q extraction/ TestExtraction
-Q unit/ TestUnit
-Q src/ ITreeTest

src/Tests.v

# Test to ensure extracted code is compilable
# - MetaModule.v is a module that depends on the
# ITree library
# - Extract.v contains the extraction command for
# MetaModule (and recursively its dependencies)
# The ocamlbuild command is in Makefile

extraction/MetaModule.v
extraction/Extract.v

# Unit tests

unit/Unit.v
src/MetaModule.v
src/Extract.v
9 changes: 9 additions & 0 deletions tests/extraction-test.sh
@@ -0,0 +1,9 @@
set -xe
cd output/

ocamlbuild test.native
./test.native

ocamlbuild MetaModule.native
./MetaModule.native
# This executable should do absolutely nothing
4 changes: 2 additions & 2 deletions tests/extraction/Extract.v → tests/src/Extract.v
@@ -1,10 +1,10 @@
Require TestExtraction.MetaModule.
Require ITreeTest.MetaModule.

Require Extraction.

Extraction Language OCaml.
Extraction Blacklist String List Char Core Z.

Cd "extraction".
Cd "output".
Recursive Extraction Library MetaModule.
Cd "..".
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/unit/Unit.v → tests/src/Tests.v
Expand Up @@ -14,3 +14,13 @@ Proof.
rewrite interp_id_h.
reflexivity.
Qed.

(* Regression test for #182 ([ITree.iter] should be executable even when the loop is infinite
(the body is always [Ret (inl _)]) *)
Definition iter_spin : itree void1 void :=
iter (C := ktree _) (fun _ : unit => Ret (@inl unit void tt)) tt.

Require Extraction.

(* This should NOT loop forever. *)
Extraction "output/test.ml" iter_spin.

0 comments on commit dd22ebb

Please sign in to comment.