Filter-out hidden filenames from list of test files
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 17 Sep 2018 11:20:57 +0000 (07:20 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 17 Sep 2018 11:20:57 +0000 (07:20 -0400)
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

index 3911f53..5cae186 100644 (file)
@@ -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)
This page took 0.028258 seconds and 4 git commands to generate.