jyn514 / saltwater

A C compiler written in Rust, with a focus on good error messages.
BSD 3-Clause "New" or "Revised" License
294 stars 27 forks source link

Cross-check rcc against other compilers #469

Open jyn514 opened 4 years ago

jyn514 commented 4 years ago

We do this at work for our SQL implementation: https://gitlab.com/YottaDB/DBMS/YDBOcto/-/blob/master/tests/test_helpers.bash.in#L551. The basic idea is to run two compilers on the same code and make sure they agree. We could integrate this with existing assert_compiles, etc. tests and make sure that we're testing the right thing. This would also let us take advantage of the existing test suite without much work.

Inspired by @pythondude325 finding that fn redefinition was testing the wrong thing (https://github.com/jyn514/saltwater/pull/470) - the test passed, but it shouldn't have.

pythongirl325 commented 4 years ago

This is effectively what I do by testing hexponent against libc's equivalent functions.

pythongirl325 commented 4 years ago

Could we do this very naively by just using cc to write the tests?

jyn514 commented 4 years ago

The way I was planning to do this is modifying https://github.com/jyn514/saltwater/blob/8a52d91ba584925a1c09a409c17ede1f652848f2/tests/utils/mod.rs#L75, etc. to run cc against the code in addition to swcc, yeah.