0

I have tests in tests/FILENAME-test.sh and for each one I want to run the script inside a docker container.

How can I refactor this Makefile to not use TEST_OUTPUTS like I have?

Also, how can I make each docker run command run in parallel?

.PHONY: test image

TESTS=$(wildcard tests/*-test.sh)
TEST_OUTPUTS=$(patsubst %.sh,%.out,$(TESTS))

%.out: %.sh image
    @sudo docker run -t box-test /bin/bash "-c" "./$^"

test: $(TEST_OUTPUTS)
    @echo

image:
    @sudo docker build -q -t box-test .
1

Here it is:

.PHONY: test image

TESTS=$(wildcard tests/*-test.sh)

test: $(TESTS)

$(TESTS): image
        @sudo docker run -t box-test /bin/bash "-c" "./$@"

image:
        @sudo docker build -q -t box-test .

And for the docker run commands to run in parallel, just use make -j test (you may specify a maximum number of concurrent runs with -j).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.