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

"should not compile" tests #50

Open
gildor478 opened this issue Oct 24, 2020 · 0 comments
Open

"should not compile" tests #50

gildor478 opened this issue Oct 24, 2020 · 0 comments

Comments

@gildor478
Copy link
Owner

This feature request has been migrated from artifact #1375 on forge.ocamlcore.org. It was assigned to user102.

user157 posted on 2014-02-14 21:55:26:

It would be nice to have tests like "this .ml should not compile".
It's useful while developing modules with abstract/private types, to make sure that some internal information must be hidden ( = "trying to access internals, it doesn't compile -> test passed"), or other compile-time constraints are obeyed (like "trying to make some operation on data with phantom/gadt type while it should be impossible -> it should not compile at all").
Also it could be very useful for projects that generate OCaml code, to check that generated code fits some constraints, not only positive ("code must compile and give expected results"), but negative also.

I understand you may have no time to implement it, but please answer these questions:

  1. does the whole idea fits OUnit ideology? (I doubt it, because OUnit works when something have compiled and already running.)
  2. in case it does, what ideas/pointers can you give me to ease implementation/merging of this feature in OUnit?

user102 replied on 2014-02-14 23:23:38:

At this point you reach one of my project (as is in my personal TODO list):
ounit-build: build code, run ocamlbuild plugin, run syntax extension

I would say, ounit itself is not the perfect place but a related project (I was planning to call it ounit-build) would be perfect.

Idealy both of them should live in this project and will be closely related, but may follow different release cycle.

In fact, I have already done some piece of this in OASIS:
https://github.com/ocaml/oasis/blob/master/test/TestFullUtils.ml

In particular:
l130 check_file_style

l196 setup_test_directories (create temporary directory and setup bin/lib/ocaml_lib et al)

l411 assert_compile && l416 try_installed_library

All these are in the context of OASIS, which means that it needs some adaptation to refer to file generated in the build system of the project itself (OASIS copies projects and compiles them fully).

If you can/want to combine that with OASIS, you can just do a fake installation of the project in a temporary directory.

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

1 participant