From: Siraaj Khandkar Date: Sun, 16 Sep 2018 17:23:19 +0000 (-0400) Subject: Add CLI options to execute different test suites X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=fca49f4f3908de86d5895b6a8708216fbb4dd529;p=tiger.ml.git Add CLI options to execute different test suites --- diff --git a/compiler/Makefile b/compiler/Makefile index 9feaa76..0cb89eb 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -1,5 +1,7 @@ MAKEFLAGS := --no-builtin-rules +DIR_TEST_CASES := ./testcases + EXE_TYPE := native # byte | native EXECUTABLES := tigerc tigert OCAMLBUILD_FLAGS_PKGS := -pkg unix @@ -17,6 +19,9 @@ OCAMLBUILD := \ all \ build \ clean \ + test_all \ + test_book \ + test_micro \ test all: clean @@ -32,5 +37,13 @@ clean: @$(OCAMLBUILD) -clean @rm -rf ./bin -test: build - @./bin/exe/tigert +test: test_all + +test_all: build + @./bin/exe/tigert all -dir $(DIR_TEST_CASES) + +test_book: build + @./bin/exe/tigert book -dir $(DIR_TEST_CASES) + +test_micro: build + @./bin/exe/tigert micro diff --git a/compiler/src/exe/tigert.ml b/compiler/src/exe/tigert.ml index f5a5851..c4d5bc8 100644 --- a/compiler/src/exe/tigert.ml +++ b/compiler/src/exe/tigert.ml @@ -1,5 +1,27 @@ +type suite = + | All of {dir : string} + | Book of {dir : string} + | Micro + let () = - let dir = ref "testcases" in - Arg.parse [("-dir", Arg.String (fun s -> dir := s), "")] (fun _ -> ()) ""; - let dir = !dir in - Tiger.Test.run (Tiger.Test_cases.all ~dir) + let suite = ref Micro in + let spec = ref [] in + Arg.parse_dynamic + spec + (function + | "micro" -> + spec := [] + | "book" -> + spec := [("-dir", Arg.String (fun dir -> suite := Book {dir}), "")] + | "all" -> + spec := [("-dir", Arg.String (fun dir -> suite := All {dir}), "")] + | _ -> () + ) + ""; + let suite = + match !suite with + | All {dir} -> Tiger.Test_cases.all ~dir + | Book {dir} -> Tiger.Test_cases.book ~dir + | Micro -> Tiger.Test_cases.micro + in + Tiger.Test.run suite