1
0
forked from aniani/vim

27 Commits

Author SHA1 Message Date
Aliaksei Budavei
7ceca3eb00
runtime(syntax-tests): Support "wait-free" test failure
When certain changes guarantee failure for old syntax tests,
opt for faster failure by reducing the number of screendumps
made for each file "page" to be no greater than the assigned
value of a VIM_SYNTAX_TEST_WAIT_TIME environment variable.
(This variable will be ignored and more screendumps may be
made when Make is GNU Make and a parent Makefile is used.)

Barring regressions, and assuming that v9.1.1163~1 succeeds
in providing a correct synchronisation mechanism outside of
"VerifyScreenDump()", and assuming that "readfile()" always
obtains the latest contents written by "term_dumpwrite()" in
"VerifyScreenDump()"; making a single screendump of a file
"page" and following it with a single reading of the written
screendump file should be enough to decide whether to pass
or fail a syntax test.

In addition, re-enable self testing after v9.1.1183~2.

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-03-16 20:59:28 +01:00
Aliaksei Budavei
f63c3467b1
runtime(syntax-tests): Improve parts of "runtest.vim"
* Accommodate the calling of "EraseLineAndReturnCarriage()"
  to not interfere with the "skipped" and "failed" reports.

* Create the "failed" directory, if unavailable, without
  relying on "VerifyScreenDump()" to do it so that reporting
  with "Xtestscript#s:AssertCursorForwardProgress()" can be
  uniformly attempted.

* Make an only list copy of the "Xtestscript" contents and
  share it with every syntax test.

* Narrow the scope of the "filetype" and "failed_root" local
  variables.

closes: #16789

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-03-08 16:58:17 +01:00
Aliaksei Budavei
6852e5c597
runtime(syntax-tests): Re-introduce support for "phoney" languages
As of patch v9.1.1176~1, there are no longer makeshift Make
targets to accommodate language names that can match phoney
targets.  For example, "clean_" was previously generated for
Clean because otherwise it clashed with the "clean" target.

Additionally, enable test filtering for makeshift targets.

Reference:
https://wiki.clean.cs.ru.nl/Clean

closes: #16810

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-03-07 19:12:45 +01:00
Aliaksei Budavei
7003a5d63f
runtime(syntax-tests): Apply stronger synchronisation between buffers
The current lightweight synchronisation with ":redraw" needs further
reinforcement in the light of v9.1.1110.  And, with v9.1.0820, make
another synchronisation point _before_ the first (or only) screenful is
dumped.

Also add a script to regenerate all screendumps.

closes: #16632

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-03-01 16:28:20 +01:00
Christian Brabandt
203c7225f5
CI: huge linux builds should also run syntax & indent tests
closes: #15960

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-10-29 20:27:34 +01:00
Christian Brabandt
de79f9129a
runtime(syntax-tests): tiny vim fails because of line-continuation
Problem:  tiny vim fails because of line-continuation, although
          the test script should be skipped for non-eval builds of Vim.
Solution: :set cpo&vim

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-10-24 23:03:10 +02:00
Aliaksei Budavei
ec0229414b
patch 9.1.0763: tests: cannot run single syntax tests
Problem:  tests: cannot run single syntax tests
Solution: Support running a subset of syntax tests
          (Aliaksei Budavei)

Two methods of assembling a subset of test filenames for
selection are provided:

* Filename and filetype Make targets will be generated, and
  multiple such targets can be passed before the mandated
  trailing "test" target, e.g. "make html markdown test".

* Filenames and their parts can be specified as a regular
  expression that is assigned to a "VIM_SYNTAX_TEST_FILTER"
  environment variable, and used with the test Make target,
  e.g. "VIM_SYNTAX_TEST_FILTER=html\\\|markdown make test".
  (This variable will be ignored and the whole suite will be
  run when Make is GNU Make and a parent Makefile is used.)

Methods can be used alone or together, with the Make targets
having the higher precedence. Neither method will influence
the order of test execution.

closes: #15670

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-10-06 16:57:33 +02:00
Aliaksei Budavei
d33afe12c6
runtime(syntax-tests): Facilitate the viewing of rendered screendumps
With the submitted "viewdumps.vim" script, a few manual
steps in typical workflows (see below) can be automated.
The updated "README.txt" contains additional information.

============================================================

Reviewing LOCAL failed syntax tests can be arranged as
follows:

1) Run tests and generate screendumps:
------------------------------------------------------------
cd /path/to/fork/runtime/syntax
make clean test
------------------------------------------------------------

2) Examine the screendumps from the "failed" directory:
------------------------------------------------------------
../../src/vim --clean -S testdir/viewdumps.vim
------------------------------------------------------------

============================================================

Reviewing UPLOADED failed syntax tests can be arranged as
follows (it can be further locally scripted):

1) Fetch an artifact with failed screendumps from
"github.com/vim/vim/actions/runs/A_ID/artifacts/B_ID".

2) Extract the archived files:
------------------------------------------------------------
unzip /tmp/failed-tests.zip -d /tmp
------------------------------------------------------------

3) Set up the "dumps" directory.  Create a symlink to
"/path/to/fork/dirs/dumps" in the extracted directories so
that term_dumpdiff() can be used.  (The lookup algorithm
resolves "dumps" for every loaded filename.  So, with
"/tmp/runtime/syntax/testdir/failed/*.dump" files passed
as script arguments, the algorithm will make the files in
"/tmp/runtime/syntax/testdir/dumps" queried.)
------------------------------------------------------------
cd /path/to/fork
ln -s $(pwd)/runtime/syntax/testdir/dumps \
  /tmp/runtime/syntax/testdir/dumps
------------------------------------------------------------

4) Examine the extracted screendumps:
------------------------------------------------------------
./src/vim --clean -S runtime/syntax/testdir/viewdumps.vim \
  /tmp/runtime/syntax/testdir/failed/*.dump
------------------------------------------------------------

5) Clean up:
------------------------------------------------------------
unlink /tmp/runtime/syntax/testdir/dumps
rm -rf /tmp/runtime
------------------------------------------------------------

============================================================

Reviewing SUBMITTED FOR PULL REQUEST syntax tests can be
arranged as follows (it can be further locally scripted):

1) List the fetched changeset and write the changed "dumps"
filenames to "/tmp/filelist":
------------------------------------------------------------
cd /path/to/fork
git switch prs/1234
git diff-index --relative=runtime/syntax/testdir/dumps/ \
  --name-only prs/1234~1 > /tmp/filelist
------------------------------------------------------------

2) Reconcile relative filepaths, and copy next-to-be-updated
"dumps" files in the "failed" directory (note the missing
new screendumps, if any):
------------------------------------------------------------
git switch master
cd runtime/syntax/testdir/dumps
cp -t ../failed $(cat /tmp/filelist)
------------------------------------------------------------

3) Remember about the introduced INVERTED relation between
"dumps" and "failed", i.e. the files to be committed are in
"dumps" already and their previous versions are in "failed";
therefore, copy the missing new screendumps from "dumps" to
"failed" (otherwise these won't be shown):
------------------------------------------------------------
git switch prs/1234
cp -t ../failed foo_10.dump foo_11.dump foo_12.dump
------------------------------------------------------------

4) Examine the screendumps from the "failed" directory (new
screendumps will be shown with no difference between their
versions):
------------------------------------------------------------
cd ..
../../../src/vim --clean -S viewdumps.vim
------------------------------------------------------------

closes: #15476

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-08-12 18:43:06 +02:00
Aliaksei Budavei
b5a92d72eb
runtime(syntax-tests): Stop generating redundant "*_99.dump" files
- Remove the code handling their generation.
- Remove the code written for the shell filetype to clear up
  the buffer screen before such a file can be generated.
- Remove all but "yaml.yaml_99.dump" of such generated files
  (since there is no published "input/yaml.yaml.yaml", let
  its maintainer regenerate screen dump files and remove
  redundant ones).

The new algorithm turns a "*_99.dump" file obsolete because
all lines written in such a file will already be present in
lower-numbered "*.dump" files.

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-07 20:51:14 +02:00
Aliaksei Budavei
719714383e
runtime(syntax-tests): Abort and report failed cursor progress
Track the cursor forward progress through a syntax test file
so that any degenerate input can be checked and reported.

closes: #15150

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-06 12:00:02 +02:00
Aliaksei Budavei
d2f4987999
runtime(syntax-tests): Introduce self tests for screen dumping
Write a batch of test files with made-up syntax to serve for
additional linewise checks to be manually performed whenever
the algorithm for screen dump file generation is modified.

Define a shell variable VIM_SYNTAX_SELF_TESTING to run these
tests:
	cd runtime/syntax/
	VIM_SYNTAX_SELF_TESTING=1 make clean test

related: #15150

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-06 11:59:35 +02:00
Aliaksei Budavei
cc5482edb4
runtime(syntax-tests): Clear and redraw the ruler line with the shell info
The current contents of sh_01_99.dump and sh_09_99.dump
begin with ":redraw" in the ruler line whereas both the
comment and the need for the redraw command execution imply
blanks "       ".

related: #15150

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-06 11:56:56 +02:00
Aliaksei Budavei
8418446644
runtime(syntax-tests): Allow for folded and wrapped lines in syntax test files
The current implementation falls short for syntax test files
on two accounts:
1. With folded lines -- some lines before folded lines are
    unnecessarily repeated in generated dump files because
    closed folded lines are always treated as opened for the
    cursor to move _in_ instead of to move _over_ them.
2. With wrapped lines (longer than 75 columns) -- some lines
    are omitted in generated dump files because calculations
    for the cursor progress and its movement commands only
    refer to file lines and not their layout within a 20x75
    buffer (less &cmdheight).

As an alternative, we abandon deterministic (and inaccurate
at times) calculations for the cursor progress and, instead,
advance the cursor by as much as before for a single dump
file, but now rely on marking the last visible line and
additional movement to position lines at desired offsets,
carefully preserving compatibility for the &scrolloff and
&ruler values inherited from defaults.vim.  The parent Vim
process will keep track of progress through a syntax test
file made by its child process ("terminal") by reading the
rightmost end of the ruler line from the terminal buffer,
looking for " All " or " Bot " for its cue to finish dump
file generation.

With these changes applied, the lossless line length limit
will be raised from 75 to 1425 (for a 19x75 view) columns.

Also, prefer "lastline" to "truncate" for &display; hiding
the content of any last _long_ line in a view goes against
the purpose of syntax file testing -- all lines should be
recorded.

related: #15150
fixes: #14245

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-06 11:56:31 +02:00
Aliaksei Budavei
a2addebca3
runtime(syntax-tests): include missing changes
related: #14215

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-18 20:40:54 +01:00
Aliaksei Budavei
a9bc195d64
runtime(syntax-tests): Retrofit input/c.c. with TEST_SETUP
Also:

- Include a syntax test for Markdown that takes advantage of
  a sourceable setup configuration.
- Update Filelist

closes: #14215

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-18 19:32:48 +01:00
Aliaksei Budavei
f6069a7ddc
runtime(syntax-tests): Support sourceable Vim configuration for syntax tests
Not all programming languages support comments; without such
support, the TEST_SETUP functionality that offers embeddable
Vim Ex commands may no longer be applicable.

We can achieve similar functionality by storing Ex commands
in a Vim file with its basename matching the basename of the
test file, and having this Vim file sourced, and then having
the test file loaded and tested.  When such a Vim file would
be used for a language that has comments and whose matching
test file has embedded TEST_SETUP lines, we will accommodate
it by letting the TEST_SETUP lines augment and/or overrule
sourced configuration.

Further details can be found in the discussion thread at
https://github.com/vim/vim/discussions/14117.

related: #14215

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-18 19:32:48 +01:00
Aliaksei Budavei
93edd254d5
runtime(syntax-tests): Support embeddable Vim configuration for syntax tests
Currently, the very same syntax file for which a test can
be written is the only place where global variables can be
defined so that the file parts guarded with such variables
can be read during screen dump generation.  This approach
would lead to littering the syntax file with test-related
queries.

Instead, we could borrow the idea of comment-based mechanism
for test setup from the indent test runner.  With it, the
first 20 lines of each test file would be ALWAYS scanned in
search of the TEST_SETUP markers and, when found, the part
between the end of the marker and the end of the line would
be treated as a Vim Ex command.

Note that with these changes, runtime/defaults.vim is no
longer sourced for screen dump generation; however, some of
its functionality is reintroduced.

Further details can be found in the discussion thread at
https://github.com/vim/vim/discussions/14117.

related: #14215

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-18 19:32:16 +01:00
Christian Brabandt
56824430c0
runtime(syntax-tests): simplify code and allow filetype options
The whole testdir/runtest.vim is a bit of a mess. So this is an attempt
to improving the current state. First of all, let's move most of the
code into a single RunTest() function so that it's easier to run this
manually.

Then, let's add the possibility to customize filetype specific tests by
applying filetype specific options. We will make use of it in the next
commit, where the provided java file uses tabs, which cause line
wrapping which will then cause the scrolling to miss some lines when
redrawing (see #14105)

related: #14105

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28 21:24:25 +01:00
Christian Brabandt
627c950e5b
patch 9.1.0091: Syntax test fails when run with non C locale
Problem:  Syntax test fails when run with non C locale
Solution: Run syntax tests with C locale, clean up Xtestscript file,
          strip environment variables from GetVimCommand()
          (h-east)

closes: #14007

Co-authored-by: h-east <h.east.727@gmail.com>
Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-10 13:02:17 +01:00
Dominique Pellé
99c3849a92
patch 9.0.1929: runtime tests fail with tiny vim
Problem:  runtime tests fail with tiny vim
Solution: check for tiny vim, run runtime tests in CI
          even for tiny version

closes: #13169
closes: #13170

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Dominique Pellé <dominique.pelle@tomtom.com>
2023-09-24 16:09:31 +02:00
Bram Moolenaar
7d0dbd0070 patch 9.0.1656: syntax test fails when detected shell type differs
Problem:    Syntax test fails when detected shell type differs.
Solution:   Avoid using "/bin/sh", it depends on the system.  Add a check that
            the shell type detection is correct.
2023-06-24 00:56:50 +01:00
Bram Moolenaar
2f43ec9363 patch 9.0.1655: syntax test fails when Vim window is not tall enough
Problem:    Syntax test fails when Vim window is not tall enough.
Solution:   Make sure each terminal window is closed.
2023-06-23 22:59:26 +01:00
Bram Moolenaar
bd32e8ad8d patch 9.0.1652: unclear why syntax test fails on Mac
Problem:    Unclear why syntax test fails on Mac.
Solution:   Echo v:errors when it's not empty.
2023-06-23 21:36:31 +01:00
Bram Moolenaar
c6530c9d68 patch 9.0.1649: syntax test failure causes script to abort
Problem:    Syntax test failure causes script to abort.
Solution:   Fix appending string to list.
2023-06-22 23:04:11 +01:00
Bram Moolenaar
031d632188 patch 9.0.1648: result of syntax tests is hard to see
Problem:    Result of syntax tests is hard to see.
Solution:   List the failed tests.
2023-06-22 22:38:54 +01:00
Bram Moolenaar
1aa5f1c21f patch 9.0.1647: insufficient testing for syntax plugins
Problem:    Insufficient testing for syntax plugins.
Solution:   Add shell file examples. (Charles Campbell)  Create a messages
            file for easier debugging and reporting the test results.
2023-06-22 21:57:51 +01:00
Bram Moolenaar
46acad7284 patch 9.0.1627: no generic mechanism to test syntax plugins
Problem:    No generic mechanism to test syntax plugins.
Solution:   Add a syntax plugin test mechanism, using screendumps.  Add a
            simple test for "c".
2023-06-11 19:04:18 +01:00