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

Simple, bare bones unit tests in Rust called from C. #1511

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shaleh
Copy link
Collaborator

@shaleh shaleh commented Jun 7, 2019

This ain't pretty and it definitely ain't fit to merge. But it demonstrates a path towards unit tests of Rust code in Rust but called by C code.

This creates a new main. The original is intact as emacs_main. Now emacs can also be used as a collection of objects like a library. There are likely bugs, pitfalls, and traps here still.

The tests are added in Rust but extern "C". There is no need for fancy C unit test support since Rust's is doing all of the work. These are not built separately and will end up in the final remacs binary. Yuck. This also means they are built exactly like the rest of remacs. No special compilation flags currently. Double Yuck.

unittests.c in src/ is the frame work. All it does is setup the Emacs bits and then call the Rust tests. Build unittests.c into unittests and run it with cd src; make unittests Failure causes the binary to be deleted!?! So the makefile masks out the error currently. Which means test failure will not stop the build currently and it definitely should.

Written correctly, the Rust unit tests will not be throw away. Once remacs is self hosting on Rust instead of built as a library called from C, the C unit test harness and support can be dropped and the tests will just keep on running under Cargo.

I am very unlikely to carry this to the end. Hopefully enough people see value in this that it is completed.

Next steps:

  • Figure out why the binary is deleted on failure.
  • Validate that all of the necessary bits of initialization are exposed to the unit tests. For instance, does Garbage Collection work in the unit tests? Dunno.
  • Move C and Rust build into a full debug compilation so the unit tests are not compiled into remacs
  • Make test failure stop the compilation
  • Add tests that validate all of the Rust ported types. LispObject -> Rust Type -> LispObject; obj1 == obj2

Just for LispFontSpecRef at the moment.
@shaleh shaleh added in progress PR is under development and should not be merged. task for hero labels Jun 7, 2019
@shaleh shaleh mentioned this pull request Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress PR is under development and should not be merged. task for hero
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant