From f7fa9b32b236443fa0d2cf83fbb617081664b81b Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 17 Sep 2018 07:20:57 -0400 Subject: [PATCH] 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 --- compiler/src/lib/tiger/tiger_test_cases_book.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- 2.20.1