Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test failed: can't load package: named files must be .go files:xxx #2006

Closed
shenkonghui opened this issue Jul 29, 2020 · 4 comments · Fixed by #2007
Closed

make test failed: can't load package: named files must be .go files:xxx #2006

shenkonghui opened this issue Jul 29, 2020 · 4 comments · Fixed by #2007
Labels
kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test.

Comments

@shenkonghui
Copy link
Contributor

Which jobs are failing:
unit test
Which test(s) are failing:
make test
Since when has it been failing:
make test
Reason for failure:
when I add a unit test. Has nothing to do with the following path

[root@centos-kubeedge kubeedge]# make test
hack/make-rules/clean.sh
hack/make-rules/test.sh 
running tests cases 
can't load package: named files must be .go files: ./cloud/pkg/cloudhub/common/model
make: *** [test] Error 1

Anything else we need to know:
I find the the reason in hack/lib/golang.sh kubeedge::golang::get_keadm_test_dirs()
when I try to perform this step, not only get the directory, but also get the go file

[root@centos-kubeedge kubeedge]# find -L ./keadm \
    -name '*_test.go' -print | xargs -0n1 dirname | uniq
./keadm/cmd/keadm/app/cmd/debug/collect_test.go
./keadm/cmd/keadm/app/cmd/util
@shenkonghui shenkonghui added the kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. label Jul 29, 2020
@daixiang0
Copy link
Member

daixiang0 commented Jul 29, 2020

The issue title is so confused util i see the details.

I think it is not a failing-test, it is related to how you add a test case or test file indeed.

So, you may fille how you add test case/file, rather than writing make test in each description.

@shenkonghui shenkonghui changed the title make test failed make test failed: can't load package: named files must be .go files:xxx Jul 29, 2020
@shenkonghui
Copy link
Contributor Author

The issue title is so confused util i see the details.

I think it is not a failing-test, it is related to how you add a test case or test file indeed.

So, you shoulmay fille how you add test case/file, rather than writing make test in each description.ok I only add

ok, I only add one unit test, in ./keadm/cmd/keadm/app/cmd/debug/collect_test.go

package debug

import (
	types1 "github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/common"
	"testing"
)

func TestVerificationParameters(t *testing.T) {
...
}

when I make test it is failed, i try to remove this unit test. it is successful

I print ${KUBEEDGE_ALL_TESTCASES[@]} in kubeedge::golang::run_test, and find this unit test can not get dir and get go file.

[root@centos-kubeedge kubeedge]# make test
hack/make-rules/clean.sh
hack/make-rules/test.sh 
running tests cases 
./cloud/pkg/cloudhub/common/model ./cloud/pkg/edgecontroller/manager ./edge/pkg/devicetwin ./edge/pkg/devicetwin/dtclient ./edge/pkg/devicetwin/dtcommon ./edge/pkg/devicetwin/dtcontext ./edge/pkg/devicetwin/dtmanager ./edge/pkg/devicetwin/dtmodule ./edge/pkg/devicetwin/dttype ./edge/pkg/devicetwin ./edge/pkg/edgehub/clients/wsclient ./edge/pkg/edgehub/common/http ./edge/pkg/edgehub ./edge/pkg/eventbus/common/util ./edge/pkg/metamanager/dao ./edge/pkg/metamanager ./edge/pkg/servicebus/util ./keadm/cmd/keadm/app/cmd/debug/collect_test.go
can't load package: named files must be .go files: ./cloud/pkg/cloudhub/common/model
make: *** [test] Error 1

Finally positioned cmd find -L ./keadm \ -name '*_test.go' -print | xargs -0n1 dirname | uniq in kubeedge::golang::get_keadm_test_dirs()
I am not sure about the usage of xarg -0

@shenkonghui
Copy link
Contributor Author

Try to modify it and try it, no -0 is normal, I’m not sure why added -0

[root@centos-kubeedge kubeedge]# find -L ./keadm -name '*_test.go'  | xargs -0  dirname
./keadm/cmd/keadm/app/cmd/debug/collect_test.go
./keadm/cmd/keadm/app/cmd/util
[root@centos-kubeedge kubeedge]# find -L ./keadm -name '*_test.go'  | xargs -0  
./keadm/cmd/keadm/app/cmd/debug/collect_test.go
./keadm/cmd/keadm/app/cmd/util/common_test.go

[root@centos-kubeedge kubeedge]# find -L ./keadm -name '*_test.go'  | xargs dirname
./keadm/cmd/keadm/app/cmd/debug
./keadm/cmd/keadm/app/cmd/util

@fisherxu
Copy link
Member

I think print0 | xargs -0n1 or print | xargs -n1 are all fine. @shenkonghui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants