Skip to content
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

testsuite: allow to use expect-tests and Compilerlibs at the same time #7827

Closed
vicuna opened this issue Jul 19, 2018 · 3 comments
Closed

testsuite: allow to use expect-tests and Compilerlibs at the same time #7827

vicuna opened this issue Jul 19, 2018 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Jul 19, 2018

Original bug ID: 7827
Reporter: @gasche
Assigned to: @gasche
Status: resolved (set by @gasche on 2018-07-19T20:48:28Z)
Resolution: not a bug
Priority: normal
Severity: feature
Category: tools (ocaml{lex,yacc,dep,debug,...})

Bug description

It would be nice to use expect-tests, which currently are the nicer way of writing small library tests in the testsuite, in conjunction with Compilerlibs -- this comes from a real need I felt while implementing a recent PR.

My understanding is that this is made difficult by the fact that expect-tests uses the toplevel machinery, and that combining the toplevel with compiler-libs is difficult as most compiler-libs libraries are already linked with the toplevel, but hidden from the user code through a non-trivial mechanism.

Would there be a way to add some logic to the toplevel so that at least some of compiler-libs, for example ocamlcommon.cma (not ocamltoplevel.cma), can be accessed from the toplevel user? It doesn't need to be exposed to the "ocaml" toplevel, but somewhere in Toploop that tools/expect_test.ml could use.

@vicuna
Copy link
Author

vicuna commented Jul 19, 2018

Comment author: @Octachron

What is lacking in the current support? For instance, the following test behaves as expected:

(* TEST
flags = "-I ${ocamlsrcdir}/parsing -I ${ocamlsrcdir}/typing"
include ocamlcommon

  • expect
    *)

let () = Oprint.out_value := (fun _ -> ignore);;
let () = Oprint.out_type := (fun _ -> ignore);;
let x = Ast_helper.Exp.ident;;
[%%expect{|
val x : =
|}]

@vicuna
Copy link
Author

vicuna commented Jul 19, 2018

Comment author: @gasche

I think that I didn't know about the "${ocamlsrcdir}" syntax, I only tried include ocamlcommon, and looked for existing test headers containing ocamlcommon.

Now we need to commit an example using your proposal, so that it is found again when people look for it.

@vicuna vicuna closed this as completed Jul 19, 2018
@vicuna
Copy link
Author

vicuna commented Jul 19, 2018

Comment author: @gasche

Trying it in practice, it looks that this doesn't actually work correctly for my attempt, due to Misc.fatal_error mixing its output with the testsuite reports. I'm discussing this with octachron over at

#1918 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants