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

rf: does not refactor test files #1

Closed
mdempsky opened this issue Nov 20, 2020 · 2 comments
Closed

rf: does not refactor test files #1

mdempsky opened this issue Nov 20, 2020 · 2 comments

Comments

@mdempsky
Copy link
Collaborator

In the test case below, rf currently only refactors the x.go and p/x.go. It doesn't refactor any of the _test files.

It seems like the logic around test packages in rf/refactor needs fixing (or maybe you had fixed this in your local x/tools copy?). I can try digging into this, but thought I'd file an issue first in case you know what needs to be done already.

mv X Y
-- go.mod --
module example.com/m
-- x.go --
package m

var X int
var _ = X
-- x_test.go --
package m

var _ = X
-- y_test.go --
package m_test

import "example.com/m"

var _ = m.X
-- p/x.go --
package p

import "example.com/m"

var _ = m.X
-- p/x_test.go --
package p

import "example.com/m"

var _ = m.X
-- p/y_test.go --
package p_test

import "example.com/m"

var _ = m.X
@mdempsky
Copy link
Collaborator Author

Okay, there are two related issues here:

  1. refactor.go is skipping over all the test packages, because their ID ends in "]".
  2. "m" and "m [m.test]" are type checked as two separate packages, so they have separate types.Object instances representing objects defined within them. This messes up the TypeInfo.Uses[id] == item.Obj checks in refactorings.

This seems tricky to handle in full generality.

@mdempsky
Copy link
Collaborator Author

Fixed by 8880f26.

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

No branches or pull requests

1 participant