From: Siraaj Khandkar Date: Mon, 17 Sep 2018 11:20:57 +0000 (-0400) Subject: Filter-out hidden filenames from list of test files X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=f7fa9b32b236443fa0d2cf83fbb617081664b81b;p=tiger.ml.git Filter-out hidden filenames from list of test files These pop-up as tests every time I open one in Vim and a .filename.swp would be created --- diff --git a/compiler/src/lib/tiger/tiger_test_cases_book.ml b/compiler/src/lib/tiger/tiger_test_cases_book.ml index 3911f53..5cae186 100644 --- a/compiler/src/lib/tiger/tiger_test_cases_book.ml +++ b/compiler/src/lib/tiger/tiger_test_cases_book.ml @@ -129,8 +129,20 @@ let test_case_of_filename filename ~dir = ~is_error_expected_parsing:(is_error_expected_parsing_of_filename filename) ~is_error_expected_semant:(is_error_expected_semant_of_filename filename) +let is_filename_starts_with_dot filename = + match filename.[0] with + | exception Invalid_argument _ -> + (* Filename should not be an empty string *) + assert false + | '.' -> true + | _ -> false + +let is_filename_not_hidden filename = + not (is_filename_starts_with_dot filename) + let read ~from_dir:dir = Sys.readdir dir |> Array.to_list + |> List.filter ~f:is_filename_not_hidden |> List.sort ~cmp:compare |> List.map ~f:(test_case_of_filename ~dir)