Commit Graph

447 Commits

Author SHA1 Message Date
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
ZyX
e78e75d85d fileio,main: Do not restart syscall at EAGAIN when reading for -s 2017-03-19 17:29:48 +03:00
ZyX
fdfa1ed578 main: Temporary fix assertion error
This variant uses `fdopen()` which is not standard, but it fixes problem on my 
system. In next commit `scriptin` will use `FileDescriptor*` from os/fileio in 
place of `FILE*`.
2017-03-19 16:09:48 +03:00
ZyX
3cd7bf31e2 tests: Fix repeated_popen_r usage, rename the function 2017-03-19 14:13:21 +03:00
ZyX
0e9286a19e tests: Fix CI failures 2017-03-19 14:13:21 +03:00
ZyX
0320a58082 functests: Check that -s works as expected 2017-03-19 14:13:21 +03:00
John Szakmeister
3c8d974f73 unittests: avoid using pattern matching on file names
The directory name could contain special characters that trips up the
matching used by find.  Instead, let's just make sure that the filename
starts with the directory name.
2017-03-16 06:58:15 -04:00
ZyX
48e7a83447 unittests: Fix linter error 2017-03-12 04:20:31 +03:00
ZyX
d559fe6e93 unittests: Allow running ffi.cdef in the main process 2017-03-12 03:14:34 +03:00
ZyX
a7f64ba517 unittests: Move filtering cdefs to main process 2017-03-12 03:02:14 +03:00
ZyX
bf68907778 unittests: Use more adequate names for some functions 2017-03-12 02:54:23 +03:00
ZyX
8ef6cfa6ac unittests: Fix linter errors 2017-03-11 23:48:16 +03:00
ZyX
a54be846cf unittests: Update test/unit/message_spec.lua 2017-03-11 23:26:33 +03:00
ZyX
ec730daee9 unittests: Do not use which, add data to paths.lua.in instead 2017-03-11 23:23:50 +03:00
ZyX
ce12bda712 unittests: Always close all pipes 2017-03-11 23:23:49 +03:00
ZyX
e2a578f40d unittests: Do not import libnvim or headers in main process
Slows down unit tests much, but gets rid of as much preserved state as possible.
2017-03-11 23:23:49 +03:00
ZyX
9400466282 unittests: Check core dumps in after_each, like in functests 2017-03-11 23:23:49 +03:00
ZyX
12b062b2c8 unittests: Run all unit tests in their own processes
Used

    sed -r -i -e '/ helpers =/ s/$/\nlocal itp = helpers.gen_itp(it)/; s/^(\s*)it\(/\1itp(/' test/unit/**/*_spec.lua

to alter all tests. Locally they all run fine now.

Reasoning:

1. General: state from one test should not affect other tests.
2. Local: travis build is failing with something which may be an output of
   garbage collector. This should prevent state of the garbage collector from
   interferring as well.
2017-03-11 23:23:30 +03:00
ZyX
5898b42d82 unittests: Do not run failing test at all 2017-03-11 23:23:30 +03:00
ZyX
29ed5b3a39 unittests: Fix lint errors 2017-03-11 23:23:30 +03:00
ZyX
b442574862 unittests: Allow failing test to fail 2017-03-11 23:23:30 +03:00
ZyX
ff5dca6630 unittests: Log syscalls if requested 2017-03-11 23:23:30 +03:00
ZyX
1edb3ccc36 unittests: Use own bindings to libc syscall wrappers 2017-03-11 23:23:30 +03:00
ZyX
3adecd3ede unittests: Do not use syscall library: does not work well with cimport 2017-03-11 23:23:30 +03:00
ZyX
9f29a76cab unittests: Try using syscall library instead (ffi-based) 2017-03-11 23:23:30 +03:00
ZyX
b92d6aaf0d unittests: Pause garbage collector while executing tests
Temporary (?) workaround for currently failing check_alloc_log tests.
2017-03-11 23:23:30 +03:00
ZyX
82e5af85c1 unittests: Run tests in a separate process 2017-03-11 23:23:30 +03:00
James McCoy
4e3a2784ec vim-patch:7.4.2068
Problem:    Not all arguments of trunc_string() are tested.  Memory access
            error when running the message tests.
Solution:   Add another test case. (Yegappan Lakshmanan)  Make it easy to run
            unittests with valgrind.  Fix the access error.

b9644433d2
2017-03-06 15:36:09 -05:00
James McCoy
7217360e34 vim-patch:7.4.2051
Problem:    No proper testing of trunc_string().
Solution:   Add a unittest for message.c.

502ae4ba63
2017-03-06 15:09:40 -05:00
Justin M. Keyes
4306e5ae0c test: luacheck update
We pull luacheck HEAD, so this is a "catch up" commit to fix
newly-discovered errors.
2017-03-01 14:47:49 +01:00
ZyX
77ebe85be6 buffer: Hide one of the asserts from lua parser 2017-02-25 00:22:46 +03:00
Nikolai Aleksandrovich Pavlov
64c375c589 unittest: Filter out standard defines so that they do not spam stderr (#6113) 2017-02-15 01:21:06 +01:00
Justin M. Keyes
bbfdb84ae1 build: Do not force busted into front of $PATH
This was a workaround from long ago, but it doesn't seem to be needed
anymore. And it breaks the $PATH on the Windows build (AppVeyor CI).

After this change python3 (and 2) is correctly detected on AppVeyor CI.

References #5946
2017-02-04 11:07:49 +01:00
Justin M. Keyes
224f99b85d win: Append process dir to $PATH
This allows executables to be found by :!, system(), and executable() if
they live next to ("sibling" to) nvim.exe. This is what gvim on Windows
does, and also matches the behavior of Win32 SearchPath().

c4a249a736/src/os_win32.c (L354-L370)
2017-02-04 11:07:49 +01:00
Justin M. Keyes
88bc9f8e92 xstrlcat: Allow overlapped pointers. (#6017)
memcpy is not equivalent to memmove (which is used by vim_strcat), this
could cause subtle bugs if xstrlcat is used as a replacement for
vim_strcat. But vim_strcat is inconsistent: in the `else` branch it uses
strcpy, which doesn't allow overlap.

Helped-by: oni-link <knil.ino@gmail.com>
Helped-by: James McCoy <jamessan@jamessan.com>
Helped-by: Nikolai Aleksandrovich Pavlov <kp-pav@yandex.ru>
2017-01-31 17:42:22 +01:00
Justin M. Keyes
497db001df test: expand_env_esc()
Test expand_env_esc() using the same parameters reported in #3725.

Closes #3725
2017-01-21 18:17:44 +01:00
ZyX
3967618fa5 unittest: Fix linter errors 2017-01-07 19:12:18 +03:00
ZyX
dea4bb33dc unittest,memory: Fix tests 2017-01-07 19:07:32 +03:00
ZyX
88a4820cc9 unittest: Add failing test for freeing dictionaries in a list 2017-01-07 15:54:55 +03:00
ZyX
728367a196 unittest: Add dict_items function 2017-01-07 15:54:55 +03:00
ZyX
41cbb7891d unittest: Add failing test of freeing lists 2017-01-07 14:48:21 +03:00
ZyX
8fd3d31329 unittest: Allow mocking allocator calls 2017-01-07 14:48:21 +03:00
James McCoy
b4c0c61f5c Merge pull request #5826 from ZyX-I/fix-typval_encode
Refactor eval/typval_encode.h
2017-01-06 21:11:33 -05:00
nfnty
7a344c795f path.c: vim_FullName(): Fix heap overflow #5737
- Clarify documentation.
- Return `FAIL` and truncate if `fname` is too long.
- Add tests.
2017-01-05 15:17:34 +01:00
ZyX
3c64b814d2 unittests: Fix linter errors 2017-01-03 23:58:12 +03:00
ZyX
937b6fac8f unittest: Fix linter errors 2017-01-03 22:54:55 +03:00
ZyX
b38e725428 unittest: Refactor preprocess.lua
Keeps arguments separated and not joined as a single string as long as possible. 
Abstracts away additional arguments so that Gcc:preprocess should work for 
compilers with different conventions should they be supported.
2017-01-03 22:54:55 +03:00
ZyX
2151ddbd73 unittest: Move nil checks to Gcc:preprocess 2017-01-03 22:54:54 +03:00
ZyX
0d7b779cab unittest: Record previous defines in another place
Previous commit made preprocess.lua know how its output will be used. This moves 
state to cimport, making only it know which is cleaner.
2017-01-03 22:54:54 +03:00
ZyX
410d18ef5c unittest: Allow multiple indirect includes
Works by saving all preprocessor defines and reusing them on each run. This also
saves NVIM_HEADER_H defines. Saving other defines is needed for defines like
`Map(foo, bar)` which are sometimes used to declare types or functions. Saving
types or function declarations is not needed because they are recorded as luajit
state.

Fixes #5857
2017-01-03 22:54:54 +03:00
ZyX
136b382e64 tests: Add tests for partials dumping
Also fixed dumping of partials by encode_vim_to_object and added code which is 
able to work with partials and dictionaries to test/unit/eval/helpers.lua 
(mostly copied from #5119, except for partials handling).
2017-01-03 22:51:29 +03:00
Marco Hinz
d2998a0a49 Tests: make unit tests work on macOS Sierra
Fixes #5455.
2016-12-29 02:58:21 +01:00
Justin M. Keyes
043f85210a tui: "backpressure": Drop messages to avoid flooding.
Closes #1234

multiqueue:
- Implement multiqueue_size()
- Rename MultiQueueItem.parent to MultiQueueItem.parent_item, to avoid confusion
  with MultiQueue.parent.
2016-12-09 18:51:17 +01:00
Justin M. Keyes
44e6ee930f build: Target luacheck HEAD.
https://github.com/mpeterv/luacheck/pull/81#issuecomment-261099606

> If you really want to use bleeding-edge version you should get the
> rockspec from master branch, not a fixed commit ...
> The correct way to install from a specific commit is cloning that
> commit and running "luarocks make" from project directory. The reason
> is that running "install" or "build" on an scm rockspec fetches
> sources from master but uses build description from the rockspec
> itself, which may be outdated.
2016-11-17 00:55:39 +01:00
Justin M. Keyes
6186df3562 event/multiqueue.c: Rename "queue" to "multiqueue".
`lib/queue.h` implements a basic queue. `event/queue.c` implements
a specialized data structure on top of lib/queue.h; it is not a "normal"
queue.

Rename the specialized multi-level queue implemented in event/queue.c to
"multiqueue", to avoid confusion when reading the code.

Before this change one can eventually notice that "macros (uppercase
symbols) are for the normal queue, lowercase operations are for the
multi-level queue", but that is unnecessary friction for new developers
(or existing developers just visiting this part of the codebase).
2016-10-02 00:24:49 +02:00
Justin M. Keyes
395ef5642e shell_escape: rename; refactor
- rename to shell_xescape_xquote
- move to os/shell.c
- disallow NULL argument
- eliminate casts, nesting
- test: empty shellxquote/shellxescape
2016-09-11 03:04:57 +02:00
Zhaosheng Pan
0991041ae7 system(): Respect 'sxe' and 'sxq' #2789
Fixes #2773
2016-09-10 22:21:40 +02:00
Kalle Ranki
e75e9c10dc test: Add unittest spec for option.c (#5289)
Move typedef expand_T to types.h for tests
Fix lint error for old style comments

Describe 'check_ff_value' valid values as an initial test.

Fix 'get_sts_value' comment inaccuracy and add unit test for it
2016-09-04 09:54:41 +02:00
Björn Linse
a2d25b7bf8 api: unify buffer numbers and window ids with handles
also allow handle==0 meaning curbuf/curwin/curtab
2016-08-31 21:40:20 +02:00
Daniel Xu
5f1a153831 os/fs: Rename os_file_exists to os_path_exists (#4973)
Because the old name did not indicate that the function
would return true on directories as well.
2016-07-06 01:40:25 -04:00
ZyX
142d00e8da unittests/*/helpers: Fix testlint errors 2016-06-24 17:38:33 +03:00
ZyX
2968dc7bdd fixup! unittests: Add tests for vim_to_object function 2016-06-24 16:53:26 +03:00
ZyX
6b06bdafa2 unittests: Add tests for vim_to_object function 2016-06-24 16:53:26 +03:00
ZyX
4741c8b234 unittests: Fix testlint errors 2016-06-24 09:29:51 +03:00
ZyX
6580dfeddd unittests: Fix kFileNoSymlink test on FreeBSD
Actual value on FreeBSD is -31, UV_EMLINK was obtained from
/usr/include/asm-generic/errno-base.h (there EMLINK is defined as 31 there).
This may actually be something else, but I do not think so as “Too many links”
description also fits in. [Man page][1] agrees with me, search for `[EMLINK]`
([linux man page][2] also specifies ELOOP explicitly in a similar section).

[1]: https://www.freebsd.org/cgi/man.cgi?query=open&sektion=2
[2]: http://man7.org/linux/man-pages/man3/open.3p.html
2016-06-24 00:07:57 +03:00
ZyX
a3b05a03b6 unittests: Fix bug somewhere that makes file_read tests SEGV 2016-06-24 00:07:56 +03:00
ZyX
2dd154457c file: Move src/nvim/file.* to src/nvim/os/fileio.* 2016-06-24 00:07:55 +03:00
ZyX
fec7983ecd unittests: Add tests for file.c
Also fixes some errors found.
2016-06-24 00:07:54 +03:00
ZyX
3e7c8e7149 unittests: Add os_write test
New os/fs.c functions are now all tested.
2016-06-23 21:17:51 +03:00
ZyX
2ac5f1138b unittests: Add os_close, os_read and os_readv tests 2016-06-23 21:17:51 +03:00
TJ DeVries
aa22b5fd9a Add new functionality to the = marker in the STL
This new functionality is explained in the documentation.

Also, many tests have been added to the buffer_spec.lua file
2016-06-14 20:10:11 +02:00
ZyX
ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00
ZyX
c571e80273 unittests: Also remove event_teardown
`event_teardown` is there from 974752c, by aktau. It was introduced with 
`init_homedir` and `event_init`. Then both were removed by justinmk in 
99a9161bac (`init_homedir`) and 
49c5689f45 (`event_init`), but `event_teardown` 
was not removed. Now this may cause a crash. More details in #4852.

Closes #4852
2016-05-31 15:41:24 +03:00
Justin M. Keyes
748898b4dd Merge pull request #4198 from daynin/string-tests
tests: add tests for vim_strsave_escaped() function
2016-05-29 13:10:26 -04:00
Sergey Golovin
c793423374 add test for vim_strsave_escaped() function 2016-05-29 13:26:39 +03:00
Justin M. Keyes
96f834a842 os_nodetype: Return NODE_NORMAL if os_stat fails.
Conforms to Vim's mch_nodetype. Regression by 7db4a15.
buf_write() expects NODE_WRITABLE for character devices such as
/dev/stderr.

Closes #4772
2016-05-22 15:12:02 -04:00
John Szakmeister
69d1bc1a47 test/functional: clear the temp directory before each tempfile test
It's possible that the first test encounters a temp directory with files
in it, due to a previous test causing the first test to fail.  Instead,
let's clean up before and after the test to make sure the temp area is
pristine before and after the test.
2016-05-06 20:53:53 -04:00
Justin M. Keyes
4682b21ef2 Merge pull request #4654 from KillTheMule/testlint
Satisfy testlint.
2016-05-06 01:13:39 -04:00
KillTheMule
00c35ab3b4 vim-patch:7.4.672
Problem:    When completing a shell command, directories in the current
            directory are not listed.
Solution:   When "." is not in $PATH also look in the current directory for
            directories.

b5971141df

Most of it applied manually.
2016-05-02 21:09:43 +02:00
KillTheMule
360d0513d1 Satisfy testlint.
For that, make luatest ignore the preload.lua files.
2016-04-28 19:30:17 +02:00
Justin M. Keyes
49c5689f45 test/unit: ensure event_init()
Closes #4635
References #4630
References https://github.com/neovim/neovim/pull/4070#discussion_r50626558
2016-04-25 00:42:44 -04:00
Justin M. Keyes
6e5343d230 test: shell_spec: rename variable 2016-04-24 23:58:11 -04:00
Jurica Bradaric
2dfc8de1cf Merge tempfile.c back into fileio.c 2016-04-20 08:25:51 +02:00
ZyX
bda0165514 eval/encode: Make sure that encoder can encode NULL variables
Adds two undocumented v: variables: _null_list and _null_dict because I do not 
know a reproducible way to get such lists (though I think I heard about this) 
and dictionaries (do not remember hearing about them). NULL strings are obtained 
using $XXX_UNEXISTENT_VAR_XXX.

Fixes crash in json_encode($XXX_UNEXISTENT_VAR_XXX). Other added tests worked 
fine before this commit.
2016-04-18 02:48:20 +03:00
ZyX
3e435df42c functests: Replace \xXX escapes with \DDD in lua code 2016-04-18 02:48:20 +03:00
ZyX
d06c2a1b18 eval/decode: Do not overflow when parsing -
Also makes if’s less nested.
2016-04-18 02:48:20 +03:00
ZyX
eb806c9620 eval/decode: Make sure that error messages do not cause overflow 2016-04-18 02:48:20 +03:00
ZyX
52c6cc2189 eval/decode: Make sure that parsing strings does not overflow 2016-04-18 02:48:20 +03:00
ZyX
4eb5d05f01 eval/decode: Avoid overflow when parsing incomplete null/true/false
Note: second test does not crash or produce asan errors, even though it should.
2016-04-18 02:48:20 +03:00
ZyX
77776b09c6 eval/encode: Fix writing strings starting with NL to list
Error [found][1] by oni-link.

[1]: https://github.com/neovim/neovim/pull/4131/files#r52239384
2016-04-18 02:47:13 +03:00
oni-link
cd00aa6ae4 mbyte_spec.lua: Fix indentation 2016-04-17 21:07:42 +02:00
oni-link
a8fec15899 mbyte_spec.lua: Fix wording 2016-04-17 21:07:22 +02:00
oni-link
cfe4352897 mbyte.c: Unittest for utfc_ptr2char_len() 2016-04-15 21:17:33 +02:00
Charles Joachim
55844eee10 buffer.c: change return type to bool
Co-authored-by: Wayne Rowcliffe (@war1025)
2016-04-03 15:39:33 -04:00
Marco Hinz
3d15cab29d Tests: fix according to lualint 2016-02-02 20:23:12 +01:00
Seth Jackson
a7ade5c832 misc: UNIX => Unix #4022
Although UNIX is a registered trademark of The Open Group, it doesn't
really matter whether we refer to these systems as UNIX, Unix, or
Unix-like. So, for consistency, refer to them collectively as Unix.

Related:
http://www.greens.org/about/unix.html
http://www.unixica.com/html/unixunix.html
2016-01-16 18:34:31 -05:00
Michael Reed
729064af5f test: sys/fcntl.h -> fcntl.h
POSIX.1-2008[1] says that the latter should be used, and all of our
supported platforms would seem to support this scheme, apparently even
Windows[2].

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
[2]: https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx
2016-01-14 23:36:58 -05:00
ZyX
3b7c4093e2 shell: Unquote &shell* options before using them 2016-01-11 05:24:44 +03:00
Rui Abreu Ferreira
28e59cb223 Use libuv errors instead of errno in unit tests
Replaced old unit tests for errno with libuv error codes UV_ENOENT
and UV_EEXIST (for os_open and os_getperms).

Added libuv include path to test/includes compiler calls - needed
to get hold of libuv headers.
2015-11-25 23:16:37 +00:00
Marco Hinz
32ecd75a16 test/unit: clean up according to luacheck 2015-11-23 13:57:21 +01:00
Wayne Rowcliffe
70f6b0f338 Start adding unit tests 2015-11-11 21:19:52 -06:00
ZyX
fefcc01cc1 os/fs: Allow os_mkdir_recurse directory name to end with /// 2015-10-23 14:54:11 +03:00
Russ Adams
7be75a0291 test: os_system: spec for non-zero exit. #3419 2015-10-04 22:57:21 -04:00
Thiago de Arruda
c708061a5a os/path: Fix path_get_absolute_path for top-level paths
Close #2833
2015-09-18 14:35:26 -03:00
Justin M. Keyes
8f09fa1a49 os/fs.c: remove os_file_is_readonly()
os_file_is_readonly() in its current form is equivalent to
!os_file_is_writable(). This does not appear to be a bug, because Vim's
use of check_file_readonly() (which we changed to os_file_is_readonly())
is equivalent to !os_file_is_writable() in every case.

os_file_is_readonly() also fails this test:

    returns false if the file is non-read, non-write

A more useful form would define behavior under these cases:

  - path is executable (but not writable)
  - path is non-existent
  - path is directory

But there is no reason for os_file_is_readonly() to exist, so remove it.
2015-08-17 01:15:04 -04:00
Justin M. Keyes
d5cd15e67f test: more cases for os_file_is_readonly() 2015-08-17 01:14:13 -04:00
Justin M. Keyes
ad6b356119 test: cover os_file_is_readable() 2015-08-17 01:07:48 -04:00
Thiago de Arruda
a6e0d35d2d queue: Implement a more flexible event queue 2015-08-13 08:46:21 -03:00
Justin M. Keyes
5c1dc0fbe7 test: fix pending() invocations
AFAICT busted does not report pending() invocations without the 2nd
argument.
2015-08-09 22:33:28 -04:00
ZyX
1206ac953f os/fs: Move mkdir_recurse from eval.c to os/fs.c 2015-07-26 02:34:32 +03:00
Thiago de Arruda
991d3ec1e6 event loop: New abstraction layer with refactored time/signal API
- Add event loop abstraction module under src/nvim/event. The
  src/nvim/event/loop module replaces src/nvim/os/event
- Remove direct dependency on libuv signal/timer API and use the new abstraction
  instead.
- Replace all references to uv_default_loop() by &loop.uv, a new global variable
  that wraps libuv main event loop but allows the event loop functions to be
  reused in other contexts.
2015-07-17 00:19:19 -03:00
Thiago de Arruda
0ef80b9c2b rbuffer: Reimplement as a ring buffer and decouple from rstream
Extract the RBuffer class from rstream.c and reimplement it as a ring buffer,
a more efficient version that doesn't need to relocate memory.

The old rbuffer_read/rbuffer_write interfaces are kept for simple
reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to
hide wrapping logic when more control is required(such as passing the buffer
pointer to a library function that writes directly to the pointer)

Also add a basic infrastructure for writing helper C files that are only
compiled in the unit test library, and use this to write unit tests for RBuffer
which contains some macros that can't be accessed directly by luajit.

Helped-by: oni-link <knil.ino@gmail.com>
Reviewed-by: oni-link <knil.ino@gmail.com>
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Justin M. Keyes <justinkz@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
2015-07-01 05:40:53 -03:00
Thiago de Arruda
c8c5af5a7a test: Ensure proper initialization in unit/helpers.lua
Remove helpers.vim_init and simply perform the required initialization in
helpers.lua.
2015-07-01 05:40:53 -03:00
Florian Walch
122890463a tests: Use pending() instead of silently skipping test. #2737 2015-05-29 20:57:20 +03:00
Scott Prager
1eb3396922 unify jobstart, termopen, and system interfaces
For any of these functions, if {cmd} is a string, execute
"&shell &shellcmdflag '{cmd}'", or simply {cmd} if it's a list.

In termopen(), if the 'name' option is not supplied, try to guess using
'{cmd}' (string) or {cmd}[0] (list).  Simplify ex_terminal to use the
string form of termopen().

termopen: get name from argument

Convert list_to_argv to tv_to_argv.

Helped-by: Björn Linse <@bfredl>
Helped-by: oni-link <knil.ino@gmail.com>
Helped-by: Thiago de Arruda <@tarruda>
2015-05-02 09:47:30 -04:00
Rui Abreu Ferreira
71487a935e Implement os_unsetenv()
- In UNIX systems where unsetenv() is available, it is used. Otherwise
  the variables are set with the empty string.
- New check HAVE_UNSETENV for unsetenv()
- Added unit test to env_spec.lua
2015-04-14 15:20:50 -04:00
David Bürgin
e129e2792d tests: Fix test setup/teardown in path_spec.lua #2402
A call to lfs.mkdir instead of lfs.rmdir left a temp directory hanging
around. Changed to do proper setup/teardown using {before,after}_each.

Helped-by: Scott Prager <splinterofchaos@gmail.com>
Suggested-by: Scott Prager <splinterofchaos@gmail.com>
2015-04-12 16:11:50 -04:00
Rich Churcher
1200f1f20e Use lfs.currentdir() to fix symlink test fail. 2015-04-01 09:21:21 +13:00
Scott Prager
93bfe6a400 path_fix_case: unit test 2015-03-31 11:20:24 -03:00
bobtwinkles
3fc18e25b8 refactor: add tests for env_expand_esc 2015-03-24 16:13:00 -04:00
John Szakmeister
d8ef23849a tests: prevent busted from reloading the ffi module and others
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.
2015-03-01 15:25:39 -05:00
John Szakmeister
235909044a tests: require luassert in the helpers
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.
2015-03-01 09:00:27 -05:00
John Szakmeister
f1f1f711c7 Merge pull request #1965 from jszakmeister/fix-fs-spec-test-for-freebsd
Fix an fs_spec test under FreeBSD and a symlinked home directory.
2015-02-11 19:45:26 -05:00
John Szakmeister
dd12238329 Merge pull request #1958 from jszakmeister/fix-unittest-header-parsing-on-freebsd
unittests: define _Thread_local to be nothing
2015-02-11 04:04:54 -05:00
John Szakmeister
3562f686b0 Get rid of a bashism in the fs_spec test. #1964
FreeBSD doesn't use bash by default, causing the group id to be print
out in the middle of the test.
2015-02-09 12:44:22 -05:00
John Szakmeister
41d8c8980b Fix an fs_spec test under FreeBSD and a symlinked home directory.
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.
2015-02-09 06:49:11 -05:00
John Szakmeister
bc6ef4bf80 unittests: define _Thread_local to be nothing
This helps the LuaJIT ffi module to parse the header correctly.
Otherwise, the whole suite of tests fail.
2015-02-09 05:37:24 -05:00
Nicolas Hillegeer
522a15f1c0 test: fix formatc.lua oddity on OSX/gcc
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.
2015-01-16 21:45:00 +01:00
Nicolas Hillegeer
dd25b2e5ae test/os/fs: fix call to lfs.attributes
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
2015-01-16 21:44:25 +01:00
Scott Prager
275f6e3a6b mch_early_init() -> early_init().
Move general initialization functions to early_init, which simplifies
test/unit/helpers.lua, which requires all these functions.
2014-11-28 14:27:58 -05:00
Stefan Hoffmann
972fc30599 unittest: increase number of retries in cimport 2014-10-30 19:05:39 +01:00
Stefan Hoffmann
741cb5be08 unittest: fix handling of pragma pack in cimport 2014-10-30 19:05:39 +01:00
Scott Prager
8b3e5829e4 update os_can_exe unit test 2014-09-17 01:01:25 -04:00
Scott Prager
9445eaa297 vim-patch:7.4.235
Problem:    It is not easy to get the full path of a command.
Solution:   Add the exepath() function.

https://code.google.com/p/vim/source/detail?r=5ab2946f7ce560985830fbc3c453bb0f7a01f385
2014-09-17 01:00:24 -04:00
Justin M. Keyes
99a9161bac unit tests: initialize everything 2014-09-11 08:58:17 +00:00