From 217e963845b596d25400ec28035a15d64478e6da Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Sun, 16 Sep 2018 12:25:28 -0400 Subject: [PATCH] Don't execute semant test if parsing fails this is a hack - need to replace with a general test-dependency framework --- compiler/src/lib/tiger/tiger_test.ml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/compiler/src/lib/tiger/tiger_test.ml b/compiler/src/lib/tiger/tiger_test.ml index 1a27cf2..81f549d 100644 --- a/compiler/src/lib/tiger/tiger_test.ml +++ b/compiler/src/lib/tiger/tiger_test.ml @@ -181,14 +181,10 @@ let pass_parsing ~fake_filename ~code | ast -> Ok ast -let pass_semant (absyn_opt : Tiger_absyn.t option) +let pass_semant (absyn : Tiger_absyn.t) : (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 @@ -312,10 +308,20 @@ let run tests = ~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 *) -- 2.20.1