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

cmd/go: go test -outputdir -coverprofile fails at compile time when outputdir does not exist #24588

Closed
nodo opened this issue Mar 29, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@nodo
Copy link
Contributor

nodo commented Mar 29, 2018

Description

go test command fails when using the flag -c, if -outpudir is set to a non-existing directory.

What version of Go are you using (go version)?

  • go version go1.10 darwin/amd64
  • go version devel +7e34ac1f4c Wed Mar 28 05:58:35 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"

What did you do?

  1. Create a dummy test file:
package main

import "testing"

func TestHelloWorld(t *testing.T) {
}
  1. Compile the test file with a coverprofile and non-existing directory go test -c -cover -outputdir=./all/profiles/here -coverprofile=profile.txt
  2. See the error

The command above does not report an error with go1.9.4.

What did you expect to see?

I would expect no error when compiling the test, but rather when running it (as it was prior to go1.10).

What did you see instead?

An error occurs:

open all/profiles/here/profile.txt: no such file or directory
nodo pushed a commit to onsi/ginkgo that referenced this issue Mar 29, 2018
This is a workaround for a change in behaviour between go <= 1.9 and go
1.10.

Prior to go 1.9, compiling a test would not fail if the specified
output dir does not exist. However, it does fail in go 1.10.

By failing when the the directory does not exist, we have a consistent
behaviour withing go versions.

See also golang/go#24588
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 29, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Mar 29, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 29, 2018
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 29, 2018
@gopherbot
Copy link

Change https://golang.org/cl/103395 mentions this issue: cmd/go: don't try to initialize cover profile for go test -c

nodo pushed a commit to onsi/ginkgo that referenced this issue Apr 5, 2018
This is a workaround for a change in behaviour between go <= 1.9 and go
1.10.

Prior to go 1.9, compiling a test would not fail if the specified
output dir does not exist. However, it does fail in go 1.10.

By failing when the the directory does not exist, we have a consistent
behaviour withing go versions.

See also golang/go#24588
alamages pushed a commit to alamages/ginkgo that referenced this issue Apr 10, 2018
This is a workaround for a change in behaviour between go <= 1.9 and go
1.10.

Prior to go 1.9, compiling a test would not fail if the specified
output dir does not exist. However, it does fail in go 1.10.

By failing when the the directory does not exist, we have a consistent
behaviour withing go versions.

See also golang/go#24588
@golang golang locked and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants