vendredi 11 septembre 2020

Makefile: Terminates after running commands "go test ./..."

I encountered a problem running "go test" from a makefile. The idea behind all this is to start a docker container, run all tests against it and then stop & remove the container.

The container gets started and the tests run, but the last two commands (docker stop & rm) aren't executed.
Make returns this message: make: *** [test] Error 1

Is it "go test" which terminates the makefile execution?

.PHONY: up down test

up:
    docker-compose up

down:
    docker-compose down

test:
    docker run -d \
        --name dev \
        --env-file $${HOME}/go/src/test-api/testdata/dbConfigTest.env \
        -p 5432:5432 \
        -v $${HOME}/go/src/test-api/testdata/postgres:/var/lib/postgresql/data postgres
    
    # runs all tests including integration tests.
    go test ./... --tags=integration -failfast -v
    # stop and remove container
    docker stop `docker ps -aqf "name=dev"`
    docker rm `docker ps -aqf "name=dev"`

Aucun commentaire:

Enregistrer un commentaire