diff --git a/lib/runners/ocaml.js b/lib/runners/ocaml.js index aabdc45b..562345bc 100644 --- a/lib/runners/ocaml.js +++ b/lib/runners/ocaml.js @@ -20,26 +20,26 @@ module.exports.run = function run(opts, cb) { var runFixtureUsingOUnit = [ '#load "str.cma";;', 'module TestRunner = struct', - ' open OUnit', - ' let cw_print_endline s = s |> Str.global_replace (Str.regexp_string "\n") "<:LF:>" |> print_endline;;', - ' let cw_print_test_event = function', - ' | EStart (name::rest) -> print_endline ("" ^ OUnit.string_of_node name)', - ' | EResult result -> ', - ' begin match result with ', - ' | RSuccess _ -> print_endline ("Test passed")', - ' | RFailure (_, err) -> print_endline ("" ^ err)', - ' | RError (_, err) -> print_endline ("" ^ err)', - ' | _ -> ()', - ' end', - ' | _ -> ()', - ' ', - ' let run_test = function', - ' | TestLabel (name, suite) -> begin', - ' print_endline ("" ^ name);', - ' perform_test cw_print_test_event suite', - ' end', - ' | suite -> perform_test cw_print_test_event suite', - ' ', + ' open OUnit', + ' let cw_print_endline s = s |> Str.global_replace (Str.regexp_string "\\n") "<:LF:>" |> print_endline;;', + ' let cw_print_test_event = function', + ' | EStart (name::rest) -> print_endline ("\\n" ^ OUnit.string_of_node name)', + ' | EResult result -> ', + ' begin match result with ', + ' | RSuccess _ -> print_endline ("\\nTest passed")', + ' | RFailure (_, err) -> print_endline ("\\n" ^ err)', + ' | RError (_, err) -> print_endline ("\\n" ^ err)', + ' | _ -> ()', + ' end', + ' | _ -> ()', + ' ', + ' let run_test = function', + ' | TestLabel (name, suite) -> begin', + ' print_endline ("\\n" ^ name);', + ' perform_test cw_print_test_event suite', + ' end', + ' | suite -> perform_test cw_print_test_event suite', + ' ', 'end', 'let _ = ', ' List.map TestRunner.run_test Tests.suite |> ignore', diff --git a/test/runners/ocaml_spec.js b/test/runners/ocaml_spec.js index 018c82f0..d292a14e 100644 --- a/test/runners/ocaml_spec.js +++ b/test/runners/ocaml_spec.js @@ -41,7 +41,35 @@ describe('ocaml runner', function() { ].join('\n') }, function(buffer) { console.log(buffer); - expect(buffer.stdout).to.contain("Person\n.greet\n"); + expect(buffer.stdout).to.contain("\nPerson\n\n.greet\n\n"); + done(); + }); + }); + + it('should have output format command on independent line', function(done) { + runner.run({ + language: 'ocaml', + testFramework: 'ounit', + solution: [ + `let add a b = a - b;;`, + ].join('\n'), + fixture: [ + `module Tests = struct`, + ` open OUnit`, + ` let suite =`, + ` [`, + ` "Suite Name" >:::`, + ` [`, + ` "Test Name" >:: (fun _ ->`, + ` Printf.printf "%s" "foo";`, + ` assert_equal 2 (add 1 1)`, + ` )`, + ` ]`, + ` ]`, + `end`, + ].join('\n'), + }, function(buffer) { + expect(buffer.stdout).to.contain('\n'); done(); }); });