Commit Graph

105 Commits

Author SHA1 Message Date
Nikolai Aleksandrovich Pavlov
abdbfd26bc eval: Add id() function and make printf("%p") return something useful (#6095) 2017-02-11 19:47:02 +01:00
Justin M. Keyes
18127f64c4 test: executable(): AppVeyor: Ignore "sibling" failure
This test sometimes fails on AppVeyor, but we still want to exercise the
code path and get at least a "soft" notification in the pending list.
2017-02-04 11:07:50 +01:00
Justin M. Keyes
67fbbdb1b5 win: executable(): full path without extension
Absolute path is considered executable even *without* an extension.
2017-02-04 11:07:50 +01:00
Justin M. Keyes
cd5b131575 vim-patch:8.0.0280
patch 8.0.0280: problem setting multi-byte environment var on MS-Windows

Problem:    On MS-Windows setting an environment variable with multi-byte
            strings does not work well.
Solution:   Use wputenv when possible. (Taro Muraoka, Ken Takata)

7c23d1d9d9cc
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
Rui Abreu Ferreira
7d58aba80c test: executable() 2017-02-04 11:07:49 +01:00
James McCoy
11f2bd5fa3 Merge pull request #6050 from jamessan/fix-xclip-tests
Fix xclip tests to cleanup on their own
2017-02-03 11:36:52 -05:00
James McCoy
ce51fa0955
test: Turn printargs_path into a function
When test/functional/eval/system_spec.lua is run on its own,
helpers.os_name() was being called before a session had been created.
This caused that describe block to fail.

Turning printargs_path into a function delays the call of
helpers.os_name() until the test is being run, which ensures a session
is available.
2017-02-02 19:52:59 -05:00
James McCoy
7e30fe3157
test: Make xclip exit after one selection request
Closes #4900
2017-02-02 19:52:06 -05:00
Justin M. Keyes
f8b21b6d82
test: execute() + :redir 2017-02-01 18:31:53 -05:00
James McCoy
7e7f01a3be
execute: Correctly capture output with highlight attributes
Closes #5422
2017-02-01 18:28:32 -05:00
Justin M. Keyes
e7de3b5f84 test/timer_spec.lua: Relax expected count.
Test sometimes fails on AppVeyor (Windows). 300/50=6, but there could be
environment factors that miss the timer interval on the "edges".
timer_start() does not have such a hard requirement.
2017-01-19 14:46:29 +01:00
Matthew Malcomson
b5560a69b1 setpos(): Set lowercase mark in other buffers (#5753)
Also make setpos("'A", [999, 1, 1, 0]) fail, i.e. return -1 (assuming there is no buffer 999).

Fixes #5713

Background:

`:help setpos()` mentions an argument `"bufnum"` that determines the buffer a mark should be put in.
This argument is respected for uppercase marks, but not for lowercase marks.
This is reasonable (though I personally would like `setpos()` to be able to set marks in other buffers), but the help doesn't mention this anywhere.

It's also strange that attempting to change buffers with `setpos('.', [bufnr('#'), 1, 1, 0])` alerts the user that having a different buffer is an error, while attempting to set a mark with `setpos("'d", [bufnr('#'), 1, 1, 0])` doesn't tell the user that the `"bufnum"` argument is an error.
2017-01-15 21:36:29 +01:00
Justin M. Keyes
82edcb593b Windows: enable more tests 2017-01-13 01:17:12 +01:00
Justin M. Keyes
9ecdce1d53 test: system([...]): v:shell_error 2017-01-11 01:05:56 +01:00
Rui Abreu Ferreira
1e079fa987 system([...]): Set v:shell_error=-1 if not executable.
Do _not_ set v:shell_error on parameter validation error.

system([...]) does not invoke a shell, so this change is somewhat
questionable. But `:help v:shell_error` is sufficiently vague to allow
-1 in this case.
2017-01-11 01:05:55 +01:00
Rui Abreu Ferreira
ac44d0ed54 test: system([...]) 2017-01-11 01:05:55 +01:00
James McCoy
6520517e22
vim-patch:7.4.2008
Problem:    evalcmd() has a confusing name.
Solution:   Rename to execute().  Make silent optional.  Support a list of
            commands.

79815f1ec7
2017-01-10 07:14:12 -05:00
ZyX
527636f158 functests: Add tests for new fixes 2017-01-06 23:52:31 +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
ZyX
759e736b0a eval/typval_encode: Fix infinite loop
Occurs when trying to dump a partial with attached self dictionary which
references that partial. “Infinite” loop should normally result in Neovim killed
by OOM killer.

Also moved the place when partials are unreferenced by clear_tv: from
…FUNC_START to …FUNC_END.
2017-01-03 06:39:23 +03:00
Justin M. Keyes
97204e1cef os/shell: Throttle :! output, pulse "..." message.
Periodically skip :! spam. This is a "cheat" that works for all UIs and greatly
improves responsiveness when :! spams MB or GB of output:
    :!yes
    :!while true; do date; done
    :!git grep ''
    :grep -r '' *

After ~10KB of data is seen from a single :! invocation, output will be skipped
for ~1s and three dots "..." will pulse in the bottom-left. Thereafter the
behavior alternates at every:
    * 10KB received
    * ~1s throttled

This also avoids out-of-memory which could happen with large :! outputs.

Note: This commit does not change the behavior of execute(':!foo').
      execute(':!foo') returns the string ':!foo^M', it captures *only* Vim
      messages, *not* shell command output. Vim behaves the same way.
      Use system('foo') for capturing shell command output.

Closes #1234

Helped-by: oni-link <knil.ino@gmail.com>
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
James McCoy
c0fd830be4
Bump all nvim-specific error codes above E5000
In order to not conflict with new error codes that Vim adds, all Neovim
error codes should be above 5000.  The three existing sub-5000 error
codes (E926, E951, and E952) are now E50003, E5004, and E5005
respectively.

E953 was removed in 6167ce6df2, so just
remove it from the help.
2016-11-15 23:16:08 -05:00
Björn Linse
b3ece5c81c encoding: update tests
Change shada reencoding tests to check for
correct handling of UTF-8 and binary strings.

Delete enc=latin1 json tests.
2016-11-05 14:49:24 +01:00
Justin M. Keyes
c5f5f427c6 api: api_info()['version']
API level is disconnected from NVIM version. The API metadata holds the
current API level, and the lowest backwards-compatible level supported
by this instance.

Release 0.1.6 is the first release that reports the Nvim version and API
level.

    metadata['version'] = {
      major: 0,
      minor: 1,
      patch: 6,
      api_level: 1,
      api_compatible: 0,
      api_prerelease: false,
    }

The API level may remain unchanged across Nvim releases if the API has
not changed.

When changing the API,
    - set NVIM_API_PRERELEASE to true
    - increment NVIM_API_LEVEL (at most once per Nvim version)
    - adjust NVIM_API_LEVEL_COMPAT if backwards-compatibility was broken

api_level_0.mpack was generated from Nvim 0.1.5 with:
    nvim --api-info
2016-10-28 14:33:13 +02:00
Rui Abreu Ferreira
f25797f869 api: Nvim version, API level #5386
The API level is disconnected from the NVIM version. The API metadata
holds the current API level, and the lowest backwards-compatible level
supported by this instance.

Release 0.1.6 will be the first release reporting the Nvim version and
API level.

    metadata['version'] = {
      major: 0,
      minor: 1,
      patch: 6,
      prerelease: true,
      api_level: 1,
      api_compatible: 0,
    }

The API level may remain unchanged across Neovim releases if the API has
not changed.

When changing the API the CMake variable NVIM_API_PRERELEASE is set to
true, and  NVIM_API_CURRENT/NVIM_API_COMPATIBILITY are incremented
accordingly.

The functional tests check the API table against fixtures of past
versions of Neovim. It compares all the functions in the old table with
the new one, it does ignore some metadata attributes that do not alter
the function signature or were removed since 0.1.5.  Currently the only
fixture is 0.mpack, generated from Neovim 0.1.5 with nvim --api-info.
2016-10-26 14:23:50 +02:00
Florian Larysch
2a6c5bb0c4 modeline: Handle version number overflow. #5450
Closes #5449

A file containing the string "vim" followed by a very large number in a modeline
location will trigger an overflow in getdigits() which is called by
chk_modeline() when trying to parse the version number.

Add getdigits_safe(), which does not assert overflows, but reports them to the
caller.
2016-10-26 13:05:25 +02:00
Justin M. Keyes
714ec09c6d version: Allow has("nvim-x"), has("nvim-x.y") 2016-10-25 13:08:48 +02:00
Justin M. Keyes
e7e2844d46 version: has("nvim-1.2.3")
Helped-by: Daniel Hahler <git@thequod.de>
2016-10-25 11:40:37 +02:00
Justin M. Keyes
459a6ff058 test: system(): Avoid indeterminism. 2016-10-23 00:13:33 +02:00
Justin M. Keyes
9706664b88 system('foo &', 'bar'): Show error, don't crash.
Closes #3529
Closes #5241

In Vim,
    :echo system('cat - &', 'foo')
works because for both system() and :! Vim writes input to a temp file and uses
shell syntax to redirect the file to the backgrounded `cat` (get_cmd_output()
.. make_filter_cmd()).

In Nvim,
    :echo system('cat - &', 'foo')
fails because we write the input directly via pipes (shell.c:do_os_system()),
but (per POSIX[1]) backgrounded process input stream is redirected from
/dev/null (unless overridden by shell redirection; supported only by some shells
[2]), so our writes are ignored, the process exits quickly, and if we are
writing data larger than the buffer size we'll see EPIPE.

This still works:
    :%w !tee > foo1358.txt &
but this does not:
    :%w !tee foo1358.txt &
though it *should* (why doesn't it?) because we still do the temp file dance
in do_bang() .. do_filter().

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_03_02
[2] http://unix.stackexchange.com/a/71218
2016-10-19 01:39:05 +02:00
Justin M. Keyes
97caabc49a test: execute_spec: Adjust screen assertion.
The previous form was passing because it happens immediately before this form;
 but on a very fast(?) server the screen check might miss that form. It's also
 not really want we want to assert anyways.
2016-10-15 22:16:48 +02:00
Björn Linse
719dae2e01 events: allow event processing in getchar()
this is consistent with vim, and is necessary for plugins that implement
their own input modes using "getchar()" and still want to do async
event processing.
2016-10-15 09:50:59 +02:00
Justin M. Keyes
dc6cc4787c api: Establish API naming convention. (#5344)
old name:                   new name:
  --------------------------------------------------
  nvim_name_to_color          nvim_get_color_by_name
  nvim_get_current_buffer     nvim_get_current_buf
  nvim_get_current_window     nvim_get_current_win
  nvim_get_buffers            nvim_list_bufs
  nvim_get_tabpages           nvim_list_tabpages
  nvim_get_windows            nvim_list_wins
  nvim_set_current_buffer     nvim_set_current_buf
  nvim_set_current_window     nvim_set_current_win
  nvim_change_directory       nvim_set_current_dir
  nvim_tabpage_get_window     nvim_tabpage_get_win
  nvim_tabpage_get_windows    nvim_tabpage_list_wins
  nvim_win_get_buffer         nvim_win_get_buf
  nvim_report_error           nvim_err_writeln

Helped-by: Björn Linse <bjorn.linse@gmail.com>
Helped-by: ZyX <kp-pav@yandex.ru>
Helped-by: James McCoy <jamessan@jamessan.com>
2016-09-17 06:30:36 +02:00
Björn Linse
98a08c3e5a api: add tests for calling the api from vimscript 2016-08-31 21:57:06 +02:00
Rui Abreu Ferreira
39c628d031 Mark some functional tests as pending in Windows 2016-08-26 08:21:41 +01:00
Björn Linse
f282b8ecac tests: don't ignore highlights in various tests 2016-08-14 21:53:02 +02:00
Björn Linse
0a51d26b33 timers: do not crash after processing events in the handler 2016-08-10 11:22:28 +02:00
Justin M. Keyes
aa2c439940 eval.c: rename capture() to execute() (#5132) 2016-07-31 13:23:29 -04:00
Björn Linse
5c754a2d22 timers: make repeat=0 work one-shot (consistent with vim) 2016-06-29 18:57:18 +02:00
Björn Linse
2c39e0b03f timers: make timers work with zero timeout 2016-06-29 18:57:18 +02:00
Björn Linse
e8a8342132 test: fix command_count_spec
The test hit wait_return if x or .x.swp exists in the project root directory.
2016-06-23 16:54:19 +02:00
Justin M. Keyes
8a4e5b4bc2 Merge #4697 'capture() function'. 2016-06-20 00:55:41 -04: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
Shougo Matsushita
41c0dfd545 Port capture() function
https://groups.google.com/forum/#!msg/vim_dev/H3Z3ChSUh_4/beZs6KzYdBsJ
2016-05-27 10:33:44 +09:00
Björn Linse
5cc87d4dab cmdline: Redraw the cmdline after processing events
vim-patch:7.4.1603

TODO(bfredl): if we allow events in HITRETURN and ASKMORE states,
we need to add the necessary redraws as well.
2016-05-24 22:11:37 +02:00
Björn Linse
61e8adb25e eval: implement timers. vim-patch: 7.4.1578, 7.4.1831
For the moment, timers are triggered during sleep,
but not in wait-for-input modes, like press-RETURN or f_getchar()
2016-05-24 22:08:56 +02:00
KillTheMule
65b7499872 vim-patch:cb00f03
Add missing test file.

cb00f03933

Converted to a lua test. Change the tolerance of the test to avoid false
positives on travis.
2016-05-08 20:15:07 +02:00
KillTheMule
360d0513d1 Satisfy testlint.
For that, make luatest ignore the preload.lua files.
2016-04-28 19:30:17 +02:00