jyn514 / saltwater

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

Add tests for command line arguments #498

Open hdamron17 opened 4 years ago

hdamron17 commented 4 years ago

Currently there are no tests to ensure command line arguments work as expected. It may also be good to check that the help message stays up to date with the accepted flags. Tests could either be runner tests or unit tests of parse_args (or both!).

jyn514 commented 4 years ago

Rust has ui-tests which let you add additional arguments at the top:

// compile-flags: -Coverflow-checks=off
fn main() {
    let x = 0 - 1;
}

Maybe we could do something similar for runner tests?

hdamron17 commented 4 years ago

I think unit tests would be preferred where possible (and I think they would be since parse_args is its own function). But having some runner tests of that sort would also be helpful to check that the functionality of the command line args is used properly and not just that the flag is read in right. (e.g. the include directory is actually included).

hdamron17 commented 4 years ago

Also, a lot of the flags require external files which may be complicated for the runner tests (not sure).

jyn514 commented 4 years ago

That part shouldn't be too bad - see for example https://github.com/jyn514/saltwater/tree/master/tests/runner-tests/cpp/include which keeps the external files in the same directory.