-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[WIP] Enable more tests in Windows #7412
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
ca7f5b3
to
d63e17c
Compare
e7b8f7d
to
fafd95d
Compare
The remaining tests are flaky so this is enough for 0.2.1 |
b83baa1
to
c58f779
Compare
@justinmk Any blockers on getting this merged for 0.2.1? I do not plan on enabling more tests. |
Just to emphasize, we should fix the root problem rather than working around that in the tests.
I don't see any usages where local function get_pathsep()
return iswin() and '\\' or '/'
end
Is it sending single-quotes to cmd.exe?
Gah, I wonder if
|
test/functional/core/job_spec.lua
Outdated
if not iswin() then | ||
nonexecutable = nonexecutable .. '/non_executable.txt' | ||
end | ||
local nonexecutable_jobid = eval("jobstart(['"..nonexecutable.."'])") |
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.
ternary is less noisy, here.
local nonexecutable_jobid = (iswin()
and eval("jobstart(['./test/functional/fixtures'])")
or eval("jobstart(['./test/functional/fixtures/non_executable.txt'])"))
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.
Will that run 2 jobs?
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.
No, if iswin()
is false then the and ...
is skipped. And eval()
cannot return nil
, unless something else is broken.
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.
What if jobstart
returns 0?
test/functional/core/job_spec.lua
Outdated
nvim('command', "call jobstart(['touch', '.Xtestjob'])") | ||
nvim('command', "sleep 100m") | ||
local touch_cmd = iswin() and "'Out-File -encoding ASCII .Xtestjob'" | ||
or "['touch', '.Xtestjob']" |
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 surprised Lua continues the line. Even if it does, should put parens around it to be explicit.
local touch_cmd = (iswin() and ...
or ...)
test/functional/core/job_spec.lua
Outdated
local touch_cmd = iswin() and "'Out-File -encoding ASCII .Xtestjob'" | ||
or "['touch', '.Xtestjob']" | ||
nvim('command', "call jobstart(" .. touch_cmd .. ")") | ||
nvim('command', "sleep " .. (iswin() and "5" or "100m")) |
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.
5s is expensive for such a trivial test. Can we just check that jobstart()
returned >0
instead? And instead of running "touch", run nvim -u NONE ...
.
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.
call jobstart(['nvim', '-u', 'NONE', '-c', 'q', '.Xtestjob'])
?
Are sleep and delete required if we're checking the job id only?
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 not. IIUC the test only verifies that jobstart()
works without the options dict. So the touch+sleep is pointless, and anything covered by it is well-trodden by other tests.
test/functional/eval/system_spec.lua
Outdated
if helpers.pending_win32(pending) then return end | ||
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")')) | ||
if iswin() then | ||
eq({'part1\npart2\npart3\r'}, eval('systemlist("type '..fname..'")')) |
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.
can't we use cat
on windows?
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.
Yes, but the trailing \r
remains. See #7343 (comment).
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.
Sure, but the more we can do to avoid platform-specific variations, the better.
map = [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]] | ||
result = [[ | ||
:!dir /b bang_filter_spec | | ||
]] |
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.
Can't the whitespace be done once below, instead of twice here? Also a ternary is clearer:
command(iswin() and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]]
or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]])
local result = (iswin() and [[:!dir /b bang_filter_spec |]]
or [[:!ls bang_filter_spec |]])
eq(0 , tlwd()) | ||
eq(globalDir .. '/' .. directories.window, wcwd()) | ||
eq(globalDir .. pathsep .. directories.window, wcwd()) |
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.
Some sort of pathjoin()
function would help, in the future ...
end | ||
eq(true, write_file(fname_bak, 'TTYX')) | ||
-- FIXME: exc_exec('write!') outputs 0 in Windows | ||
if not helpers.iswin() then |
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.
just return
early, to avoid the extra nesting and VCS churn.
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 helpers.iswin() then return end
?
test/functional/helpers.lua
Outdated
@@ -319,6 +319,7 @@ end | |||
-- Dedent the given text and write it to the file name. | |||
local function write_file(name, text, dont_dedent) | |||
local file = io.open(name, 'w') | |||
if file == nil then return false 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.
Was this silently failing before? If not, it will now, which means we would have to explicitly check eq(true, write_file())
everywhere.
Why don't we raise an error (exception) here instead?
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 was failing for ex_cmds/write_spec.lua
because os.remove
did not remove the files. write_file
tried to write on a directory so file:write
raised an error.
- echo "" does not hang in powershell - cmd.exe's echo command does not hang. - job tests default to powershell (WHY?) - wait 5 seconds for powershell to create an empty file - powershell is slow - cannot reliably validate the id returned by jobstart via jobpid, jobstop - if using cmd.exe, waiting for a second should be enough - remaining job tests are unreliable in Windows because any build can pass/fail for same conditions without changes, especially if the error is in stderr
Try nvim's delete() for cross-platform file remove in Windows
a022b7d
to
7fa69fb
Compare
Regarding your note in one of the commit messages:
IIRC that was my fault, I did so for these reasons:
If |
Regarding the it('preserves NULs', function()
- if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
+ -- TODO: Windows: the data is received on_stderr instead of on_stdout. Why?
+ if helpers.pending_win32(pending) then return end |
Unlike #7343, this PR focuses on tests only.
The following types of tests must be updated to work in Windows environment:
/bin/sh
must resolve to an absolute path without spaces otherwise you getshell returned 1
all over the placeset shell=sh
because, unlike nvim, vim respects$SHELL
on Windows and doesn't useshellescape
in most tests by hardcoding the single quotes (WHY???)gf
doesn't work for paths with spaces such asC:\Program Files (x86)\nvim\share\nvim\runtime\defaults.vim
set shellslash
breaks it since its shell defaults should be for cmd.exedelete
os.execute
inhelpers.do_rmdir
works in Windows. What about Unix?rm -rf
hangs while cmd.exe'srd
returns early.cat -
and other shipped tools included in Windows zip/dev/null
nul
in cmd.exe$null
in powershellunreliable forUnreliable for both but seems to be more flaky in win64.has('win64')
?desync with cat.exe so testing is limited to jobstart onlyjobpid(jobstart(['cat', '-'))
is unreliablefeed(G)
and different expected screen output as workaroundData file mismatch - some data files may have been concurrently updated without locking support
fails withIt's fine. I mixed up the shells in core/job_spec.lua"-u NONE --cmd '" .. nvim_set .. "'"
(how?)^
for single character escaping. These two can be combined but it is tedious to escape the entire command this way. There issxe
andsxq
but they don't work well withshellescape
because 1 mishandled double quote can ruin the entire command.FileWriteCmd
E13
in Windowsmklink /d
I don't know why the Appveyor builds hang when I use
helpers.get_pathsep()
so I hardcode the value ofpathsep
local variable in tests that check filepaths such as test/functional/ex_cmds/cd_spec.luaTo minimize diffs, I useset fileformat=unix
or the++opt
variant.\r\n
as eol in Windows is enough for shada on BufWriteCmd, FileAppendCmd, and FileWriteCmd. For some reason,:w!
is required in FileWriteCmd after os.remove in before_each() and teardown().For some reason, nvim does not kill a parallel process created viaIt works for MINGW_32.start /b cmd /s/c "<command>"
, where<command>
is the user's command entered in a cmd.exe session./b
is for not creating a new window. Ifstart /min
for a minimized new window doesn't work out, then I'll try powershell'sStart-Job
orStart-Process
sincecore/job_spec.lua
defaults to powershell anyway.