bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.36k stars 635 forks source link

code generated with `import x "."` fails strict deps checks #1865

Open jmhodges opened 5 years ago

jmhodges commented 5 years ago

Current versions of mockgen (and probably other tools) generate code with imports like:

import (
    x "."
    ...
)

That isn't allowed by rules_go's strict dependencies check, but doesn't actually require a new dependency.

Example error:

GoCompile: missing strict dependencies:
    /private/var/tmp/_bazel_jmhodges/ee957dabdee1b1a9e1f2fe90369cf80f/sandbox/darwin-sandbox/685/execroot/founding/bazel-out/darwin-fastbuild/bin/go/path/to/mock_test.go: import of "."
jmhodges commented 5 years ago

I took a quick look to see where the change was (I think it's special casing "." at builders/compile.go:214) but didn't immediately see where I should add a test. It's late, so maybe it's obvious and I'm just tired, but I'll take a clue on where to put the test.

(If someone fixed this while I slept, I wouldn't be bummed, of course)

jayconrod commented 5 years ago

That would pass the strict deps check in the builder, but I don't think the compiler will be happy with it. We'd need a -D <dir> argument. Possibly also -p command-line-arguments and a change to the importcfg file.

Related #1645.

jmhodges commented 5 years ago

Ah fun!