Commit Graph

58 Commits

Author SHA1 Message Date
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
zeertzjq
4528a69c87
test: remove unnecessary nil argument to testutil (#28270) 2024-04-11 08:51:06 +08:00
Lewis Russell
81fc27124b refactor(test): inject after_each differently 2024-04-10 15:53:50 +01:00
bfredl
3d44340cea fix(tests): use more global highlight definitions 2024-04-09 09:09:41 +02: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
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
6c3ddd8c51
test: set 'termguicolors' in outer Nvim instance (#26437)
Currently, the value of $COLORTERM in :terminal in tests depends on
outer environment because of 'notermguicolors'.

If $COLORTERM is not set in :terminal, an inner Nvim instance will try
to detect 'termguicolors' support, which may interfere with tests.

So set 'termguicolors' in outer Nvim instance unless $COLORTERM needs to
be overridden, and unset it in inner Nvim instance when running TUI.
2023-12-07 10:16:00 +08:00
Gregory Anders
a5a346678a test: set notermguicolors in tests
Set 'notermguicolors' in tests which spawn a child Nvim process to force
existing tests to use 16 colors. Also refactor the child process
invocation to make things a little bit less messy.
2023-12-06 10:38:44 -08:00
Evgeni Chasnovski
64a14026d7
feat(highlight): update default color scheme
Problem: Default color scheme is suboptimal.

Solution: Start using new color scheme. Introduce new `vim` color scheme
for opt-in backward compatibility.

------
Main design ideas
- Be "Neovim branded".
- Be minimal for 256 colors with a bit more shades for true colors.
- Be accessible through high enough contrast ratios.
- Be suitable for dark and light backgrounds via exchange of dark and
  light palettes.

------
Palettes

- Have dark and light variants. Implemented through exporeted
  `NvimDark*` and `NvimLight*` hex colors.

- Palettes have 4 shades of grey for UI elements and 6 colors (red,
  yellow, green, cyan, blue, magenta).

- Actual values are computed procedurally in Oklch color space based on
  a handful of hyperparameters.

- Each color has a 256 colors variant with perceptually closest color.

------
Highlight groups

Use:

- Grey shades for general UI according to their design.

- Bold text for keywords (`Statement` highlight group). This is an
  important choice to increase accessibility for people with color
  deficiencies, as it doesn't rely on actual color.

- Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some
  minor text UI elements.

- Cyan as main syntax color, i.e. for function usage (`Function`
  highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI
  elements.

- Red to generally mean high user attention, i.e. errors; in particular
  for `ErrorMsg`, `DiffDelete`, `DiagnosticError`.

- Yellow very sparingly only with true colors to mean mild user
  attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`.

- Blue very sparingly only with true colors as `DiagnosticHint` and some
  additional important syntax group (like `Identifier`).

- Magenta very carefully (if at all).

------
Notes

- To make tests work without relatively larege updates, each one is
  prepended with an equivalent of the call `:colorscheme vim`.

  Plus some tests which spawn new Neovim instances also now use 'vim'
  color scheme.

  In some cases tests are updated to fit new default color scheme.
2023-12-02 18:53:19 +02:00
bfredl
b522cb1ac3 refactor(grid): make screen rendering more multibyte than ever before
Problem: buffer text with composing chars are converted from UTF-8
to an array of up to seven UTF-32 values and then converted back
to UTF-8 strings.

Solution: Convert buffer text directly to UTF-8 based schar_T values.

The limit of the text size is now in schar_T bytes, which is currently
31+1 but easily could be raised as it no longer multiplies the size
of the entire screen grid when not used, the full size is only required
for temporary scratch buffers.

Also does some general cleanup to win_line text handling, which was
unnecessarily complicated due to multibyte rendering being an "opt-in"
feature long ago. Nowadays, a char is just a char, regardless if it consists
of one ASCII byte or multiple bytes.
2023-11-17 12:58:57 +01:00
zeertzjq
d321deb4a9
test: fix dependencies between test cases (#23343)
Discovered using --shuffle argument of busted.
2023-04-27 15:51:44 +08:00
dundargoc
9d574f8dd7
ci: bump to windows 2022
Skip failing funcitonaltests. Use jobstart() instead termopen() for
oldtests to prevent CI freezing.
2023-03-11 22:56:16 +01: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
bfredl
068a998e60 fix(tests): remove irrelevant usage of display-=msgsep
These were just added to avoid churn when changing the default
of 'display'. To simplify message handling logic, we might want
to remove support for printing messages in default_grid later on.
This would allow things like printing error messages safely in the
middle of redraw, or a future graduation of the 'multigrid' feature.
2022-08-17 23:44:49 +02: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
zeertzjq
6e414b698c
test: unskip tests on Windows (#18600)
Remove the command('qall!') from mksession_spec.lua because it prevents
helpers.rmdir() from retrying.

Allow extra trailing spaces when matching terminal lines.
2022-05-18 12:57:04 +08:00
zeertzjq
0545bd2180 test: use helpers.pending_win32(pending) instead of iswin() 2022-02-26 19:40:11 +08:00
Dundar Göc
82c5a02050 ci: skip tests that fail on windows 2022-02-20 10:22:39 +01:00
Justin M. Keyes
6751d6254b
refactor(tests): use assert_alive() #15546 2021-09-01 09:42:53 -07:00
Jan Edmund Lazo
172d5b6561
test: rewrite powershell tests to remove timeout
TSAN kept failing and Appveyor sometimes fails on the same test.
2020-11-20 19:55:17 -05:00
Jan Edmund Lazo
1836853955
ci: test powershell core on Linux 2019-12-31 15:11:08 -05:00
Daniel Hahler
4bbad54817
tests: fix non-controversial misuse of pending (#11247)
Ref: https://github.com/neovim/neovim/pull/11184
2019-10-18 04:46:30 +02:00
Björn Linse
4987311fb5 tests/ui: remove unnecessary screen:detach()
It is perfectly fine and expected to detach from the screen just by
the UI disconnecting from nvim or exiting nvim. Just keep detach() in
screen_basic_spec, to get some coverage of the detach method itself.

This avoids hang on failure in many situations (though one could argue
that detach() should be "fast", or at least "as fast as resize",
which works in press-return already).

Never use detach() just to change the size of the screen, try_resize()
method exists for that specifically.
2019-10-13 22:10:42 +02:00
Jan Edmund Lazo
a7fc2f3f64 test: "!:&" works with powershell #11201
Removed 'echo' alias because it does not behave like POSIX echo.
2019-10-10 21:30:20 -07:00
Jan Edmund Lazo
51f2826f61 doc: update shellquote for powershell #11122
shellquote is not treated like shellxquote for non-quote values.
2019-10-10 01:16:02 -07:00
Justin M. Keyes
ead39d6ce6 test/uname(): always lowercase 2019-09-01 22:49:33 -07:00
Justin M. Keyes
7d20907724 test/OpenBSD: skip some tests
Temporary workaround to unblock CI for OpenBSD.
2019-09-01 22:49:33 -07:00
Daniel Hahler
bf85023005 shell-test: remove REP_NODELAY, less delay with REP
REP_NODELAY was added because REP delayed too much.  This changes REP to
only add a delay on every 100th line instead.

This helps to cover the additional pulse steps with
out_data_decide_throttle, which would have required to change
REP_NODELAY anyway.
2019-08-30 07:12:46 +02:00
Jan Edmund Lazo
a5b915e56c
test: win: enable output_spec test 2019-08-18 21:40:26 -04:00
Daniel Hahler
38a3af5dff
tests: output_spec: use shell-test REP_NODELAY (#10726)
Fix flaky "shell command :! throttles shell-command output greater than ~10KB:":

    [ RUN      ] shell command :! throttles shell-command output greater than ~10KB:
    warning: Screen changes were received after the expected state. This indicates
    indeterminism in the test. Try adding screen:expect(...) (or wait()) between
    asynchronous (feed(), nvim_input()) and synchronous API calls.
      - Use screen:redraw_debug() to investigate; it may find relevant intermediate
        states that should be added to the test to make it more robust.
      - If the purpose of the test is to assert state after some user input sent
        with feed(), adding screen:expect() before the feed() will help to ensure
        the input is sent when Nvim is in a predictable state. This is preferable
        to wait(), for being closer to real user interaction.
      - wait() can trigger redraws and consequently generate more indeterminism.
        Try removing wait().

    ERR
    test/functional/ui/screen.lua:579: Failed to match any screen lines.
    Expected (anywhere): "
    %."
    Actual:
      |XXXXXXXXXX 591                                    |
      |XXXXXXXXXX 592                                    |
      |XXXXXXXXXX 593                                    |
      |XXXXXXXXXX 594                                    |
      |                                                  |
      |                                                  |
      |{3:-- TERMINAL --}                                    |
    stack traceback:
            test/functional/ui/screen.lua:579: in function '_wait'
            test/functional/ui/screen.lua:367: in function 'expect'
            test/functional/ui/output_spec.lua:63: in function <test/functional/ui/output_spec.lua:53>

Log: https://travis-ci.org/neovim/neovim/jobs/569082705#L5355
(gcc-functionaltest-lua)
2019-08-08 16:02:28 +02:00
Justin M. Keyes
94afc201bc test: isCI(): add "name" parameter 2019-08-05 04:02:41 +02:00
Justin M. Keyes
4f5e378124
test/CI: skip "throttles output" test on Travis macOS #9721
Travis macOS is not fast enough to run this test reliably. The test
depends on the system producing output faster than the Nvim TUI can
handle it.
2019-03-12 19:26:24 +01:00
James McCoy
2fbe28bc05
Mark "shell command :! throttles shell-command output greater than ~10KB" fragile 2019-01-01 11:27:52 -05:00
Justin M. Keyes
deb18a050e
defaults: background=dark #2894 (#9205)
By historical accident, Nvim defaults to background=light. So on a dark
background, `:colorscheme default` looks completely wrong.

The "smart" logic that Vim uses is confusing for anyone who uses Vim on
multiple platforms, so rather than mimic that, pick the (hopefully) most
common default.

- Since Neovim is dark-powered, we assume most users have dark backgrounds.
- Most of the GUIs tend to have a dark background by default.

ref #6289
2018-11-20 10:52:49 +01:00
Björn Linse
c8810a51a3 tests: improve robustness of immediate successes in screen tests 2018-10-15 20:13:11 +02:00
Björn Linse
3d88287e30 tests: introduce screen:expect{...} form 2018-08-27 15:15:49 +02:00
James McCoy
6c0f1903e6
functionaltest: Use octal escapes for printf
According to POSIX[0], only octal escapes are supported by the printf
command.  GNU coreutils' printf and some shells' builtin printf versions
which support hex escapes, but dash and non-GNU printf do not.

[0]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
2018-06-13 23:03:37 -04:00
Björn Linse
98e7112390 msg: do not scroll entire screen (#8088) 2018-03-31 11:12:27 +02:00
Jan Edmund Lazo
c03a847884 win: enable backtick_expansion and shell output tests 2018-02-10 22:28:12 +01:00
Björn Linse
f75c4b39ec shell: handle split-up UTF-8 sequences 2018-02-10 22:28:12 +01:00
Björn Linse
01cdeff626 tests: integrate ex_cmds/bang_filter_spec into ui/output_spec
they test the same thing. Filtering is tested elsewhere.
2018-02-10 22:28:12 +01:00
Björn Linse
60ce7d9e0a shell: support bell 2018-02-10 22:28:12 +01:00
Justin M. Keyes
352a51e831 test: :! print binary data, control chars
closes #5442
closes #4142
ref #6618
ref #4376
ref #7844
ref #2958
ref #4338
2018-02-07 09:25:51 +01:00
Björn Linse
9af14506e5 shell: add test for binary and multibyte output
Also update existing tests for new (vim-compatible) newline behavior
2018-02-06 10:23:26 +01:00
Justin M. Keyes
a90beeadbb defaults: 'showcmd', 'belloff', 'ruler'
- Vim "unix default" of 'noshowcmd' is serving few users. And it's
  inconsistent.
- 'ruler' and 'belloff=all' improve the out-of-the-box experience.
- Continue to use 'noshowcmd' and 'noruler' by default in the functional
  tests to keep them fast.

TODO: Add a "disable slow stuff" command or mapping to address the
use-case of a very slow terminal connection.
2017-03-16 18:44:10 +01:00
Justin M. Keyes
25427ae892 test: Fix broken test. 2017-01-24 14:25:50 +01:00
Justin M. Keyes
a3a241d313 ci: XXX: Disable "throttle" test on Travis macOS. 2017-01-23 22:17:16 +01:00