I am trying to write a generic Makefile that can run multiple different unit tests based on a second term in the make command.
Basically I would like to write something like:
make test target1 # runs unit tests for target 1
make test target2 # runs unit tests for target 2
:
:
:
make test all # runs all unit tests
but I can't find any documentation on how to do this. What I have right now is:
.PHONY: clean test
test-target1:
pytest --cov-report term-missing --cov=a .\target1\
test-target2:
pytest --cov-report term-missing --cov=b .\target2\
test-all:
### I don't know what to put here ###
but this syntax requires you to use make test-target1
with the hyphen included.
EDIT:
Based on some really good advice I now have the updated Makefile:
a: # ...
pytest --cov-report term-missing --cov=a.\UnitTest\a
.PHONY: test
test : $(RUN_ARGS)
@echo "Running unittests for $(RUN_ARGS)..."
but running make test a
returns
Running unittests for ...
make: 'a' is up to date.
and if I change a
to a1
then make test a1
will run the actual unittests. Why is the a
RUN_ARGS not allowed?
For reference, the structure of the code is:
src/a
src/b
src/UnitTest
src/UnitTest/a
src/UnitTest/b