Skip to content

Commit

Permalink
Add a workaround to allow querying the test program for '--help'
Browse files Browse the repository at this point in the history
without requiring test data. The issue was raised at
mirage/alcotest#358
  • Loading branch information
mjambon committed Sep 17, 2022
1 parent 70b1aeb commit 7268c0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions semgrep-core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ clean:
#
.PHONY: test
test: all
# ensure that '--help' is available and that we don't load test data
# until the tests need to run.
./_build/default/tests/test.exe --help 2>&1 >/dev/null
$(MAKE) -C src/spacegrep test
dune runtest -f --no-buffer

Expand Down
11 changes: 10 additions & 1 deletion semgrep-core/tests/Test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ let tests () = List.flatten [
(* Entry point *)
(*****************************************************************************)

(*
This allows running the test program with '--help' from any folder
without getting an error due to not being able to load test data.
*)
let tests_with_delayed_error () =
try tests ()
with e ->
["cannot load test data - not a real test", (fun () -> raise e)]

let main () =
let alcotest_tests = Testutil.to_alcotest (tests ()) in
let alcotest_tests = Testutil.to_alcotest (tests_with_delayed_error ()) in
Alcotest.run "semgrep-core" alcotest_tests

let () = main ()

0 comments on commit 7268c0e

Please sign in to comment.