Skip to content

Fixing spawn_test for go 1.21#208

Open
pfgray wants to merge 1 commit into
miquella:masterfrom
pfgray:go_1.21_compat
Open

Fixing spawn_test for go 1.21#208
pfgray wants to merge 1 commit into
miquella:masterfrom
pfgray:go_1.21_compat

Conversation

@pfgray
Copy link
Copy Markdown

@pfgray pfgray commented Feb 9, 2024

In go 1.21, go env changed the way it printed values

go version < 1.21:

GOPATH="/vaulted"
...

go >= 1.21:

GOPATH='/vaulted'
...

Which causes spawn_test.go to fail, since it's looking for exactly GOPATH="/vaulted" in go env's output.

This commit updates the test to look for single quotes or double quotes, making it compatible with all versions of go.

Comment thread spawn_test.go Outdated

func TestSpawn(t *testing.T) {
spawnRefreshVar := `GOPATH="/vaulted"`
spawnRefreshVar := `GOPATH=["|']/vaulted`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Isn't the | wrong? ["'] should be correct? Otherwise you will also match |/valued which I don't think you want to do.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

indeed, fixed!

In go 1.21, `go env` changed the way it printed values

go version < 1.21:
```
GOPATH="/vaulted"
...
```

go >= 1.21:
```
GOPATH='/vaulted'
...
```

Which causes `spawn_test.go` to fail, since it's looking for exactly
`GOPATH="/vaulted"` in `go env`'s output.

This commit updates the test to look for single quotes or double quotes,
making it compatible with all versions of go.
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.

2 participants