Don't execute semant test if parsing fails
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 16 Sep 2018 16:25:28 +0000 (12:25 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 16 Sep 2018 16:25:28 +0000 (12:25 -0400)
this is a hack - need to replace with a general test-dependency framework

compiler/src/lib/tiger/tiger_test.ml

index 1a27cf2..81f549d 100644 (file)
@@ -181,14 +181,10 @@ let pass_parsing ~fake_filename ~code
   | ast ->
       Ok ast
 
   | ast ->
       Ok ast
 
-let pass_semant (absyn_opt : Tiger_absyn.t option)
+let pass_semant (absyn : Tiger_absyn.t)
 : (unit, string) result
 =
 : (unit, string) result
 =
-  match absyn_opt with
-  | None ->
-      Error "AST not provided"
-  | Some absyn ->
-      Ok (Tiger_semant.transProg absyn)
+  Ok (Tiger_semant.transProg absyn)
 
 let str_exact str exact =
   let len = String.length str in
 
 let str_exact str exact =
   let len = String.length str in
@@ -312,10 +308,20 @@ let run tests =
           ~is_error_expected:is_error_expected_parsing
       in
       let res_sem =
           ~is_error_expected:is_error_expected_parsing
       in
       let res_sem =
-        run_pass
-          ~f:(fun () -> pass_semant res_pars.out_val)
-          ~expect_output:(Some ())
-          ~is_error_expected:is_error_expected_semant
+        (* TODO: Replace this hack with general test-dependency checking *)
+        match res_pars.out_val with
+        | None ->
+            { exe_stat = Skip
+            ; exe_msg  = "No AST provided"
+            ; out_stat = Skip
+            ; out_val  = None
+            ; out_msg  = ""
+            }
+        | Some absyn ->
+            run_pass
+              ~f:(fun () -> pass_semant absyn)
+              ~expect_output:(Some ())
+              ~is_error_expected:is_error_expected_semant
       in
       let results =
         (* Replacing out_val for type compatibility *)
       in
       let results =
         (* Replacing out_val for type compatibility *)
This page took 0.033322 seconds and 4 git commands to generate.