Skip to content

test: Return root module root dir when using go.work #1125

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

Merged
merged 3 commits into from
May 14, 2025

Conversation

dlipovetsky
Copy link
Contributor

@dlipovetsky dlipovetsky commented May 9, 2025

What problem does this PR solve?:
Fixes the test helper when go.work is used locally.

Previously, the helper returned all the output of go list -m, and when using go.work, the output contains multiple lines, with the directory of the root module on the first line. Now, the helper returns only the first line.

The previous behavior caused the test to fail:

=== Failed
=== FAIL: pkg/handlers/generic/lifecycle/ccm/nutanix Test_templateValues (0.00s)
    handler_test.go:71:
        	Error Trace:	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go:193
        	           				/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go:71
        	Error:      	Received unexpected error:
        	           	open /home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/api
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/common
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/docs
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/hack/third-party/caaph
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/hack/third-party/capa
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/hack/third-party/capx
        	           	/home/dlipovetsky/projects/cluster-api-runtime-extensions-nutanix/hack/tools/charts/cluster-api-runtime-extensions-nutanix/addons/ccm/nutanix/values-template.yaml: no such file or directory
        	Test:       	Test_templateValues

DONE 446 tests, 1 failure in 35.288s
make: *** [make/go.mk:49: test.root] Error 1

Which issue(s) this PR fixes:
Fixes #

How Has This Been Tested?:

The test passes. My go.work:

go 1.24.2

use (
	.
	./api
	./common
	./docs
	./hack/third-party/caaph
	./hack/third-party/capa
	./hack/third-party/capx
	./hack/tools
)

Special notes for your reviewer:

Previously, the helper returned all the output of `go list -m`,
and when using go.work, the output contains multiple lines, with
the directory of the root module on the first line.

Now, the helper returns only the first line.
Copy link
Member

@jimmidyson jimmidyson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jimmidyson jimmidyson enabled auto-merge (squash) May 12, 2025 13:18
jimmidyson and others added 2 commits May 12, 2025 09:34
@dlipovetsky dlipovetsky requested a review from dkoshkin May 13, 2025 14:54
@jimmidyson jimmidyson merged commit 6fcafb7 into main May 14, 2025
22 checks passed
@jimmidyson jimmidyson deleted the dlipovetsky/fix-handler-test-go-work branch May 14, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants