Simple, bare bones unit tests in Rust called from C. #1511
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 asemacs_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 intounittests
and run it withcd 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:
LispObject -> Rust Type -> LispObject; obj1 == obj2