Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions lib/runners/ocaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ("<IT::>" ^ OUnit.string_of_node name)',
' | EResult result -> ',
' begin match result with ',
' | RSuccess _ -> print_endline ("<PASSED::>Test passed")',
' | RFailure (_, err) -> print_endline ("<FAILED::>" ^ err)',
' | RError (_, err) -> print_endline ("<ERROR::>" ^ err)',
' | _ -> ()',
' end',
' | _ -> ()',
' ',
' let run_test = function',
' | TestLabel (name, suite) -> begin',
' print_endline ("<DESCRIBE::>" ^ 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<IT::>" ^ OUnit.string_of_node name)',
' | EResult result -> ',
' begin match result with ',
' | RSuccess _ -> print_endline ("\\n<PASSED::>Test passed")',
' | RFailure (_, err) -> print_endline ("\\n<FAILED::>" ^ err)',
' | RError (_, err) -> print_endline ("\\n<ERROR::>" ^ err)',
' | _ -> ()',
' end',
' | _ -> ()',
' ',
' let run_test = function',
' | TestLabel (name, suite) -> begin',
' print_endline ("\\n<DESCRIBE::>" ^ 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',
Expand Down
30 changes: 29 additions & 1 deletion test/runners/ocaml_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,35 @@ describe('ocaml runner', function() {
].join('\n')
}, function(buffer) {
console.log(buffer);
expect(buffer.stdout).to.contain("<DESCRIBE::>Person\n<IT::>.greet\n<PASSED::>");
expect(buffer.stdout).to.contain("\n<DESCRIBE::>Person\n\n<IT::>.greet\n\n<PASSED::>");
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<FAILED::>');
done();
});
});
Expand Down