Postgresql Makefile:在运行命令后终止;去测试一下;
从makefile运行“go test”时遇到问题。这一切背后的想法是启动一个docker容器,对其运行所有测试,然后停止并移除该容器 容器启动并运行测试,但最后两个命令(docker stop和rm)未执行。Postgresql Makefile:在运行命令后终止;去测试一下;,postgresql,go,testing,makefile,Postgresql,Go,Testing,Makefile,从makefile运行“go test”时遇到问题。这一切背后的想法是启动一个docker容器,对其运行所有测试,然后停止并移除该容器 容器启动并运行测试,但最后两个命令(docker stop和rm)未执行。 Make返回此消息: make:**[测试]错误1 终止makefile执行的是“go test”吗 .PHONY: up down test up: docker-compose up down: docker-compose down test: doc
Make返回此消息:
make:**[测试]错误1
终止makefile执行的是“go test”吗
.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"`
假设您希望“生成测试”返回测试状态,请考虑以下更改为MaxFrime/P>
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 ; echo "$$?" > test.result
# stop and remove container
docker stop `docker ps -aqf "name=dev"`
docker rm `docker ps -aqf "name=dev"
exit $$(cat test.result)
它使用test.result文件捕获测试的退出代码尝试将
| | true
添加到行尾以抑制返回代码,并查看是否有差异。前缀go test
使用-
忽略错误,-go test
@LaurenzAlbe解决了我的问题。非常感谢,祝你周末愉快@米拉格也工作!我将使用这个解决方案,因为输出更加明确。