rouge8 / neotest-rust

Neotest adapter for Rust, using cargo-nextest.
MIT License
91 stars 29 forks source link

#.junit.xml: No such file or directory #20

Closed nerdo closed 1 year ago

nerdo commented 1 year ago

I can't seem to get this working. When I run a test, I get an error saying that a file 3.junit.xml doesn't exist.

I searched for the issue and saw that someone reported an issue with it but they didn't have cargo-nextest installed. I do, v0.9.48.

Did I misconfigure something?

Miaxos commented 1 year ago

Same issue here

rouge8 commented 1 year ago

I can't reproduce. Does this happen with a minimal example or only with some files?

ShortArrow commented 1 year ago

I can't reproduce. Does this happen with a minimal example or only with some files?

I tried to make minimal example, Is this same error? https://github.com/ShortArrow/PoC_neotest_rust_issue_20

rouge8 commented 1 year ago

I can't reproduce. Does this happen with a minimal example or only with some files?

I tried to make minimal example, Is this same error? https://github.com/ShortArrow/PoC_neotest_rust_issue_20

Thanks, I can reproduce with that! I'm not sure when I'll have time to look into this more, but this is a huge help!

rouge8 commented 1 year ago

I can't reproduce. Does this happen with a minimal example or only with some files?

I tried to make minimal example, Is this same error? https://github.com/ShortArrow/PoC_neotest_rust_issue_20

Oh, this issue here is that the build fails, not the test, so there is not result file. I hadn't considered that.

ShortArrow commented 1 year ago

Maybe the same issue? #22

SiasMey commented 1 year ago

I may have just found a clue:

image

or, in lay and text terms: [?25lerror: failed to parse nextest config at C:\Users\sias.mey\AppData\Local\Temp\nvim.0\WFp1tH\1.nextest.tomlCaused by: invalid hex escape character in string: s at line 2 column 13 in ................\Temp\nvim.0\WFp1tH\1.nextest.toml ]0;C:\WINDOWS\SYSTEM32\cmd.exe[?25h

I actually have this happen with the test project in the plugin itself. It does make sense though if the underlying cause is a failure to read the config.

Wel wel wel wel... windows, what have you done now.

[profile.neotest.junit] path = "C:\Users\sias.mey\AppData\Local\Temp\nvim.0\WFp1tH\2.junit.xml"

or, rather... image

Omg... seriously.

SiasMey commented 1 year ago

Fixed:

I will do a PR tomorrow, I cant test on other OS, but this makes it work for me in windows. image

Just swapping " for ' in the config toml

Line 135 of lua/init.lua

nerdo commented 1 year ago

Oh, interesting.

I'll see if I can make a similar tweak on my system (macos) and see if it works - time permitting. Will respond as soon as I can.

nerdo commented 1 year ago

That seems to fix it for me too. I was able to run a test with that change in place!

rouge8 commented 1 year ago

I’d love a PR with the fix and ideally a new test!

nerdo commented 1 year ago

I should have some time this weekend; I will try and do a PR if SiasMay doesn't get to it first.

SiasMey commented 1 year ago

My week exploded, sorry.. But I am very glad that it seems I got to the root cause of the issue for a few folks.

We should probably report upstream, since I am not sure the intent of config parsing should be to allow escape sequences like that. At least, for the moment we know that ' is much safer than " in situations like this.

nerdo commented 1 year ago

No worries, I totally understand.

I submitted a PR (https://github.com/rouge8/neotest-rust/pull/24)

@rouge8 I didn't add tests because I'm unfamiliar with the process in lua and couldn't get make test to run properly in an unmodified repo (details in the PR).

ShortArrow commented 1 year ago

On Arch linux.

I was tried inject this.

writer:write("[profile.neotest.junit]\npath = '" .. junit_path .. "'")
print("[profile.neotest.junit]\npath = '" .. junit_path .. "'")

result was here.

[profile.neotest.junit]
path = "/tmp/nvim.who/2yVsIM/10.junit.xml"
Error executing vim.schedule lua callback: ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: ...e/nvim/lazy/plenary.nvim/lua/plenary/context_manager.lua:47: /tmp/nvim.who/2yVsIM/10.junit.xml: No such file or directory
stack traceback:
[C]: in function 'error'
...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function <...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:44>

image

Therefore, it seems that the escape character is not the cause of not being able to find a file in Linux.

I have two hypotheses.

  1. There is a problem in cooperation with Upstream with Plenary, and it has disappeared before reading the .junit.xml file.
  2. No .junit.xml file is generated

If "no file is generated" has expected behavior then, skip .junit.xml and need to make load feature 11 file or 2,5,8.

I want to make a PR if possible. But don't expect me. I have just started using Lua language. Of course I will make an effort.

SiasMey commented 1 year ago

@ShortArrow I believe what you are seeing is something different from the issue resolved by the quote changes. The result may be the same error, but the cause is totally unrelated.

What we could possibly do in such a case, is output a junit result file that indicated all tests failed due to a compiler issue, but as I said above, that is a little beyond the issue I was experiencing.

That does still happen to me regularly though, I am not good enough at rust yet to avoid all the compilation errors.

rouge8 commented 1 year ago

I can't reproduce. Does this happen with a minimal example or only with some files?

I tried to make minimal example, Is this same error? https://github.com/ShortArrow/PoC_neotest_rust_issue_20

Oh, this issue here is that the build fails, not the test, so there is not result file. I hadn't considered that.

Failing builds will now no longer crash and will now display the build output.

The single vs double quote thing might be an issue with Windows paths? If someone can reproduce it on non-Windows, I might take a look.