Commit Graph

581 Commits

Author SHA1 Message Date
Björn Linse
55677ddc46 Add new marktree data structure for storing marks
This is inspired by Atom's "marker index" data structure to efficiently
adjust marks to text insertions deletions, but uses a wide B-tree
(derived from kbtree) to keep the nesting level down.
2020-01-14 12:57:31 +01:00
Jan Edmund Lazo
1aacab49ea
vim-patch:8.1.1579: dict and list could be GC'ed while displaying error
Problem:    Dict and list could be GC'ed while displaying error in a timer.
            (Yasuhiro Matsumoto)
Solution:   Block garbage collection when executing a timer.  Add
            test_garbagecollect_soon(). Add "no_wait_return" to
            test_override(). (closes vim/vim#4571)
adc6714aac
2020-01-05 10:40:53 -05:00
Brian Wignall
001e69cd46 doc: fix typos
close #11459
2019-11-27 22:47:25 -08:00
Justin M. Keyes
019c8d13dd
build/doc/CI: remove/update quickbuild references #11258 2019-10-19 18:04:08 -07:00
Jurica Bradarić
fe074611cd vim-patch:8.1.1371: cannot recover from a swap file #11081
Problem:    Cannot recover from a swap file.
Solution:   Do not expand environment variables in the swap file name.
            Do not check the extension when we already know a file is a swap
            file.  (Ken Takata, closes 4415, closes vim/vim#4369)
99499b1c05
2019-10-05 20:35:48 -07:00
Daniel Hahler
f96d1e6bc4
tui: fix handling of bg response after suspend (#11145)
`tui_terminal_after_startup` gets called right after resuming from
suspending (via `Ctrl-z`) already (not delayed as with the startup
itself), and would set `waiting_for_bg_response` to false then directly.
This results in the terminal response not being processed then anymore,
and leaking into Neovim itself.

This changes it to try 5 times always, which means that it typically
would stop after a few characters of input from the user typically, e.g.
with tmux, which does not send a reply.

While it might be better to have something based on the time (e.g. only
wait for max 1s), this appears to be easier to do.

Fixes regression in 8a4ae3d.
2019-10-03 08:04:24 +02:00
Daniel Hahler
b069e9b20f tests: unit: NVIM_TEST_TRACE_LEVEL: default to 0 #11144
Traces are not useful normally (unless debugging/fixing tests), but only add
overhead.  Disable them by default.
2019-10-02 22:41:57 -07:00
Daniel Hahler
8a4ae3d664
tui: improve handle_background_color: short-circuit (#11067)
* handle_background_color: short-circuit if handled already

* Unit tests for handle_background_color

* set waiting_for_bg_response to false in tui_terminal_after_startup
  By then it should have been received.
2019-09-30 22:00:55 +02:00
Daniel Hahler
ed11721b6b
tests: unit: fix preprocess: pass -m32 for 32bit ABI (#11073) 2019-09-22 14:57:44 +02:00
Daniel Hahler
0b71bb73e8
tests: improve error message with literat "~" directory (#11032) 2019-09-17 00:39:33 +02:00
Daniel Hahler
dcc8fcf0b9 tests: assert:set_parameter('TableFormatLevel', 100) #10925
luassert uses 3 by default, which is often not enough.

Instead of documenting how to increase it, let's use a more fitting
(sane) default of 100 levels.
2019-09-03 04:29:49 -07:00
Daniel Hahler
e85b4e749e
tests: unit.helpers: provide string with write errors (#10715)
This might help to have more information in case of errors, like
mentioned in https://github.com/neovim/neovim/commit/eec529cf9e.
2019-08-06 17:42:32 +02:00
Justin M. Keyes
f6c9412436 test/mbyte_spec: skip broken test on QuickBuild
Forgot `return` in eec529cf9e.
2019-08-06 00:28:00 +02:00
Justin M. Keyes
eec529cf9e test/mbyte_spec: skip broken test on QuickBuild
14:13:04,119 INFO  - # ./test/unit/helpers.lua @ 760: mbyte utf_char2bytes for chars 0xa000 - 0xafff
    14:13:06,307 WARN  - E908: using an invalid value as a String
      /usr/home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/.deps/usr/bin/luajit:
      ./test/unit/helpers.lua:459: write() error: 32: Broken pipe
    14:13:06,308 WARN  - stack traceback:
    14:13:06,308 WARN  - 	[C]: in function 'throw'
    14:13:06,308 WARN  - 	...quests-automated/.deps/usr/share/lua/5.1/busted/core.lua:149: in function 'error'
    14:13:06,308 WARN  - 	...ts-automated/.deps/usr/share/lua/5.1/luassert/assert.lua:171: in function 'assert'
    14:13:06,308 WARN  - 	./test/unit/helpers.lua:459: in function 'write'
    14:13:06,308 WARN  - 	./test/unit/helpers.lua:626: in function 'hook'
    14:13:06,308 WARN  - 	./test/unit/helpers.lua:574: in function <./test/unit/helpers.lua:557>
    14:13:06,308 WARN  - 	[C]: in function 'type'
    14:13:06,308 WARN  - 	...d/.deps/usr/share/lua/5.1/busted/outputHandlers/base.lua:57: in function 'copyElement'
    14:13:06,308 WARN  - 	...d/.deps/usr/share/lua/5.1/busted/outputHandlers/base.lua:66: in function 'format'
    14:13:06,308 WARN  - 	...d/.deps/usr/share/lua/5.1/busted/outputHandlers/base.lua:172: in function 'fn'
    14:13:06,308 WARN  - 	...-requests-automated/.deps/usr/share/lua/5.1/mediator.lua:103: in function 'publish'
    14:13:06,308 WARN  - 	...quests-automated/.deps/usr/share/lua/5.1/busted/core.lua:201: in function 'safe'
    14:13:06,308 WARN  - 	...quests-automated/.deps/usr/share/lua/5.1/busted/core.lua:312: in function 'execute'
    14:13:06,308 WARN  - 	...sts-automated/.deps/usr/share/lua/5.1/busted/execute.lua:58: in function 'execute'
    14:13:06,308 WARN  - 	...ests-automated/.deps/usr/share/lua/5.1/busted/runner.lua:197: in function <...ests-automated/.deps/usr/share/lua/5.1/busted/runner.lua:11>
    14:13:06,308 WARN  - 	./.deps/usr/lib/luarocks/rocks/busted/2.0.0-1/bin/busted:3: in main chunk
    14:13:06,308 WARN  - 	[C]: at 0x004041a0
    14:13:06,323 WARN  - Terminated
    14:13:06,325 INFO  - Executing post-execute action...
    14:13:06,526 INFO  - Checking step execute condition...
    14:13:06,526 INFO  - Step execute condition satisfied, executing...
    14:13:06,706 INFO  - Executing pre-execute action...
    14:13:06,706 INFO  - Running step...
2019-08-05 04:19:36 +02:00
Daniel Hahler
f4942a63f9 build/tests: remove pre/uv.h #10531
Initially done in 28e59cb22, but does not appear to be necessary
anymore.

Uses UV_EEXIST directly, just like UV_ENOENT.
2019-07-28 11:10:22 +02:00
Justin M. Keyes
2e171a6fd1 test: cleanup, reduce verbosity 2019-06-01 21:59:42 +02:00
Justin M. Keyes
7cc01c704c Merge #9709 'fileio: use os_copy to create backups'
ref #8288
2019-05-20 22:33:19 +02:00
Justin M. Keyes
fd04877eb0 test: remove use of require('test.helpers')
The test.functional.helpers and test.unit.helpers modules now include
all of the public functions from test.helpers, so there is no need to
separately require('test.helpers').
2019-05-18 15:48:13 +02:00
Justin M. Keyes
bba75eb184 lua/stdlib: Introduce vim.shared
This is where "pure functions" can live, which can be shared by Nvim and
test logic which may not have a running Nvim instance available.

If in the future we use Nvim itself as the Lua engine for tests, then
these functions could be moved directly onto the `vim` Lua module.

closes #6580
2019-05-18 15:48:13 +02:00
Justin M. Keyes
2b87485c22 test: Extend {unit,functional}.helpers with global helpers
Automatically include all "global helper" util functions in the
unit.helpers and functional.helpers and modules.  So tests don't need to
expicitly do:

    local global_helpers = require('test.helpers')
2019-05-18 14:51:01 +02:00
Said Al Attrach
2bf18e7843
test: move trim to global helpers 2019-03-30 18:14:20 +01:00
Justin M. Keyes
d44ab5fdea
search.c: remove dead code #5307
has_mbyte is always true.
2019-03-02 03:13:00 +01:00
Justin M. Keyes
89515304e4 os/env: use libuv v1.12 getenv/setenv API
- Minimum required libuv is now v1.12
- Because `uv_os_getenv` requires allocating, we must manage a map
  (`envmap` in `env.c`) to maintain the old behavior of `os_getenv` .
- free() map-items after removal. khash.h does not make copies of
  anything, so even its keys must be memory-managed by the caller.

closes #8398
closes #9267
2019-02-27 23:29:07 +01:00
Matěj Cepl
a8a38f3465 test: Lua 5.2/5.3 compat
close #9515
ref #9280
2019-01-17 23:06:04 +01:00
James McCoy
25356f2802
Merge pull request #9240 from jamessan/mbyte_spec-failure
unit/mbyte_spec: Run utf_char2bytes test in batches of 0xFFF characters
2018-11-15 16:25:29 -05:00
James McCoy
c344f4b6ae
unit/mbyte_spec: Run utf_char2bytes test in batches of 0xFFF characters
Running the full 0xFFFF set of tests in one process fails on slower
architectures/when there's CPU contention.
2018-11-15 07:06:37 -05:00
Justin M. Keyes
ecdd2df88a
shell/logging: Fix E730 with verbose system({List}) #9009
ref https://github.com/neovim/neovim/issues/9001#issuecomment-421843790

Steps to reproduce:
    :set verbose=9
    :call system(['echo'])
    E730: using List as a String
2018-09-21 09:20:04 +02:00
James McCoy
ba7704ab4e
test: Rename includes/pre/uv-errno.h to includes/pre/uv.h
libuv users are only supposed to directly include uv.h.  In v1.21.0, all
the uv-*.h headers were renamed to uv/*.h, which caused the unit tests
to fail with

    [123/125] Generating post/uv-errno.h
    FAILED: test/includes/post/uv-errno.h
    cd «SRCDIR»/src/neovim/build/test/includes && /usr/bin/clang -std=c99 -E -P «SRCDIR»/src/neovim/test/includes/pre/uv-errno.h -I/usr/include -I/usr/include -o «SRCDIR»/neovim/build/test/includes/post/uv-errno.h
    «SRCDIR»/src/neovim/test/includes/pre/uv-errno.h:1:10: error: 'uv-errno.h' file not found with <angled> include; use "quotes" instead
    #include <uv-errno.h>
             ^~~~~~~~~~~~
             "uv-errno.h"

The intention of the file is to extend libuv's error constants with more
values used by the unit tests.  This can just as easily be achieved
without poking into pseudo-private header files.
2018-07-11 00:26:07 -04:00
ZviRackover
627cc1b3d8 test: build_stl_str_hl (#8703)
Improve coverage of `build_stl_str_hl`.
Minor removal of dead code in the tested function.
2018-07-10 20:46:40 +02:00
Jan Edmund Lazo
3e4a058b01 test: port kword_test to Lua for utf_char2bytes()
Use LuaJIT FFI to create char pointer.
Validate output with utf_ptr2char(), vim_iswordc() and vim_iswordp().
Use const for LuaJIT string-to-char conversion.
2018-07-01 08:45:19 -04:00
Justin M. Keyes
4744142fad lint 2018-04-28 11:01:16 +02:00
Justin M. Keyes
bd17ef75b3 test/unit/undo_spec.lua: fixup after rebase #4985 2018-04-27 13:06:41 +02:00
Christopher Waldon
34f29ac858 test/unit: some unit tests for undo.c #4985 2018-04-27 13:06:31 +02:00
b-r-o-c-k
ad999eaa77 Merge branch 'master' into s-dash-stdin 2018-04-14 14:17:51 -05:00
Justin M. Keyes
7ae4144208 refactor/rename: path_try_shorten_fname() 2018-03-24 14:17:40 +01:00
Justin M. Keyes
998a16c926 refactor/rename: path_is_absolute() 2018-03-24 14:17:40 +01:00
James McCoy
158f8b7ce3 unittest: Ignore all _Float-prefixed types (#8067)
Previously, we ignored only _Float128. But glibc 2.27 added _Float32
and _Float32x.  Rather than play whack-a-mole, ignore everything.
2018-02-25 10:23:12 +01:00
ZyX
2316a38dd1
tests: Make format_string('%q', ...) output more stable
It appears to be different on lua and luajit.
2018-02-02 07:28:56 -05:00
lePerdu
bc17ad31dc os/input.c: parse keycodes in non-string context #7411
cb02137dfa had two mistakes, of the same nature: trans_special() must
be invoked with in_string=false unless the parsing context is a VimL
string. replace_termcodes() and input_enqueue() are low-level
mechanisms where VimL strings do not exist.

keymap.c: adjust double-quote case to satisfy keymap_spec.lua

closes #7410
2018-01-18 01:37:51 +01:00
ZyX
9ea1752d60 *: Provide list length when allocating lists 2018-01-14 01:33:16 +03:00
ZyX
bc52ec6110 *: Fix linter errors 2017-12-24 23:09:26 +03:00
ZyX
7997147245 eval: Replace some tv_list_item_remove() calls
There is nothing wrong with them, just it is generally better to remove
a range then to remove items individually.
2017-12-24 17:52:24 +03:00
ZyX
2923e8533d unittests: Do gc after reporting error, not before
Reason: test may contain cleanup at the endwhich is needed for GC to work 
properly, but is not done if test fails. With collectgarbage() in former 
position it would crash when collecting garbage.
2017-12-24 17:42:23 +03:00
ZyX
32689aa5be unittests: Remove start of trace, not end 2017-12-24 17:13:49 +03:00
ZyX
67fa9e5237 eval: Rename tv_list_remove_items() to tv_list_drop_items()
tv_list_remove_items() may cause confusion with tv_list_item_remove()
2017-12-24 16:38:30 +03:00
ZyX
ac55558c97 eval/typval: Make tv_list_item_remove return pointer to the next item 2017-12-24 14:09:36 +03:00
ZyX
608c3d7baf eval/typval: Remove tv_list_item_free() as it is unused 2017-12-24 14:09:36 +03:00
ZyX
6bf3dc77c4 eval/typval: Make tv_list_item_alloc static
Better write this bit in lua then make reviewers or clint filter out 
tv_list_item_alloc().
2017-12-24 14:09:36 +03:00
ZyX
0c533a488f *: Remove most calls to tv_list_item_alloc
Still left calls in eval/typval.c and test/unit/eval/helpers.lua. Latter is the 
only reason why function did not receive `static` modifier.
2017-12-24 14:09:35 +03:00
ZyX
fbdc3ac4ef tests: Fix linter errors 2017-12-03 20:22:09 +03:00
ZyX
c49e22d396 Merge branch 'master' into s-dash-stdin 2017-12-03 16:49:30 +03:00
ZyX
5ab0f988ca *: Replace all occurrences of NVim with Nvim 2017-11-30 11:53:25 +03:00
ZyX
0b4054e043 unittests: Reduce memory used by vim_str2nr test 2017-11-30 11:48:23 +03:00
ZyX
b588ccddd7 Merge branch 'master' into expression-parser 2017-11-30 02:02:55 +03:00
James McCoy
59f4bd435c unittest: Ignore _Float128 types in ffi
When building with certain GCC versions, a _Float128 type is present
when setting up the ffi for unit tests.

    ./test/unit/helpers.lua:256: declaration specifier expected near '_Float128' at line 396
    /usr/bin/luajit: /usr/share/lua/5.1/busted/runner.lua:99: attempt to concatenate local 'message' (a table value)
    stack traceback:
    	/usr/share/lua/5.1/busted/runner.lua:99: in function 'fn'
    	/usr/share/lua/5.1/mediator.lua:103: in function 'publish'
    	/usr/share/lua/5.1/busted/modules/helper_loader.lua:21: in function 'helperLoader'
    	/usr/share/lua/5.1/busted/runner.lua:147: in function </usr/share/lua/5.1/busted/runner.lua:11>
    	/usr/bin/busted:3: in main chunk
    	[C]: at 0x004044a0

    CMake Error at /<<PKGBUILDDIR>>/cmake/RunTests.cmake:53 (message):
      Running unit tests failed with error: 1.

Since this is being pulled in by a dependency, not directly used by
nvim, just ignore the type.

Closes #7423
2017-11-29 10:07:12 -05:00
ZyX
36a4f3a259 viml/parser/expressions: Make sure that listed nodes may be present
With the new test leaving `assert(false);` for any of the cases makes tests 
crash.
2017-11-26 16:57:42 +03:00
ZyX
cddf84c398 functests: Add some more tests 2017-11-26 16:45:29 +03:00
ZyX
05a3c12118 unittests: Run vim_str2nr tests with GC enabled 2017-11-19 23:36:40 +03:00
ZyX
64158f2b0b unittests: Populate ARGTYPES in child process only 2017-11-19 22:32:02 +03:00
ZyX
03a129aacf Merge branch 'master' into expression-parser 2017-11-19 22:05:22 +03:00
ZyX
7c20f60b88 unittests: Avoid infinite cycle somewhere because of init failure 2017-11-19 22:01:14 +03:00
ZyX
ebb33eddd9 tests: Stabilize float format and %e in format_luav and format_string 2017-11-19 22:00:59 +03:00
ZyX
f20f97c936 *: Fix linter errors 2017-11-19 21:13:27 +03:00
ZyX
a94255a7ac tests: Use single test file for unit and functional parser tests 2017-11-19 20:20:06 +03:00
ZyX
c287893225 viml/parser/expressions,unittests: Do better testing, fix found issues 2017-11-19 19:22:54 +03:00
Marco Hinz
d5b7f28b44 test/unit/path_spec: expect correct buffer size (#7514)
Fixed-size buffers and lfs.currentdir().. does not compute. The tests would fail
if the current working directory was longer than expected.
2017-11-13 02:28:07 +01:00
ZyX
342239a9c5 unittests,viml/parser/expressions: Start adding asgn parsing tests 2017-11-13 01:11:13 +03:00
ZyX
39c75d31be unittests: Fix automatic test case generation 2017-11-13 01:11:13 +03:00
ZyX
556451a7f2 unittests,syntax: Check for sanity of highlight_init_cmdline
Also fixes some errors found.
2017-11-13 01:11:13 +03:00
ZyX
45445e2e03 unittests: Add some more edge test cases 2017-11-12 03:52:26 +03:00
ZyX
c7495ebcc0 viml/parser/expressions: Add support for parsing assignments 2017-11-12 02:18:43 +03:00
ZyX
bbb21e5dd3 unittests: Add a way to show some custom messages only when crashed 2017-11-11 23:50:37 +03:00
ZyX
4aebd00a9e *: Fix linter errors 2017-11-06 20:28:37 +03:00
ZyX
42959d0e8f unittests: Add tests for vim_str2nr 2017-11-06 20:15:05 +03:00
ZyX
7849070f99 tests: Add missing test cases 2017-11-06 01:17:39 +03:00
ZyX
7bc6de7526 api/vim,functests: Add tests for nvim_parse_expression, fix found bugs 2017-11-06 01:17:39 +03:00
ZyX
d98199de9c charset: Refactor vim_str2nr 2017-11-06 01:17:38 +03:00
ZyX
3ecb95298f tests: Fix testlint errors 2017-11-06 01:17:37 +03:00
ZyX
538af1c90a syntax,viml/parser/expressions: Add missing highlight groups
Also adjusts some names.
2017-10-29 22:02:19 +03:00
ZyX
748f3ad5bb syntax,viml/expressions/parser: Create defaults for expr highlighting 2017-10-29 21:30:06 +03:00
ZyX
c202f17c8d unittests: Avoid alloc log checking errors when printing tests 2017-10-29 01:31:31 +03:00
ZyX
568cf73c90 viml/parser/expressions: Fix last error found by KLEE 2017-10-29 01:29:48 +03:00
ZyX
47938e1e22 viml/parser/expressions: Fix some errors spotted by KLEE
Not all of them are fixed yet though.
2017-10-19 10:48:05 +03:00
ZyX
252a76db80 unittests: Free everything and check for memory leaks
Also improves error reporting.
2017-10-16 03:06:34 +03:00
ZyX
248493f155 test/unit/formatc: Fix parsing of most recent viml_parser_highlight 2017-10-16 03:03:34 +03:00
ZyX
fe81380bf5 viml/parser/expressions: Highlight prefix separately from number
Should make accidental octals more visible.
2017-10-16 00:30:55 +03:00
ZyX
1a3635304b charset: Avoid overflow in vim_str2nr 2017-10-16 00:07:32 +03:00
ZyX
76f0466536 Merge branch 'master' into expression-parser 2017-10-15 21:16:27 +03:00
ZyX
3aa2c0d63a viml/parser/expressions,klee: Fix some problems found by KLEE run 2017-10-15 21:11:00 +03:00
ZyX
6c19cbef26 viml/parser/expressions,tests: Add AST freeing, with sanity checks 2017-10-15 20:05:35 +03:00
ZyX
206f7ae76a unittests: Test some edge cases 2017-10-15 19:18:17 +03:00
ZyX
c286155bfa viml/parser/expressions: Create tests for latest additions 2017-10-15 19:13:52 +03:00
ZyX
fa3cfc0dd5 viml/parser/expressions: Finish parser
Note: formatc.lua was unable to swallow some newer additions to ExprASTNodeType 
(specifically `kExprNodeOr = '|'` and probably something else), so all `= …` 
were dropped: in any case they only were there in order to not bother updating 
viml_pexpr_debug_print_ast_node and since it is now known all nodes which will 
be present it is not much of an issue.
2017-10-15 19:13:52 +03:00
ZyX
af38cea133 viml/parser/expressions: Add support for string parsing 2017-10-15 19:13:52 +03:00
ZyX
bd3a4166b2 viml/parser/expressions: Add support for subscript and list literals 2017-10-15 19:13:51 +03:00
ZyX
e45e519495 viml/parser/expressions: Error out on multiple colons in a row 2017-10-15 19:13:51 +03:00
ZyX
21a5ce033c viml/parser/expressions: Add support for the dot operator and numbers 2017-10-15 19:13:50 +03:00
ZyX
163792e9b9 viml/parser/expressions: Make lexer parse numbers, support non-decimal 2017-10-15 19:13:50 +03:00
ZyX
0bc4e22379 viml/parser/expressions: Forbid dot or alpha characters after a float
This is basically what Vim already does, in addition to forbidding floats should
there be a concat immediately before it.
2017-10-15 19:13:50 +03:00
ZyX
6168e1127c viml/parser/expressions: Add support for comparison operators 2017-10-15 19:13:49 +03:00
ZyX
6791c57420 viml/parser/expressions: Make sure that arrows outside lambda throw 2017-10-15 19:13:49 +03:00
ZyX
6144e26eb9 viml/parser/expressions: Add support for ternary operator 2017-10-15 19:13:49 +03:00
ZyX
9e721031d5 viml/parser/expressions: Fix determining invalid commas/colons 2017-10-15 19:13:48 +03:00
ZyX
3735537a50 viml/parser/expressions: Fix call inside nested parenthesis
It may have incorrectly tried to call everything because of essentially “value” 
nodes being treated as not such.
2017-10-15 19:13:48 +03:00
ZyX
f265066081 unittests: Add support for dumping “expected” state
Purpose is similar to that of `screen:snapshot_util()`, but in different domain.
2017-10-08 22:25:09 +03:00
ZyX
9fa8f7fc0a viml/parser/expressions: Add a way to adjust lexer
It also adds support for kExprLexOr which for some reason was forgotten.

It was only made sure that KLEE test compiles in non-KLEE mode, not that
something works or that KLEE is able to run tests.
2017-10-08 22:25:08 +03:00
ZyX
0987d3b10f viml/parser/expressions: Make curly braces name actually work 2017-10-08 22:25:07 +03:00
ZyX
3cc65ac054 viml/parser/expressions: Make commas actually work when calling 2017-10-08 22:25:07 +03:00
ZyX
d4782fb1ca viml/parser/expressions: Make commas actually work when calling 2017-10-08 22:25:06 +03:00
ZyX
7980614650 viml/parser/expressions: Add support for figure braces (three kinds) 2017-10-08 22:25:06 +03:00
ZyX
430e516d3a viml/parser/expressions: Start creating expressions parser
Currently supported nodes:

- Register as it is one of the simplest value nodes (even numbers are
  not that simple with that dot handling).
- Plus, both unary and binary.
- Parenthesis, both nesting and calling.

Note regarding unit tests: it stores data for AST in highlighting in
strings in place of tables because luassert fails to do a good job at
representing big tables. Squashing a bunch of data into a single string
simply yields more readable result.
2017-10-08 22:25:03 +03:00
ZyX
919223c23a unittests: Move some functions into helpers modules 2017-10-08 22:12:00 +03:00
ZyX
2d8b9937de viml/parser: Handle encoding conversions 2017-10-08 22:11:59 +03:00
ZyX
0300c4d109 viml/expressions: Add lexer with some basic tests 2017-10-08 22:11:57 +03:00
Justin M. Keyes
6f7754dfa0 test: avoid extra clear() calls
also: various other cleanup
2017-10-02 01:46:16 +02:00
Ignas Anikevicius
2b133101cf win: vim_FullName(): force backslashes #7287
- Replace obvious cases of '/' literal with PATHSEP. (There are still
  some remaining cases that need closer inspection.)
- Fixup tests: ui/screen_basic

closes #7117
ref https://github.com/neovim/neovim/issues/2471#issuecomment-271193714
2017-10-02 00:48:30 +02:00
ZyX
190c8516f5 unittests: Add a way to print trace on regular error 2017-09-29 01:21:13 +03:00
James McCoy
ac055d677a os_stat: return ENOENT on NULL filename arg
Closes #4370

Explication:

    In the backtrace in #4370, we see that `buf_write()` was called with
    non-NULL `fname` and `sfname` arguments, but they've since _become_
    NULL.

    #7  0x00000000004de09d in buf_write (buf=0x1dee040, fname=0x0, fname@entry=0x1e985b0 "/home/sean/src/github.com/snczl/virta/pkg/meld/segment.go",
                                         sfname=0x0, sfname@entry=0x1ddfa60 "segment.go", start=1, end=72, eap=eap@entry=0x7ffc6b032e60, append=0,
                                         forceit=0, reset_changed=1, filtering=0)
    at /home/travis/build/neovim/bot-ci/build/neovim/src/nvim/fileio.c:2576

    This is most likely due to the code that restores those values from
    `buf`, which happens just before the fatal call to `os_fileinfo`

    ```c
        /*
         * The autocommands may have changed the name of the buffer, which may
         * be kept in fname, ffname and sfname.
         */
        if (buf_ffname)
          ffname = buf->b_ffname;
        if (buf_sfname)
          sfname = buf->b_sfname;
        if (buf_fname_f)
          fname = buf->b_ffname;
        if (buf_fname_s)
          fname = buf->b_sfname;
    ```

    It's worth noting that at this point `ffname` is still non-NULL, so
    it _could_ be used.  However, our current code is purely more strict
    than Vim in this area, which has caused us problems before (e.g.,
    `getdigits()`).  The commentary for `struct file_buffer` clearly
    indicate that all of `b_ffname`, `b_sfname`, and `b_fname` may be
    NULL:

    ```c
      /*
       * b_ffname has the full path of the file (NULL for no name).
       * b_sfname is the name as the user typed it (or NULL).
       * b_fname is the same as b_sfname, unless ":cd" has been done,
       *		then it is the same as b_ffname (NULL for no name).
       */
      char_u      *b_ffname;        /* full path file name */
      char_u      *b_sfname;        /* short file name */
      char_u      *b_fname;         /* current file name */
    ```

    Vim directly calls `stat(2)` which, although it is annotated to tell
    the compiler that the path argument is non-NULL, does handle a NULL
    pointer by returning a `-1` value and setting `errno` to `EFAULT`.
    This satisfies Vim's check, since it treats any `-1` return from
    `stat(2)` to mean the file doesn't exist (at least in this code
    path).

    Note that Vim's mch_stat() implementations on win32 and solaris
    clearly cannot accept NULL `name`. But the codepaths that call
    mch_stat will NULL `name` tend to be unix-only (eg: u_read_undo)!
2017-08-10 00:56:07 +02:00
ZyX
72b3fd9664 os/fileio: Add ability to use os/fileio.c for file descriptors
Code imported from #6299
2017-07-04 18:37:01 +03:00
ZyX
5ab9e9f617 os/fileio: Add msgpack_file_write function 2017-07-04 18:37:01 +03:00
Justin M. Keyes
008b604bac Merge #6947 from ZyX-I/consistent-get_keymap 2017-07-03 23:33:08 +02:00
ZyX
35898cff5d unittests: Fix allocation ordering for tv_dict_add_str() 2017-07-02 20:24:39 +03:00
James McCoy
4d01725699
test: expand_env_esc: Pass correct buffer size for outlen and assertion
Running this test with a mocked passwd file whose $HOME was set to
/home/jamessan/src/debian.org/pkg-vim/deb-packages/neovim/neovim-0.2.0/debian/fakehome
caused the test to fail, since the expanded result was >= 99 bytes.  The
test should be reflecting the actual size of the buffer, instead of some
arbitrary other number, anwyay.
2017-07-02 12:52:43 -04:00
ZyX
df040e55fb eval/typval: Add tv_dict_add_allocated_str() function 2017-07-02 19:01:09 +03:00
Jonathan de Boyne Pollard
838277e28a test: fix bashisms (#6791) 2017-06-01 00:46:00 +02:00
Justin M. Keyes
4c5398bc40 startup: v:progpath fallback: path_guess_exepath
If procfs is missing then libuv cannot find the exe path.
Fallback to path_guess_exepath(), adapted from Vim findYourself().

Closes #6734
2017-05-15 15:01:52 +02:00
ZyX
f4d5d5250a eval: Refactor get_user_input to support dictionary 2017-05-10 15:52:48 +03:00
ZyX
04e7eb1e29 tests: Add tests for vim_strchr 2017-05-09 14:41:23 +03:00
Justin M. Keyes
8f346a322b test/fs: sanity check for literal "~" directory (#6579)
If the CWD contains a directory with the literal name "~" then the tests
will have bogus failures.
2017-04-24 22:45:03 +02:00
ZyX
d463c9e03a Merge branch 'master' into lazier-arg_errmsg-gettext 2017-04-21 00:33:12 +03:00
ZyX
c2f3e361c5 *: Add comment to all C files 2017-04-19 19:11:50 +03:00
ZyX
b54e5c220f unittests: Add a test for TV_CSTRING
Not using enum{} because SIZE_MAX exceeds integer and I do not really like how
enum definition is described in C99:

1. Even though all values must fit into the chosen type (6.7.2.2, p 4) the type
   to choose is still implementation-defined.
2. 6.4.4.3 explicitly states that “an identifier declared as an enumeration
   constant has type `int`”. So it looks like “no matter what type was chosen
   for enumeration, constants will be integers”. Yet the following simple
   program:

        #include <stdint.h>
        #include <stdio.h>
        #include <stddef.h>

        enum { X=SIZE_MAX };

        int main(int argc, char **argv)
        {
          printf("x:%zu m:%zu t:%zu v:%zu",
                 sizeof(X), sizeof(SIZE_MAX), sizeof(size_t), (size_t)X);
        }

    yields one of the following using different compilers:

    - clang/gcc/pathcc: `x:8 m:8 t:8 v:18446744073709551615`
    - pcc/tcc: `x:4 m:8 t:8 v:1844674407370955161`

    If I remove the cast of X to size_t then pcc/tcc both yield `x:4 m:8 t:8
    v:4294967295`, other compilers’ output does not change.

    All compilers were called with `$compiler -std=c99 -xc -` (feeding program
    from echo), except for `tcc` which has missing `-std=c99`. `pcc` seems to
    ignore the argument though: it is perfectly fine with `-std=c1000`.
2017-04-14 23:58:47 +03:00
Justin M. Keyes
7c4e5dfd27 win: os_shell_is_cmdexe() + tests 2017-04-12 02:28:43 +02:00
Justin M. Keyes
699e8406b5 Merge #6439 from ZyX-I/fix-gc-failures
unittests: Force GC, fix GC failures in typval_spec
2017-04-09 04:05:07 +02:00
ZyX
967fa96eb2 unittests: Fix linter error 2017-04-09 03:39:37 +03:00
ZyX
8990490b50 unittests: Move allocating vimconv_T to a function 2017-04-09 03:36:18 +03:00
ZyX
233e71419e unittests: Do not GC typval_T which is owned by a di 2017-04-09 03:36:18 +03:00
ZyX
bac870433b unittests: Do not unref partial which is owned by Callback structure 2017-04-09 03:36:17 +03:00
ZyX
44cd4e63f5 unittests: Use Neovim memory allocation for vimconv_T
Not sure whether this is going to fix things though, but core dump does not 
contain Neovim functions in stack in this case.
2017-04-09 03:36:17 +03:00
ZyX
94c1af7c41 unittests: Do not gc what is already freed 2017-04-09 03:36:17 +03:00
ZyX
dc9722326e unittests: Do not alter p_enc in decode unit test 2017-04-08 19:20:41 +03:00
ZyX
a83511d1a1 unittests: Move checking cores to check_child_err 2017-04-08 04:48:58 +03:00
ZyX
654dd15bb8 unittests: Fix testlint failure 2017-04-07 00:46:52 +03:00
ZyX
271df03fa4 unittests: Force GC, fix GC failures in typval_spec 2017-04-06 07:29:15 +03:00
ZyX
dc75766081 tests: Fix testlint errors 2017-04-03 03:07:01 +03:00
ZyX
b10880dadc eval: Make writefile() able to disable fsync() 2017-04-02 22:11:35 +03:00
Nikolai Aleksandrovich Pavlov
ddfa0359c6 unittests: Make it easier to determine on which _spec line it crashed (#6424)
Benchmarks:

Before change: 17.78s user 3.48s system  94% cpu 22.525 total
After change:  25.38s user 4.46s system 101% cpu 29.317 total
2017-04-02 13:25:47 +02:00
Justin M. Keyes
518f28f537 Merge #6422 from ZyX-I/fix-6420
eval,fileio: Omit additional fsync() call
2017-04-01 22:38:20 +02:00
ZyX
cc4523013f eval,fileio: Omit additional fsync() call
Fixes #6420
2017-04-01 21:15:13 +03:00
ZyX
ac22238b6a unittests: Replace two environment variables with one TRACE_LEVEL 2017-04-01 20:57:23 +03:00
ZyX
2d158dde02 unittests: Fix linter error 2017-04-01 13:17:25 +03:00
ZyX
708a55ee15 unittests: Disable non-C-calls
Some benchmarks:

TRACE_EVERYTHING: 79.45s user 12.68s system 124% cpu 1:13.94  total

(default):        30.26s user  5.30s system  89% cpu   39.663 total
2017-04-01 13:16:25 +03:00
ZyX
9dd0d4f8b9 unittests: Add trace description right to the error message 2017-04-01 12:52:28 +03:00
ZyX
046d6a8dfe unittests: Collect traces
Some benchmarks:

MAIN_CDEFS + NO_TRACE:  3.81s user  1.65s system  33% cpu   16.140 total

MAIN_CDEFS:            73.61s user 10.98s system 154% cpu   54.690 total

NO_TRACE:              18.49s user  4.30s system  73% cpu   30.804 total

(default):             77.11s user 14.74s system 126% cpu 1:12.79  total
2017-04-01 12:25:10 +03:00
ZyX
8f7a48f46a unittests: Split itp implementation into multiple functions 2017-04-01 11:19:41 +03:00
ZyX
933d60bc23 unittests: Do not hang when error message is too long 2017-04-01 11:07:08 +03:00
Nikolai Aleksandrovich Pavlov
a1c928e70c ci: Do not hide ci directory (#6410) 2017-03-31 14:32:58 +02:00
ZyX
114eaa15f0 eval/typval,api/buffer: Fix review comments 2017-03-29 10:08:46 +03:00
ZyX
58e34e8d99 eval/typval: Allow NULL dict as tv_dict_get_callback() argument
Also removes NULL key input: tv_dict_find() does not allow this.
2017-03-29 10:08:46 +03:00
ZyX
8daf756fb6 unittests: Fix linter errors 2017-03-29 10:08:46 +03:00
ZyX
7826ee1c03 unittests: Add tv_get_string* tests 2017-03-29 10:08:46 +03:00
ZyX
e08b27ba4a unittests: Add tv_get number tests 2017-03-29 10:08:46 +03:00
ZyX
4536c064e4 unittests: Move tv_dict_add* tests to a proper describe() block 2017-03-29 10:08:46 +03:00
ZyX
49195063fd unittests: Add tv_check… tests 2017-03-29 10:08:46 +03:00
ZyX
389274bef7 unittests: Add tv_equal() tests 2017-03-29 10:08:46 +03:00
ZyX
630ff33dc1 unittests: Test locks section 2017-03-29 10:08:46 +03:00
ZyX
ed4948a933 unittests: Test tv_copy() 2017-03-29 10:08:46 +03:00
ZyX
f0bbd1e825 unittests: Add tests for tv_clear() 2017-03-29 10:08:46 +03:00
ZyX
e43de6bb3e unittests: Add test for tv_dict_set_keys_readonly 2017-03-29 10:08:45 +03:00
ZyX
368a61c525 unittests: Add tv_dict_copy tests 2017-03-29 10:08:45 +03:00
ZyX
8b9a1fbf7a unittests: Add tests for tv_dict_extend 2017-03-29 10:08:45 +03:00
ZyX
4987850cac unittests: Add tv_dict_clear tests 2017-03-29 10:08:45 +03:00
ZyX
270a3889af unittests: Add tv_dict_add* unit tests
Also fixes incorrect location of `tv_dict_add` function and three bugs in other 
functions:

1. `tv_dict_add_list` may free list it does not own (vim/vim#1555).
2. `tv_dict_add_dict` may free dictionary it does not own (vim/vim#1555).
3. `tv_dict_add_dict` ignores `key_len` argument.
2017-03-29 10:08:45 +03:00
ZyX
bc87d23c28 unittests: Add tests for dictionary indexing 2017-03-29 10:08:45 +03:00
ZyX
5ce6243241 unittests: Enable tv_list_join tests back
Unable to reproduce the problem on Mac OS X Sierra VPS, need to check whether it 
is reproducible on travis.
2017-03-29 10:08:45 +03:00
ZyX
52e226ff74 unittests: Disable tv_list_join test on Mac OS only 2017-03-29 10:08:45 +03:00
ZyX
38dd81c136 eval/typval: Fix SEGV in test_alot.vim test 2017-03-29 10:08:45 +03:00
ZyX
6c622ed08b unittests: Add tv_dict_item_{add,remove} tests 2017-03-29 10:08:45 +03:00
ZyX
ffaf7c7521 unittests: Add tv_dict_item_{alloc,free} tests 2017-03-29 10:08:45 +03:00
ZyX
4c3be98db9 unittests: Add tv_dict_watcher_{add,remove} tests 2017-03-29 10:08:45 +03:00
ZyX
140174669e unittests: Run tv_list_join tests in case it stopped failing 2017-03-29 10:08:45 +03:00
ZyX
4bcee96347 *: Fix some Windows-specific warnings
Also fixed an error in path_fnamecmp().
2017-03-29 10:08:42 +03:00
ZyX
56e51033ab unittests: Add tests for tv_list_idx_of_item 2017-03-29 10:08:06 +03:00
ZyX
e5edf07ec4 unittests: Add tests for tv_list_find*() functions
Additional modifications:

- More `const` qualifiers in tested functions.
- `tv_list_find_str()` second argument is more in-line with other
  `tv_list_find*()` functions.
2017-03-29 10:08:06 +03:00
ZyX
b3672ae2fc eval/typval: Add tv_list_equal() tests, compare NULL lists equal 2017-03-29 10:08:06 +03:00
ZyX
4f9e784427 unittests: Test tv_list_join() 2017-03-29 10:08:06 +03:00
ZyX
cf45c7bb05 unittests: Fix tests crash
Tests crash at some point without
- `after_each(collectgarbage)` right before “typval.c list copy() copies list
  correctly and converts items” test.
- Commenting out that test.
- Adding `collectgarbage()` after the test (what actually this commit does).

Adding `collectgarbage()` to top-level `after_each` block right after
`restore_allocators` makes running this file crash even if it is run alone.
2017-03-29 10:08:06 +03:00
ZyX
7ceebacb3f eval/typval,tests: Fix extending list with itself, add tests
Adds unit test for tv_list_extend and regression test for extend() VimL
function.
2017-03-29 10:08:06 +03:00
ZyX
56e4c2f67e unittests: Test tv_list_concat() 2017-03-29 10:08:06 +03:00
ZyX
9898f36aa3 unittests: Test tv_list_copy
Also found some bugs:

1. var_item_copy() always fails to copy v:_null_list and v:_null_dict. Fixing
   this should mean fixing `deepcopy(v:_null_list)` which should’ve been, but
   was not listed in #4615. This also fixes `deepcopy(v:_null_dict)`.
2. var_item_copy() crashes when trying to copy NULL string with `conv != NULL`.
3. `conv` argument is ignored when copying list unless `deep` is true, but it
   was not reflected in documentation.
4. `tv_dict_item_alloc_len()` allocated more memory then needed.
5. typvalt2lua was not able to handle self-referencing containers.
2017-03-29 10:08:06 +03:00
ZyX
9b8beaff02 unittests: Add tests for tv_list_insert*()/…append*() functions 2017-03-29 10:08:06 +03:00
ZyX
be360d8841 unittests: Add tests for tv_list_insert() 2017-03-29 10:08:06 +03:00
ZyX
d2639e1e1d unittests: Add tests for list watchers and list alloc/free/unref 2017-03-29 10:08:06 +03:00
ZyX
a394167177 unittests: Test tv_list_item_\* functions
To check that memory is free()d correctly.
2017-03-29 10:08:06 +03:00
ZyX
2ad4fba46d eval: Move copy_tv to eval/typval 2017-03-29 10:08:06 +03:00
ZyX
5df35297f8 eval: Remove eval_expr() completely 2017-03-29 10:08:05 +03:00
ZyX
e18a578308 *: Move some dictionary functions to typval.h and use char*
Also fixes buffer reusage in setmatches() and complete().
2017-03-29 10:07:42 +03:00
ZyX
fb146e80aa eval: Split eval.c into smaller files 2017-03-29 10:05:06 +03:00
Justin M. Keyes
e20e9645b2 build: Rename NEOVIM_* to NVIM_* 2017-03-27 14:27:20 +02:00
ZyX
ae4fae9d3e unittests: Add tests for new fileio functions 2017-03-19 19:16:44 +03:00