Go测试在Makefile中找不到测试包。

huangapple go评论81阅读模式
英文:

Go test does not find package tests in Makefile

问题

我有以下的Makefile:

SHELL := /bin/bash

boot:
    @go run main.go

test:
    @go test ./...

test-conf:
    @go test --verbose conf

test-httpd:
    @go test --verbose ./httpd

.PHONY: test test-conf test-httpd

奇怪的是,make test 可以正常工作,但是 make test-conf 或者 make test-httpd 都会显示 "github.com/bodokaiser/foobar [no test files]"。

当我在工作目录中运行 go test ./conf 时,它可以正常工作 - 那么 Makefile 为什么不能工作呢?

我需要怎么做才能让 Makefile 中的 go test 与包一起正常工作?

PS:如果可能的话,我想避免在所有路径前面使用 $(pwd) 或其他东西...

英文:

I have following Makefile:

SHELL := /bin/bash

boot:
    @go run main.go

test:
    @go test ./...

test-conf:
    @go test --verbose conf

test-httpd:
    @go test --verbose ./httpd

.PHONY: test test-conf test-httpd

Strangely enough make test works without problems however make test-conf or make test-httpd will both result in "github.com/bodokaiser/foobar [no test files]".

When I run go test ./conf from the working dir it works - shouldn't the makefile work too then?

What do I need to do to get go test working with packages in a Makefile?

PS: I would like to avoid using $(pwd) or something in front of all paths if possible...

答案1

得分: 3

test-httpdtest-conf不起作用,因为你不能在go test中使用--verbose,只能使用-v

英文:

test-httpd and test-conf don't work, as you can't use --verbose with go test, only -v.

huangapple
  • 本文由 发表于 2014年7月8日 16:30:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/24627124.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定