Commit Graph

61 Commits

Author SHA1 Message Date
bfredl
e61228a214 fix(tests): needing two calls to setup a screen is cringe
Before calling "attach" a screen object is just a dummy container for
(row, col) values whose purpose is to be sent as part of the "attach"
function call anyway.

Just create the screen in an attached state directly. Keep the complete
(row, col, options) config together. It is still completely valid to
later detach and re-attach as needed, including to another session.
2024-11-14 12:40:57 +01:00
dundargoc
052498ed42 test: improve test conventions
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.
2024-04-23 18:17:04 +02:00
Lewis Russell
81fc27124b refactor(test): inject after_each differently 2024-04-10 15:53:50 +01:00
dundargoc
7035125b2b test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-08 22:51:00 +02:00
bfredl
0c59771e31 refactor(tests): all screen tests should use highlights
This is the first installment of a multi-PR series significantly
refactoring how highlights are being specified.

The end goal is to have a base set of 20 ish most common highlights,
and then specific files only need to add more groups to that as needed.

As a complicating factor, we also want to migrate to the new default
color scheme eventually. But by sharing a base set, that future PR
will hopefully be a lot smaller since a lot of tests will be migrated
just simply by updating the base set in place.

As a first step, fix the anti-pattern than Screen defaults to ignoring
highlights. Highlights are integral part of the screen state, not
something "extra" which we only test "sometimes". For now, we still
allow opt-out via the intentionally ugly

  screen._default_attr_ids = nil

The end goal is to get rid of all of these eventually (which will be
easier as part of the color scheme migration)
2024-03-23 13:44:35 +01:00
zeertzjq
268066e014
fix(process): start pty process eof timer on main thread (#27625) 2024-02-26 09:47:49 +08:00
zeertzjq
267e90f31d
fix(edit): don't go to Terminal mode when stopping Insert mode (#27033) 2024-01-16 10:42:09 +08:00
Lewis Russell
795f896a57 test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
Lewis Russell
4f81f506f9 test: normalise nvim bridge functions
- remove helpers.cur*meths
- remove helpers.nvim
2024-01-12 17:53:27 +00:00
Justin M. Keyes
04f2f864e2 refactor: format test/* 2024-01-03 02:09:29 +01:00
zeertzjq
1037ce2e46 test: avoid repeated screen lines in expected states
This is the command invoked repeatedly to make the changes:

    :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
2023-12-09 22:15:02 +08:00
zeertzjq
62dff43947
test(ex_terminal_spec): match descriptions (#26314) 2023-11-30 08:56:21 +08:00
zeertzjq
90b213990f test: :terminal when 'shell' uses backslashes 2023-11-30 07:32:28 +08:00
zeertzjq
73691b6c3d
test(ex_terminal_spec): unskip tests that work on Windows (#26310) 2023-11-30 07:06:23 +08:00
zeertzjq
82b1a389ba
fix(terminal): avoid Insert mode in Terminal buffer (#25820) 2023-10-29 09:32:03 +08:00
Gregory Anders
673ee213e9 test: update tests for auto-closing :term buffers
The terminal buffer closes automatically when using `:terminal` and the
command exits without an error. This messes up some tests that expect
the terminal buffer to still be open. We can force the buffer not to
close by passing an argument to `:terminal`. This can be anything, since
the shell-test stub simply prints whatever argument it's given.
2023-08-10 09:08:25 -05:00
zeertzjq
ce56ad2ba7
test: reduce flakiness (#24443)
Avoid consecutive RPC requests involving :startinsert or :stopinsert,
because consecutive RPC requests may be processed together, before the
:startinsert or :stopinsert takes effect.

Also change some feed_command() to command() to make tests faster.
2023-07-23 12:46:56 +08:00
Lewis Russell
1fe1bb084d refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-05-21 15:14:01 +06:00
dundargoc
5eb5f49488
test: simplify platform detection (#21020)
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.
2022-11-22 08:13:30 +08:00
dundargoc
736c36c02f
test: introduce skip() #21010
This is essentially a convenience wrapper around the `pending()`
function, similar to `skip_fragile()` but more general-purpose.

Also remove `pending_win32` function as it can be replaced by
`skip(iswin())`.
2022-11-13 05:52:19 -08:00
dundargoc
5046b4b4ad
ci: add cirrus to isCI function to skip tests (#20526)
The environment variable CIRRUS_CI is manually passed to RunTests.cmake
as it doesn't get passed when using cmake script mode.
2022-10-17 17:16:31 +02:00
dundargoc
2d6735d8ce
ci: move BSD jobs from sourcehut to Cirrus CI #19616
dispatch.sr.ht is being deprecated, meaning that using sourcehut CI
won't be possible (see https://github.com/neovim/neovim/issues/19609).
Since Github Actions doesn't provide any BSD runners an external service
is required and Cirrus CI seems like a good replacement for sourcehut.

Initially experimented with using FreeBSD and OpenBSD virtual machines
in GitHub Actions, but Cirrus has been a much better fit with better
performance, logs and overall experience.

Failing tests are automatically skipped on FreeBSD regardless if it's on
CI or not. Ideally these tests should only be skipped in CI with the
help of `isCI` helper function. Unfortunately, the tests don't recognize
the environment variable CIRRUS_CI even if it's set manually. This
workaround is good enough for the time being, but we might want to only
skip tests when using the CI (or even better, fix the failing tests).

Closes: https://github.com/neovim/neovim/issues/19609
2022-09-08 15:12:42 -07:00
Justin M. Keyes
f977f9445f refactor(tests): introduce testprg()
Also:
- Add a describe('shell :!') section to system_spec.
- Make the test for #16271 work on systems without powershell.
2022-06-25 08:27:17 -07:00
Dundar Göc
82c5a02050 ci: skip tests that fail on windows 2022-02-20 10:22:39 +01:00
zeertzjq
f4359b5dbd
vim-patch:8.2.3461: distinguish Normal and Terminal-Normal mode #15878
Problem:    Cannot distinguish Normal and Terminal-Normal mode.
Solution:   Make mode() return "nt" for Terminal-Normal mode. (issue vim/vim#8856)
72406a4bd2
2021-10-09 18:15:46 -07:00
Justin M. Keyes
6751d6254b
refactor(tests): use assert_alive() #15546 2021-09-01 09:42:53 -07:00
Björn Linse
07cc231142 A Mudholland Dr. Recast
The commit summary maybe does not make sense, but calling a function
that does not wait on anything `wait()` makes even less sense.
2020-10-19 21:48:06 +02:00
Daniel Hahler
e1d63c180c
tests: ex_terminal_spec: retry ":terminal (with fake shell)" (#11588)
Flaky failure (Travis CI, macOS):

    [ RUN      ] :terminal (with fake shell) works with gf: 10518.41 ms FAIL
    test/functional/terminal/ex_terminal_spec.lua:248: Row 1 did not match.
    Expected:
      |*^ready $ echo "scripts/shadacat.py"                |
      |*                                                  |
      |*[Process exited 0]                                |
      |:terminal echo "scripts/shadacat.py"              |
    Actual:
      |*^                                                  |
      |*[Process exited 0]                                |
      |*                                                  |
      |:terminal echo "scripts/shadacat.py"              |
    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.
    stack traceback:
            test/functional/ui/screen.lua:579: in function '_wait'
            test/functional/ui/screen.lua:361: in function 'expect'
            test/functional/terminal/ex_terminal_spec.lua:248: in function <test/functional/terminal/ex_terminal_spec.lua:245>
2019-12-22 11:23:39 +01:00
Justin M. Keyes
f63d952ca2 test: use shell-test (avoid system shell) 2019-09-01 09:03:46 -07:00
Daniel Hahler
c07f266c5b
tests: ex_terminal_spec: add test for previous leak (#10450)
Closes https://github.com/neovim/neovim/pull/4766.
2019-07-08 18:42:52 +02:00
Daniel Hahler
1c45ba462b
tests: fix flaky "terminal (with fake shell) with not arguments …" (#10401)
`retry()` would only try it three times (waiting for 20ms in between),
despite the large timeout.

Fixes https://github.com/neovim/neovim/issues/10265.
2019-07-02 19:31:36 +02:00
glacambre
b3fd83a0ea Reset stop_insert_mode in terminal_enter rather than terminal_check
Problem: Using `:stopinsert` while in normal mode in a terminal buffer
prevents neovim from entering insert mode.

Solution: Move `stop_insert_mode = false` from terminal_check to
terminal_enter to be consistent with edit.c, as suggested by bfredl in
 #9889.

Closes https://github.com/neovim/neovim/issues/9889.
2019-04-20 10:41:46 +02:00
glacambre
d928b036dc :stopinsert should leave terminal-mode #9856
Problem:  Calling :stopinsert from RPC while in terminal-mode does not
          go back to normal-mode.
Solution: Implement a check() handler for state_enter(), adapted from
          insert_check().

Fix #7807
2019-04-08 01:13:43 +02:00
Björn Linse
3d88287e30 tests: introduce screen:expect{...} form 2018-08-27 15:15:49 +02:00
林千里
451c48a092 terminal: flush vterm output buffer on pty output #8486
Fixes #4151

libvterm uses an "output buffer" for terminal reporting
(e.g. \e[6n to report cursor position)
Flush it in on_channel_output() not just terminal_send_key()

See also this line from pangoterm:
https://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/607/pangoterm.c#L2159
2018-06-08 02:18:27 +02:00
Jan Edmund Lazo
131aad953c win: defaults: 'shellcmdflag', 'shellxquote' #7343
closes #7698

Wrapping a command in double-quotes allows cmd.exe to safely dequote the
entire command as if the user entered the entire command in an
interactive prompt. This reduces the need to escape nested and uneven
double quotes.

The `/s` flag of cmd.exe makes the behaviour more reliable:

    :set shellcmdflag=/s\ /c

Before this patch, cmd.exe cannot use cygwin echo.exe (as opposed to
cmd.exe `echo` builtin) even if it is wrapped in double quotes.

Example:
:: internal echo
> cmd /s /c " echo foo\:bar" "
foo\:bar"

:: cygwin echo.exe
> cmd /s /c " "echo" foo\:bar" "
foo:bar
2018-03-24 22:05:53 +01:00
Justin M. Keyes
d73dd1588c :terminal Enter/Leave should not increment jumplist
The old behavior is probably not justified, for the usual reason:
terminal buffers may have interactive processes, so cursor placement is
arbitrary, therefore tracking it in the jumplist is useless (or worse).

N.B.: per the docstring for `checkpcmark()` it looks like we were
calling `checkpcmark()` and `setpcmark()` in the wrong order.

closes #3723
2018-02-07 00:01:58 +01:00
Jan Edmund Lazo
e9b5616eaf win: enable tests in ex_terminal_spec 2018-01-06 17:46:49 +01:00
Justin M. Keyes
618cfe03fc test: ex_terminal_spec.lua: retry flaky test (#7245)
https://api.travis-ci.org/jobs/271833660/log.txt
2017-09-07 09:40:37 +02:00
Drew Neil
642e14d9e7 Repair ex_terminal_spec functional tests 2017-08-21 20:44:03 +01:00
Justin M. Keyes
d2d76882f7 win/test: enable more :terminal tests
To deal with SIGWINCH limitations on Windows, change some resize tests
to _shrink_ the screen width. ... But this didn't work, so still
ignoring those tests on Windows.
2017-08-16 09:13:44 +02:00
erw7
4b1f21de75 win: support :terminal 2017-08-16 09:13:43 +02:00
Björn Linse
48f0542ad6 tests: detect invalid helpers.sleep 2017-04-21 14:21:26 +02:00
Björn Linse
2c5751b9b2 ui: add tests for new cursor shape modes 2017-04-21 12:32:38 +02:00
ZyX
65fb622000 functests: Replace execute with either command or feed_command
Hope this will make people using feed_command less likely: this hides bugs.
Already found at least two:

1. msgpackparse() will show internal error: hash_add() in case of duplicate
   keys, though it will still work correctly. Currently silenced.
2. ttimeoutlen was spelled incorrectly, resulting in option not being set when
   expected. Test was still functioning somehow though. Currently fixed.
2017-04-09 03:24:08 +03:00
Jack Bracewell
2ea7bfc627 terminal: Support extra arguments in 'shell'. #4504
Tokenize p_sh if used as default in ex_terminal(). Previously p_sh was
used as the first arg in a list when calling termopen(), this would try
to call an untokenized version of shell, meaning if you had an argument
in 'shell':
    set shell=/bin/bash\ --login
the command would fail.

Helped-by: oni-link <knil.ino@gmail.com>

Closes #3999
2017-03-17 17:47:33 +01:00
Justin M. Keyes
4ceec30cd0 terminal: Follow output only if cursor is at end.
Closes #2257
Closes #2636
References #2683
2017-02-26 13:00:01 +01:00
Justin M. Keyes
e7bbd35c81 terminal: 'scrollback'
Closes #2637
2017-02-26 11:57:52 +01:00
Tommy Allen
bdfa1479d2 eval.c: Fix findfile(), :find, gf in :terminal. #6009
Closes #4299
2017-01-31 00:48:30 +01:00
Justin M. Keyes
6636e2a259 test: :terminal should not interrupt Press-ENTER
References #2748
2016-10-20 23:41:59 +02:00