Split `moon`'s test cases into different files
Feature Request
Split moon's test cases that access different test directories into different files, to reduce clutter.
Summary
Motivation
It's hard to add tests for moon now, as test cases are embedded in a file more than 10kLoC. There is no direct connection between the test case names and the test folders, other than the TestDir::new call in the test function.
Detailed Description
Split moon's test cases and group by test folder, so that each test file only accesses the test folder it's in, like:
test/
mod.rs -- module description
test1.in/ -- test folder
mod.rs -- the test itself
-- files used in tests:
src/
main/
moon.pkg.json
test2.in/ -- another test
...
Related Issues
N/A
Checklist
- [x] I have added all necessary details to make it easy for the maintainers to understand my request.
Some thoughts:
- After splitting, actually, it becomes harder to add new test cases. We should provide a helper function in xtask to generate test templates.
- One advantage of the current pattern is that diffs are very easy to read. After splitting, diffs will be scattered across multiple files.
- We need to consider that different test cases might reuse the same MoonBit project, for example,
hello.inis reused in 7 test cases. - We could consider replacing
expect!withexpect_file!to reduce the size of the.rstest files. - It might be worth moving the test suite from
./crates/moon/tests/test_casesto./teststo reduce directory nesting.
After splitting, actually, it becomes harder to add new test cases. We should provide a helper function in xtask to generate test templates.
IMHO not harder than we currently do. We already copy folders to create new tests anyway.
One advantage of the current pattern is that diffs are very easy to read. After splitting, diffs will be scattered across multiple files.
Really? I often find it harder than only seeing diffs in relevant, short files ;)
We need to consider that different test cases might reuse the same MoonBit project, for example,
hello.inis reused in 7 test cases.
Then all of them may reside in hello.in/mod.rs, for example
We could consider replacing
expect!withexpect_file!to reduce the size of the.rstest files.
Yeah, that can be a thing. But even then the file might still be too long.
@lynzrand You can write a test to demonstrate the new approach. Then I can help migrate some of the tests.
cc @Young-Flash
You can write a test to demonstrate the new approach.
Can I just migrate existing tests?
Can I just migrate existing tests?
Yep!