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 Answer 1

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).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .