Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@nodo

Description

@nodo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions