chore: Add new custom built and test target to make in order to enable easy build or test single nim modules #2913
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.
Description
While chating with @fryorcraken, he popped up, why don't we have an easy way of running single tests.
We all do this in different ways, like me I'm using some alias to achieve this.
So I made this little experiment to add custom targets to our makefile to ease and make common and available this task.
While it's a bit tricky to achieve such with make and nimscript I found a usable solution.
So the target is to check if a single file you're working on builds or you may write unit test and want to run first separately from other tests.
With this enhancement, you just need to run
make build/<path-to-your-file>
ormake test/<path-to-your-file>
Why is it good?
Changes
build/...
andtest/...
targetsHow to test
run:
1a. make build/tests/common/test_tokenbucket.nim
1b. make test/tests/common/test_tokenbucket.nim
Check: ./build/tests/common/test_tokenbucket.nim.bin exists
Suggestions/ideas are welcome
It is not trivial to add parametric target to make, but still possible I'm not aware of the proper solution. If you have any better idea or addon to this, I'm happy to discuss.