Commit Graph

139 Commits

Author SHA1 Message Date
zeertzjq
dc6d0d2daf
refactor: reorganize option header files (#25437)
- Move vimoption_T to option.h
- option_defs.h is for option-related types
- option_vars.h corresponds to Vim's option.h
- option_defs.h and option_vars.h don't include each other
2023-09-30 14:41:34 +08:00
zeertzjq
8a59d04a31 test(unit): add test for os_mkdir_recurse "created" 2023-04-16 15:04:41 +08:00
zeertzjq
f39b33ee49 vim-patch:9.0.0411: only created files can be cleaned up with one call
Problem:    Only created files can be cleaned up with one call.
Solution:   Add flags to mkdir() to delete with a deferred function.
            Expand the writefile() name to a full path to handle changing
            directory.

6f14da15ac

vim-patch:8.2.3742: dec mouse test fails without gnome terminfo entry

Problem:    Dec mouse test fails without gnome terminfo entry.
Solution:   Check if there is a gnome entry. Also fix 'acd' test on
            MS-Windows. (Dominique Pellé, closes vim/vim#9282)

f589fd3e10

Cherry-pick test_autochdir.vim changes from patch 9.0.0313.
Cherry-pick test_autocmd.vim changes from patch 9.0.0323.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 15:04:41 +08:00
dundargoc
743860de40
test: replace lfs with luv and vim.fs
test: replace lfs with luv

luv already pretty much does everything lfs does, so this duplication
of dependencies isn't needed.
2023-04-04 21:59:06 +02:00
zeertzjq
b2d984558b
test(unit): use file:close() properly (#21505) 2022-12-22 22:17:01 +08:00
Justin M. Keyes
f50135a32e
feat: stdpath('run'), /tmp/nvim.user/ #18993
Problem:
- Since c57f6b28d7 #8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes #3517
closes #17093
2022-06-30 04:16:46 -07:00
zeertzjq
519e4c4472 test: correct order of arguments to eq() and neq() 2022-04-26 11:38:58 +08:00
dundargoc
0b0c4f7dfa
chore: fix typos (#16816)
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Sebastian Volland <seb@baunz.net>
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-01-04 11:07:40 -07:00
zeertzjq
5b153f5d3d test: remove references to misc1.c 2021-12-11 07:10:01 +08:00
Justin M. Keyes
59712f6dbe
win: avoid duplicate separators in $PATH #12869
Seems like redundant env var separators (";" on Windows) in $PATH can
cause weird behavior. From #7377:

> After some time, system(['win32yank', '-o']) and system('win32yank -o')
> start returning different results: specifically first returns an
> empty string.
>
> 1. $PATH weirdly contains double semicolon followed by path to the
>    “installation directory” (unpacked directory from archive).
> 2. If I run `let $PATH=substitute($PATH, ';;', ';', 'g')` the problem is fixed.

close #7377
ref 224f99b85d
2020-09-08 20:47:22 -07:00
James McCoy
55a885c179
lua: Use #var instead of deprecated table.getn(var) 2020-07-31 01:33:42 -04:00
Brian Wignall
001e69cd46 doc: fix typos
close #11459
2019-11-27 22:47:25 -08:00
Daniel Hahler
0b71bb73e8
tests: improve error message with literat "~" directory (#11032) 2019-09-17 00:39:33 +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
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
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
b-r-o-c-k
ad999eaa77 Merge branch 'master' into s-dash-stdin 2018-04-14 14:17:51 -05:00
Justin M. Keyes
998a16c926 refactor/rename: path_is_absolute() 2018-03-24 14:17:40 +01:00
ZyX
c49e22d396 Merge branch 'master' into s-dash-stdin 2017-12-03 16:49:30 +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
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
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
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
Justin M. Keyes
7c4e5dfd27 win: os_shell_is_cmdexe() + tests 2017-04-12 02:28:43 +02: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
ZyX
cc4523013f eval,fileio: Omit additional fsync() call
Fixes #6420
2017-04-01 21:15:13 +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
8ef6cfa6ac unittests: Fix linter errors 2017-03-11 23:48:16 +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
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
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
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
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
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
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