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

find correct import path for _test packages #46

Merged

Conversation

tadeokondrak
Copy link
Contributor

When using _test packages that used types from the corresponding non-_test package before this commit, autogold would pass the wrong package name to valast and the replacements would be in the form Type{} instead of pkg.Type{}.

We now look for the package containing the tested file rather than using the non-test package in the same directory.


Fixes #25.

I included a test for getPackageNameAndPath, but there's no test using actual files. Let me know if I should add one - it'd require two files and all the current tests only need one, so I haven't tried yet.

I have tested this on my project and it does work.

  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

@tadeokondrak tadeokondrak force-pushed the correct-import-path-for-blackbox-tests branch from 9b1c5e4 to 844af9a Compare July 14, 2023 03:44
@tadeokondrak
Copy link
Contributor Author

tadeokondrak commented Jul 14, 2023

Was worried the CI failure (flag provided but not defined: -update) had something to do with my last PR but it's actually that I'm adding a _test package in internal for test purposes that doesn't actually import autogold.

What should I do here? I could add a blank import to make the problem go away, or set CI to list the packages it's testing, but neither of those seem good.

@slimsag
Copy link
Member

slimsag commented Jul 14, 2023

Adding a blank import sounds fine to me.

When using _test packages that used types from the corresponding
non-_test package before this commit, autogold would pass the wrong
package name to valast and the replacements would be in the form Type{}
instead of pkg.Type{}.

We now look for the package containing the tested file rather than
using the non-test package in the same directory.
@tadeokondrak tadeokondrak force-pushed the correct-import-path-for-blackbox-tests branch from 844af9a to 8eee69c Compare July 14, 2023 15:21
@codecov-commenter
Copy link

Codecov Report

Merging #46 (8eee69c) into main (f28e503) will increase coverage by 0.60%.
The diff coverage is 66.66%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   32.81%   33.41%   +0.60%     
==========================================
  Files           6        7       +1     
  Lines         384      392       +8     
==========================================
+ Hits          126      131       +5     
- Misses        230      232       +2     
- Partials       28       29       +1     
Impacted Files Coverage Δ
expect.go 37.62% <66.66%> (+1.21%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@slimsag slimsag merged commit d890cc7 into hexops:main Jul 28, 2023
2 checks passed
michaellzc pushed a commit to michaellzc/autogold that referenced this pull request Sep 6, 2023
When using _test packages that used types from the corresponding
non-_test package before this commit, autogold would pass the wrong
package name to valast and the replacements would be in the form Type{}
instead of pkg.Type{}.

We now look for the package containing the tested file rather than
using the non-test package in the same directory.
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

Successfully merging this pull request may close these issues.

valast: missing import path when inlining a value from a different package
3 participants