It turns out that Busted started cleaning the environment in 2.0rc5 as a
result of Olivine-Labs/busted#62. This, in turn, caused the ffi module
to be reloaded for each spec file, and LuaJIT doesn't appreciate it.
The net effect is an assertion error in LuaJIT.
By using the --helper feature of Busted, we can pre-load some modules
ahead of Busted and prevent it from reloading them--making LuaJIT happy
again.
This is necessary for newer versions of Busted, otherwise assert will be
nil and the tests will die.
Note: this does not mean the tests now work with the latest Busted.
There are still several issues preventing that from happening.
- Removed term.c, term.h and term_defs.h
- Tests for T_* values were removed. screen.c was simplified as a
consequence(the best strategy for drawing is implemented in the UI layer)
- Redraw functions now call ui.c functions directly. Updates are flushed with
`ui_flush()`
- Removed all termcap options(they now return empty strings for compatibility)
- &term/&ttybuiltin options return a constant value(nvim)
- &t_Co is still available, but it mirrors t_colors directly
- Remove cursor tracking from screen.c and the `screen_start` function. Now the
UI is expected to maintain cursor state across any call, and reset it when
resized.
- Remove unused code
- The syntax `gui=` is invalid when setting properties of highlight group.
- Wait for the initial "-- More --" prompt before continuing. Required to avoid
a race condition
Some screen tests such as system/ctrl+c(viml_system_spec.lua) can take some time
to respond(default kill timeout is 2 seconds for an interrupted job) and fail
when running under a slow environment such as travis.
The `system` function is never executed with these tests because the ctrl+c is
queued with the input string that calls it(The `process_interrupts` function
will destroy all previous input when a ctrl+c is found).
It turns out the FreeBSD 10 VM has a symlink for the home directory to
/usr/home. Unfortunately, this breaks the test as arg[0] may not have
the symlink resolved, but the path returned from the exe() call will.
As a result, the comparison fails, even though the result is correct.
Let's fix this by running the absolute path through exe() too, and then
comparing the results.
The systemlist test currently calls the `echo` command which can potentially
complete before being interrupted, causing random test failures.
Use `yes | xargs` instead. A `yes` invocation that is not piped through `xargs`
can produce a huge amount of lines in a very short time, leading memory
starvation when the result is being converted into a list. `xargs` ensures only
one line of output will be produced while allowing interrupt to be tested.
`job_send` is non-blocking and can potentially fail due to the following
`job_stop` call. Since we can't reliably verify that the "exit" event is only
sent after the "stdout" event, mark the test as pending and fix after we can
get a notification about `job_send` status.
The test was hoping to not find a tags file, but didn't actively guard
against it. In my case, I had a tags file present which was causing
different output to be generated. To fix this, let's set the tags
option to look for an unlikely filename.
While running under valgrind, the screen can take significantly longer to
update(especially on travis) so a higher timeout can be required. Also reduce
the timeout when not running on valgrind.
When a test that fails leaves nvim in a 'Press Enter...' state, the whole suite
will hang because the `qa!` command executed before the next test won't be
processed until '<enter>' is sent.
Now the lua client can send a signal with when `Session:exit()` is called, so
the `qa!` request is no longer necessary.
Also:
- Set noswapfile at startup to prevent tests from leaving .s* swap files(should
also improve test environment determinism)
- Use `assert(false, msg) instead of `error(msg)` to report screen assertion
failures.
Problem: In Insert mode, after inserting a newline that inserts a comment
leader, CTRL-O moves to the right. (ZyX) Issue 57.
Solution: Correct the condition for moving the cursor back to the NUL.
(Christian Brabandt)
https://code.google.com/p/vim/source/detail?r=v7-4-492
The primitive C canonicalizer we use to strip out duplicate header
declarations and keep luajit's ffi happy, didn't work properly in this case.
What happened is this (in /usr/include/ctype.h):
__DARWIN_CTYPE_TOP_inline int
isspecial(int _c)
{
return (__istype(_c, _CTYPE_T));
}
Gets preprocessed to something like:
__inline int
isspecial(int _c)
{
return (__istype(_c, _CTYPE_T));
}
On OSX/gcc. The formatter wasn't recognizing this entire function as
something to put on a single line because it naively just checks for
"static" or "inline" for that, but not "__inline".
This error doesn't occur on OSX/clang. Without looking further into it, I
guess that __DARWIN_CTYPE_TOP_inline gets defined to inline on clang, but
__inline on gcc, for some reason.
This helps issue #1572 along.
The second argument to lfs.attributes() serves only to select a specific
part of the normally returned table. It's not a file open flag (e.g.: as for
fopen() in C). Also made the (n)eq checks a bit more idiomatic.
Fixes#1831
Ignoring invalid key sequences simplifies input handling in UIs. The only
downside is having to use "<lt>" everytime a "<" is needed on functional tests.
Ignoring invalid key sequences simplifies input handling in UIs. The only
downside is having to use "<lt>" everytime a "<" is needed on functional tests.
While we're at, using the slightly more portable `command -v` technique
to detect the executable. Also, there's no need to use `io.popen()` if
we aren't going to record the path. Instead, let's use the simpler
`os.execute()` to detect the presence of xclip.
In Lua, all math is floating point. We need to coerce the result of a
division into a integer with the `{get,set}_height` and
`{get,set}_width` window_spec functional tests.
The $GDB env var can be set to run tests under gdbserver. If $VALGRIND is also
set, it will add the --vgdb=yes command-line option to valgrind instead of
starting gdbserver.
See https://github.com/neovim/neovim/issues/1519 for failure report.
Cause : In OSX, /tmp is a symbolic link to /private/tmp, which causes
expected and got results different because of implicit
resolution.
Solution : Resolve path before setting expected value.
Nvim wasn't exiting cleanly in some job tests due to errors.
This can't be noticed until the next commit, which will perform a refactoring to
selectively process K_EVENT, so the `qa!` command executed at the end of each
test blocks forever if there are errors which require the user to press ENTER(in
that state Nvim no longer will process events).
The vim_input function accepts raw terminal input and so is better to emulate
real user, especially because it is not deferred as vim_feedkeys.
Using this function required a number of changes:
- expect() was refactored to use curbuf_contents()
- The vim_eval function in request() was moved to curbuf_contents(). For most
cases this is enough(we only care for synchronizing api calls with user input
when verifying buffer contents).
- <C-@>(NUL) is preprocessed before being passed to replace_termcodes.
- Legacy test 4 had a bug that only became visible when using vim_input, it is
fixed now.
- An extra blank line deletion was required for test 101
The last two items show that vim_feedkeys because it is not 100% equivalent to
receiving terminal input.
Commit @45525853d352 removed usage of the `job_write_cb` for closing stdin due
to a memory error, but that doesn't work anymore because `job_close_in` closes
stdin immediately, possibly trimming input data before it is fully written.
Since most memory issues with jobs have been fixed, re-add the `job_write_cb`
call to ensure stdin is only closed when it should. Also add tests for scenarios
where using the callback makes a difference.
Tests which spin the event loop and stop it in a notification handler have a
chance of re-entering the event loop due to the `vim_eval` call in the
`request()` helper(assuming the request call is what triggered the
notification). Since this will cause an error to be thrown by the lua client,
don't send the extra `vim_eval` request when the loop has been stopped.
Use save_tv_as_string(), same as vimL system(). This also makes
jobsend() more liberal in what it can accept. For example,
`jobsend(j, 123)` is now valid.
Closes#1176
Factor out string_to_list() from f_system()'s implementation
and use that to set job_data. This has the technical advantage of
preserving NULs, and may be more convenient for users.
Required for #1176.
During test setup, we used to call a vimscript function(BeforeEachTest) that
attempted to restore Nvim to it's initial state as much as possible in order to
provide a clean environment for running new tests. This approach has proven to
be unreliable, as some tests leave state that can affect other tests, eventually
causing failures that are difficult to debug.
This commit changes the 'clear' function so it will restart Nvim every time it
is called, which is a slower, but more reliable solution that will simplify
spotting bugs in the future.
Some other improvements/fixes were also performed:
- Whenever an error is detected in a handler passed to "run()", the event loop
will be stopped and the error will be propagated to the main thread.
- Errors and the "cleanup()" function will always send a quit command to the
current Nvim instance. This should prevent memory starvation when running
tests under valgrind(where each Nvim instance can consume a lot of memory).
- Fixed a wrong assertion in server_requests_spec.lua. Previously the failure
was undetected in a notification handler.
- Fixed some tests to expect fully clean registers. The deleted cleanup function
used to put an empty string in every register, but that resulted in a extra
line being added.
It is currently possible for a client to send a response that doesn't match the
current server->client request(at the top of the stack). This commit fixes that
by delaying notifications to until the first `channel_send_call` invocation
returns.
Also remove the "call stack" size check, vim will already break if the call
stack goes too deep.
The options_spec.lua suite has one purpose: Check if the :options commands will
throw any exception(:options is implemented by $VIMRUNTIME/optwin.vim). For this
it is best to use the `vim_command` API function since it will automatically
catch exceptions and forward them via msgpack-rpc.
Also, the option window seems to affect other tests, so call `restart` in the
teardown hook.