-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RDY] test: win: use cmd.exe by default in job_spec.lua #8120
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
Conversation
Somehow the exit code is wrong for these two tests on the 32bit build:
should we leave those "pending" for now? |
@justinmk Sure, but I'll do it later. I want to see if it happens in 32-bit build only. Old tests aren't running.
|
Exit codes are still inconsistent even with cmd.exe but this is more consistent on stdout than powershell. I'll create |
Weird. I wonder if we should just write our own |
test/functional/core/job_spec.lua
Outdated
@@ -138,7 +139,7 @@ describe('jobs', function() | |||
end) | |||
|
|||
it('allows interactive commands', function() | |||
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)") | |||
nvim('command', "let j = jobstart(['"..nvim_cat.."', '-'], g:job_opts)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't foo.cmd
require a shell? So I would not expect this to work, the jobstart({list})
form skips the shell.
That's one reason why including cat.exe
was important.
And changing these invocations to use the shell form of jobstart({string})
changes the nature of the tests, so we don't want to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll keep the list form and run the batchfile with cmd.exe directly. It should be fine if the path of the tempfile doesn't have to be escaped.
548ac58
to
c68f10e
Compare
|
@justinmk How does |
@janlazo Do you mean grandchildren? We will need to iterate through the process tree. See The above will be implemented in #8107 . If you meant something else, please give a specific example. |
79ac88b
to
2cc77ff
Compare
test/functional/core/job_spec.lua
Outdated
nvim('command', 'call jobsend(j, "'..(iswin() | ||
and [[a\n\nc\n\n]] | ||
or [[a\n\nc\n\n\n\nb\n\n]] | ||
)..'")') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would rather keep the test pending than have a lot of special-case code that is difficult to follow, just to get the test working. Maybe something can be improved in the future so that the test can pass without requiring lots of weird workarounds.
That should be the last of it (unless cat.exe fails again or find.exe errors on |
d4ec323
to
db27b09
Compare
075e5c3
to
63d3b76
Compare
test/functional/core/job_spec.lua
Outdated
return os.execute((iswin() | ||
and 'tasklist /nh /fi "PID eq '..pid..'" | findstr '..pid..' > nul' | ||
or 'ps -p '..pid..' > /dev/null')) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#8107 provides nvim_get_proc({pid})
which can be used in the tests via helpers.meths.get_proc()
. It returns helpers.NIL
if the process doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to return an exit code though.
Need something like nvim_get_proc(pid) == helpers.NIL and 1 or 0
.
Or I can use it directly on the jobpid test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need an exit code? If nvim_get_proc
returns NIL
then the process wasn't found. Non-NIL means it was found.
test/functional/core/job_spec.lua
Outdated
return os.execute((iswin() | ||
and 'taskkill /f /t /pid '..pid..' > nul' | ||
or 'ps -p '..pid..' > /dev/null')) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be easy to expose nvim_kill_proc()
if this turns out to be unreliable.
Can revert this after neovim#8120.
This reverts commit ae409b5. This PR (neovim#8120) defaults to cmd.exe for job_spec.lua
66a5437
to
bf83b3e
Compare
test/functional/core/job_spec.lua
Outdated
nvim('command', 'call jobsend(j, "abc\\nxyz")') | ||
eq({'notification', 'stdout', {0, {'abc', 'xyz'}}}, next_msg()) | ||
eq({'notification', 'stdout', {0, iswin() and {'abc', ''} or {'abc', 'xyz'}}}, next_msg()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should used expect_msg_seq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this line only? This is expected behaviour for find.exe
because the string has to end with newline (or some character for find.exe to receive the input). As for the stdout after jobstop, I don't know why.
I can experiment with expect_msg_seq
for both stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 2nd thought, I'll revert it. Leave it for cat
when the situation improves. There's enough tests for find.exe anyway.
test/functional/core/job_spec.lua
Outdated
-- find.exe can't handle 3+ consecutive newlines consistently | ||
nvim('command', "let j = jobstart(['find', '/v', ''], g:job_opts)") | ||
nvim('command', [[call jobsend(j, "a\n\nc\n\n")]]) | ||
expect_msg_seq( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not consistent then just mark it pending. The entire purpose of this test is to check that newlines are preserved (consistently).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll revert it back to pending. Revist when testing with cat.exe gets better.
test/functional/core/job_spec.lua
Outdated
nvim('command', "call jobstop(j)") | ||
if iswin() then | ||
eq({'notification', 'stdout', {0, {'final nl', ''}}}, next_msg()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This output has the newline, doesn't it? That defeats the purpose of the test. Should just be pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's leftover from stdout when find.exe exits for some reason. Don't recall this happening on a regular cmd.exe window. Strange that this doesn't happen on jobclose(g:job_id, "stdin")
test/functional/core/job_spec.lua
Outdated
-- clean up after ourselves | ||
os.execute('kill -9 '..pid..' > /dev/null') | ||
os_kill(pid) | ||
neq(0, os_ps(pid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be NOT found since we killed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm checking if the os_kill
did work. Is there a better way to do it or do you want to check the exit code of os_kill
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janlazo Ah, I didn't realize os_ps
was returned the exit code, I thought it returned a pid
. Anyways nvim_get_proc
should be used instead.
test/functional/core/job_spec.lua
Outdated
\ jobstart('Start-Sleep -Milliseconds 70; exit 4'), | ||
\ jobstart('Start-Sleep -Milliseconds 50; exit 5'), | ||
\ jobstart('Start-Sleep -Milliseconds 30; exit 6'), | ||
\ jobstart('Start-Sleep -Milliseconds 10; exit 7') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be unreliable because powershell startup takes 600ms at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump the sleep timeout to (1)700, (1)500, (1)300, (1)100 or use cmd.exe and ping instead?
The timeout test for jobwait lasts up to 2-3s so it's long wait either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think cmd.exe would be a better choice here.
The timeout test for jobwait lasts up to 2-3s so it's long wait either way.
Yes but I'm thinking of the variance in event ordering, e.g. if powershell starts 20ms faster in one case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely because of Powershell's lazy-loading and Appveyor-specific modules. Can't prevent them with -NoProfile
.
test/functional/core/job_spec.lua
Outdated
@@ -775,22 +840,36 @@ describe("pty process teardown", function() | |||
end) | |||
|
|||
it("does not prevent/delay exit. #4798 #4900", function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use nvim_get_proc_children instead of a screen test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the PIDs? It won't work with the child process launched with start (cmd.exe). Have to rethink this test for Windows. Anything launched with start
should be killed separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean, but if !start
is detached from nvim somehow, such that it wouldn't prevent nvim from exiting (if there were a nvim bug in its jobs teardown routine), then that defeats the purpose of the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvim will exit completely and !start
terminates after running the program (ie. ping) but the program that start
does run (ie ping) will not necessarily terminate if nvim terminates.
That said, closing :terminal
seems to terminate programs run with start /b
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the program that start does run (ie ping) will not necessarily terminate if nvim terminates.
That defeats the purpose of the test :)
This reverts commit ae409b5. This PR (neovim#8120) defaults to cmd.exe for job_spec.lua
This reverts commit ae409b5. This PR (neovim#8120) defaults to cmd.exe for job_spec.lua
cmd.exe (shell) is faster and more reliable than powershell (.NET frontend). It's best for short and basic tests that don't require non-trivial scripting. cmd.exe doesn't support sleep so use powershell's Start-Sleep as substitute.
This reverts commit ae409b5. This PR (neovim#8120) defaults to cmd.exe for job_spec.lua
Use ping to test job detach Use find.exe as an alternative to cat.exe Use nvim_get_proc to check pid
fda26ed
to
73d48b7
Compare
Ref #7412 (comment), #8034
Need #8107 for
jobstop
to return exit code 0 if the program successfully exits and returns exit code 0 if run from a shell (ex. cmd.exe, bash).Testing to see if switching to cmd.exe improves testing with job API and cat.exe on Windows.
I'm giving up on NULs and newlines for jobsend (list argument). cat.exe still has the
invalid channel id
error,write_file
truncates the string with\0
and find.exe truncates the input string after\0
.start
(cmd.exe builtin) reaps its child processes with/b
(I can't find them with tasklist) so I'm using/min
instead for a minimized window. Redirecting tonul
shouldn't be necessary. If that's intended with thejobstop()
test, so be it.Not sure what's the expected behaviour for start (cmd.exe builtin) because nvim is not reaping the child processes on exit after
:qa!
, even on nested nvim termnal. Seems to have different semantics from fork (or what bash does with&
). Perhaps powershell is better suited herebut I don't know how (yes, there'sStart-Process
but I can't pass arguments to the external program).I can useLeave it for later. I disabled the pty teardown test.Start-Job
so if the session terminates, the jobs die too. Is that close enough?more.com (like less) is the default pager in Windows so it can be used to display files. That leaves the NUL tests for cat if more can't do it.
fnamemodify doesn't adjust slashes and it's the same on Vim too. Have to use expand() again.