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

Fix rust#cargotest namespace search #613

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dhleong
Copy link

@dhleong dhleong commented Dec 29, 2021

The position.file property seems to often be just a file name; for files
like mod.rs this would throw an error due to the way the special casing
was set up; to fix this (and to assist with building the full module
path for 'nearest' and 'file' tests) I've expanded to the full path
(which is what the code seems to have been expecting).

Next, with the full path to the file in hand, the way it searched for
Cargo.toml would just not work on macOS (at least) since it would look
like, eg: Users/name/path/to/Cargo.toml, which glob() would treat as
relative, and so not match. To fix this in a (hopefully)
platform-agnostic way, I've pulled out the prefix before the first
"modules" entry and prepended it to the proposed path.


Make sure these boxes are checked before submitting your pull request:

  • Add fixtures and spec when implementing or updating a test runner
  • Update the README accordingly
  • Update the Vim documentation in doc/test.txt

Copy link
Collaborator

@codeinabox codeinabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this, LGTM though you need to update the expectations in spec/cargotest_spec.vim. Let me know if you need a hand with this.

The position.file property seems to often be just a file name; for files
like mod.rs this would throw an error due to the way the special casing
was set up; to fix this (and to assist with building the full module
path for 'nearest' and 'file' tests) I've expanded to the full path
(which is what the code seems to have been expecting).

Next, with the full path to the file in hand, the way it searched for
Cargo.toml would just not work on macOS (at least) since it would look
like, eg: `Users/name/path/to/Cargo.toml`, which `glob()` would treat as
relative, and so not match. To fix this in a (hopefully)
platform-agnostic way, I've pulled out the prefix before the first
"modules" entry and prepended it to the proposed path.
@dhleong dhleong force-pushed the dhleong/fix-cargotest-namespace branch from e016ed6 to f4eb920 Compare March 19, 2022 18:36
@dhleong
Copy link
Author

dhleong commented Mar 20, 2022

Hi @codeinabox sorry for the long delay—I've been a bit busy with Real Life and this fell off my radar.

I found some time recently to finally figure out how to run the unit tests, and investigated this a bit further. It seems like the reason the unit tests work fine but I run into errors in practical use is autochdir. I automatically change directory whenever I move buffers, so expand('%') is always just the filename for me. However, the unit test environment does not have this logic, and so when it does view src/file.rs the buffer name (even made relative to the current directory with ":.") still contains src/file.rs.

I can probably proceed with updating the fixtures/tests to pass using my approach here of forcing absolute paths, but I wonder if there are other runners that have this brittleness, assuming noautochdir. Also, I couldn't quite verify this behavior in the tests; I would've expected calling set autochdir in the before hook would work, but nothing seems to change. I did verify, however, that running nvim -u NONE and executing :e src/cli.rs | echo expand('%:.') with and without set autochdir before it will result in cli.rs and src/cli.rs, respectively 🤔

@dhleong
Copy link
Author

dhleong commented Mar 20, 2022

Also it seems that vim-flavor v3.0.0 doesn't work anymore due to changes on github's side:

fatal: remote error: 
[1440]()  The unauthenticated git protocol on port 9418 is no longer supported.
[1441]()Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

Locally, I had to install a newer version of ruby and install the latest vim-flavor there to get the tests to run.

@codeinabox
Copy link
Collaborator

Also it seems that vim-flavor v3.0.0 doesn't work anymore due to changes on github's side:

fatal: remote error: 
[1440]()  The unauthenticated git protocol on port 9418 is no longer supported.
[1441]()Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

Locally, I had to install a newer version of ruby and install the latest vim-flavor there to get the tests to run.

Thank you for spotting this, I have fixed the build

@codeinabox
Copy link
Collaborator

@dhleong keen to get this merged in though there is still one failing test, could you please look into this and let me know if you need a hand

@dhleong
Copy link
Author

dhleong commented Nov 23, 2022 via email

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.

None yet

2 participants