tcncloud/wollemi

gofmt removes same package from test targets

Closed this issue · 4 comments

Given a library and a test target that looks like this:

go_library(
    name = "lib",
    srcs = glob(
        [
            "*.go",
        ],
        exclude = ["*_test.go"],
    ),
    # ...
)

go_test(
    name = "test",
    srcs = glob(
        [
            "*_test.go",
        ],
        exclude = ["external_test.go"],
    ),
    deps = [
        ":lib",
        # ...
    ],
)

gofmt removes the :lib dependency. I assume it wants the non-test files to be added to srcs, however that also requires to add deps directly to the deps section which can be rather large in number.

Is this the intended behavior? Is this a bug?

I'm still looking if it happens everywhere or only in certain targets, but this is definitely a change in behavior since 0.2.1.

Thanks @sagikazarmark. That's definitely not intended behavior. Wollemi has never really handled packages which contain a mixture of internal and external tests correctly. That's generally when this issue occurs. I have a fix currently in progress which I hope to have done soon.

Thanks again @sagikazarmark. The issue you described should now be fixed in v0.7.0 but if your specific case still persists let me know and I will re-open.

Thanks for the quick fix! I'll give it a try.

Seems to be working correctly, thanks!