New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate expect tests to ocamltest #1519
Changes from 1 commit
05a85e7
e801cc6
3f0d42a
6e01fbb
218a4ca
6e0a143
88f051e
de80a1d
cefbe81
b95315d
c2d122f
adfa328
2e46ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,15 @@ let ocaml_dot_opt ocamlsrcdir = | |
let cmpbyt ocamlsrcdir = | ||
Filename.make_path [ocamlsrcdir; "tools"; "cmpbyt"] | ||
|
||
let expect_program ocamlsrcdir = | ||
Filename.make_path | ||
[ocamlsrcdir; "testsuite"; "tools"; Filename.mkexe "expect_test"] | ||
|
||
let expect_command ocamlsrcdir = | ||
let ocamlrun = ocamlrun ocamlsrcdir in | ||
let expect_test = expect_program ocamlsrcdir in | ||
ocamlrun ^ " " ^ expect_test | ||
|
||
let stdlib ocamlsrcdir = | ||
Filename.make_path [ocamlsrcdir; "stdlib"] | ||
|
||
|
@@ -450,11 +459,51 @@ let ocamlopt_opt = Actions.make | |
"ocamlopt.opt" | ||
(compile_test_program Builtin_variables.program2 ocamlopt_opt_compiler) | ||
|
||
let run_expect_once ocamlsrcdir input_file principal log env = | ||
let expect_flags = try Sys.getenv "EXPECT_FLAGS" with Not_found -> "" in | ||
let repo_root = "-repo-root " ^ ocamlsrcdir in | ||
let principal_flag = if principal then "-principal" else "" in | ||
let commandline = | ||
[ | ||
expect_command ocamlsrcdir; | ||
expect_flags; | ||
flags env; | ||
repo_root; | ||
principal_flag; | ||
input_file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original invocation command TERM=dumb $(EXPECT_TEST) $(EXPECT_FLAGS) -repo-root $(OTOPDIR) $$file also starts with a |
||
] in | ||
let exit_status = Actions_helpers.run_cmd log env commandline in | ||
if exit_status=0 then Pass env | ||
else Fail (Actions_helpers.mkreason | ||
"expect" (String.concat " " commandline) exit_status) | ||
|
||
let run_expect_twice ocamlsrcdir input_file log env = | ||
let corrected filename = Filename.make_filename filename "corrected" in | ||
let first_run = run_expect_once ocamlsrcdir input_file false log env in | ||
match first_run with | ||
| Pass env1 -> | ||
let intermediate_file = corrected input_file in | ||
let second_run = | ||
run_expect_once ocamlsrcdir intermediate_file true log env1 in | ||
(match second_run with | ||
| Pass env2 -> | ||
let output_file = corrected intermediate_file in | ||
let output_env = Environments.add_bindings | ||
[ | ||
Builtin_variables.reference, input_file; | ||
Builtin_variables.output, output_file | ||
] env2 in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An intermediary file |
||
Pass output_env | ||
| Skip _ | Fail _ -> second_run | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is minor, but I find the code more readable if the short cases are first ( |
||
) | ||
| Skip _ | Fail _ -> first_run | ||
|
||
let run_expect log env = | ||
let newenv = Environments.apply_modifiers env Ocaml_modifiers.expect in | ||
Actions_helpers.run_script log newenv | ||
let ocamlsrcdir = ocamlsrcdir () in | ||
let input_file = Actions_helpers.testfile env in | ||
run_expect_twice ocamlsrcdir input_file log env | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When are the result and reference file actually compared? I don't see a call to |
||
|
||
let expect = Actions.make "expect" run_expect | ||
let run_expect = Actions.make "run-expect" run_expect | ||
|
||
let make_check_compiler_output name compiler = Actions.make | ||
name | ||
|
@@ -640,7 +689,7 @@ let _ = | |
setup_ocamlopt_opt_build_env; | ||
ocamlopt_opt; | ||
check_ocamlopt_opt_output; | ||
expect; | ||
run_expect; | ||
compare_bytecode_programs; | ||
compare_native_programs; | ||
setup_ocaml_build_env; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,5 @@ val bytecode : Tests.t | |
val native : Tests.t | ||
|
||
val toplevel : Tests.t | ||
|
||
val expect : Tests.t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
setup_simple_build_env
doing compared tosetup_build_env
?