mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-15 21:18:32 +08:00
78122497f5
CI / Build (push) Has been cancelled
CI / Neovim 0.10 Windows (push) Has been cancelled
CI / Neovim 0.12 Windows (push) Has been cancelled
CI / Vim 8.2 Windows (push) Has been cancelled
CI / Vim 9.2 Windows (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Lua (push) Has been cancelled
CI / Neovim 0.10 Linux (push) Has been cancelled
CI / Neovim 0.12 Linux (push) Has been cancelled
CI / Vim 8.2 Linux (push) Has been cancelled
CI / Vim 9.2 Linux (push) Has been cancelled
* fix(tests): fix ale_c_build_dir_names being unset in tests (#5109) - Use ale#Set() to set the ale_c_build_dir_names variable. - Ensure SetUpLinterTest() is called before any Save commands in tests. - Add c.vim to runtime before non-linter tests are executed. - Remove workarounds in c.vim. * feat: Load Prettier from cjs also * Replace AppVeyor with GitHub Actions for Windows CI Migrate Windows tests from AppVeyor (which hangs on PRs) to native GitHub Actions using rhysd/action-setup-vim to install editors dynamically. - Add test_ale_windows job testing Vim 9.0, Neovim 0.7, and Neovim 0.8 on windows-latest, running in parallel with existing Linux CI - Set fail-fast: false so all matrix entries report results independently - Update run-tests.bat to accept VIM_EXE and VIM_HEADLESS env vars instead of hardcoding C:\vim\vim\vim80\vim.exe - Add -n -i NONE and --not-a-term flags to avoid E211 temp file errors caused by Windows 8.3 short name paths losing drive letters - Override TMP/TEMP to C:\tmp in CI to avoid 8.3 path mangling - Use mklink /J directory junction for C:\testplugin to avoid modifying 146+ test files that reference /testplugin/ paths - Update doc/ale-development.txt section 4.3 for the new setup - Remove AppVeyor badge from README.md - Delete .appveyor.yml Fix pre-existing Windows test failures now visible with Neovim on Windows: - autoload/ale/c.vim: ParseCompileCommandsFlags bufnr() fails when the buffer path has a drive letter but the compile_commands key does not. Add fallback path comparison using ale#path#RemoveDriveLetter() so exact file matches work regardless of drive letter presence. - autoload/ale/path.vim: FindNearestFile and FindNearestDirectory now return ale#path#Simplify() paths, fixing mixed slash separators on Windows that caused test_write_good.vader to fail. - test/smoke_test.vader: echo output has trailing \r on Windows. Change strip pattern from ' *$' to '[\r ]*$' in all TestCallback functions. - test/test_prepare_command.vader: &shellcmdflag on Windows is '/s /c' not '/c'. Use split(&shellcmdflag) in expected values so the test adapts to the actual default. - test/test_lint_file_linters.vader: Increase WaitForJobs timeout from 2000ms to 10000ms to prevent spurious timeouts on Windows CI runners. - test/test_writefile_function.vader: Dissociate buffer from temp file before deleting it to avoid E211 on Windows. * Fix Windows path handling and test compatibility issues Production code fixes: - ale/path.vim: Apply Simplify to buffer_filename in IsBufferPath to fix forward-slash vs backslash mismatch on Neovim Windows; handle .\ prefix - ale/c.vim: Use iterative key-matching via RemoveDriveLetter for both file_lookup and dir_lookup in ParseCompileCommandsFlags - ale/filename_mapping.vim: Normalize suffix separators when mapping target uses forward slashes (fixes mixed-separator paths on Windows) - cuda/nvcc.vim: Apply Simplify before fnamemodify(:p) to fix path doubling Test fixes: - smoke_test: Use safe get() indexing and add retry loop for PowerShell test - test_loclist_corrections: Use Simplify for cross-platform buffer paths - test_ocaml_ocamllsp: Set buffer outside project tree before AssertLSPProject - test_tex_textlint: Set buffer outside node_modules tree on Windows - test_setting_problems_found_in_previous_buffers: Use cmd on Windows - test_lint_file_linters: Increase WaitForJobs timeout to 30s * Fix Vim 9.0 tempname() format change and simplify PowerShell test Vim 9.0 changed tempname() to return a flat path (e.g. C:\tmp\VIMXXXXXXXX) instead of the nested C:\tmp\VIMxxx\NNN format. Using :h:h on the flat format resolves to the drive root, causing IsTempName() to match every path on the drive. This broke tslint handler tests, loclist_corrections, and setting_problems_found_in_previous_buffers tests. Fix s:temp_dir to detect when :h:h yields a root path and fall back to :h. Add GetTempBase() helper in test_format_command.vader with same logic. Simplify smoke_test PowerShell test to avoid multi-command chaining that produces unreliable output on Vim 9.0. * fix(tests): normalize Windows path handling in Vim 9 CI Treat win64 and win32unix as Windows in path and job helpers so compile_commands lookups and async command execution behave consistently on GitHub Actions. Normalize NVCC parsed filenames after absolute expansion to keep expected Windows paths stable in handler tests. * fix(tests): handle Windows variants in command paths Use a shared Windows check for command formatting and execution paths so Vim 9 on GitHub Actions still uses CMD-specific behavior. Apply the same check in filename mapping suffix normalization so Windows-style temporary and mapped paths are converted consistently in tests. * ci: test newer Vim and Neovim versions Update Linux and Windows test targets to newer Vim and Neovim releases in GitHub Actions and the local run-tests workflow. Refresh the Docker test image and helper scripts so the selected editor versions can be built and executed consistently across environments. * fix(tests): adapt checks for Neovim 0.12 and Python 3.12 - Replace deprecated imp with import.util in python tests. - Reorder ale.txt to match help files order. - Add lines to sign test to ensure there are enough lines for the signs. * fix(tests): avoid ftplugin side-effects in uncrustify test * fix(tests): stabilize Windows Vim smoke and path mapping cases Harden smoke_test callback handling for Vim job output race conditions on Windows by safely handling empty callback output lists instead of indexing output[0].\n\nMake disabling_ale assertions compare against a baseline message history entry so preexisting Vim startup messages do not cause false failures.\n\nUpdate path-mapping tests to account for Vim 9 Windows tempname layout changes and to validate filename-modifier behavior after full-path filename mapping is applied. * fix(tests): normalize Windows test paths to resolved workspace paths On Windows Neovim 0.10, test working directories can resolve to host checkout paths (for example D:\a\ale\ale) instead of container-style mount paths (for example C:\testplugin). Many tests compared absolute paths against g:dir-derived expectations and failed despite equivalent files.\n\nNormalize test directory handling in ale#test helpers by storing and using ale#path#Simplify(resolve(getcwd())), so expected paths match the same canonical form used by path discovery functions.\n\nAlso update tests that manually reassign g:dir from raw getcwd() and Gradle path assertions to use resolved/simplified paths, preventing regressions from mixed mount-path forms across Vim/Neovim and CI environments. * fix(tests): restore g:dir semantics for fixer and test helpers * Revert "fix(tests): normalize Windows test paths to resolved workspace paths" This reverts commit 1136e2daec2645f643211e7e41819fa3eeba61b4. * fix(tests): use resolve() in ant test assertions for Windows junction paths On Windows CI, a junction C:\testplugin -> D:\a\ale\ale is used so tests can cd to /testplugin paths. However, findfile() + fnamemodify(':p') resolves junction points to real paths, while g:dir holds the junction-based path. Fix the two ant test files to use resolve(g:dir) only in the specific assertions that compare paths returned by findfile()-based functions (ale#ant#FindProjectRoot, ale#ant#BuildClasspathCommand). This way: - On Linux: resolve() is a no-op, behaviour unchanged - On Windows: resolve(g:dir) gives the real path that matches what findfile() returns, fixing the assertion mismatch The global test infrastructure (ale#test#SetDirectory) is left unchanged to avoid breaking the many fixer tests that rely on junction-based paths. * Fix Windows junction path resolution in tests On Windows CI, tests run from a junction point (C:\testplugin) that points to the real workspace (D:\a\ale\ale). Functions like ale#path#FindNearestFile resolve junctions via findfile()/fnamemodify(':p'), returning the real path, while g:dir holds the junction path. Wrap expected path values with resolve() so junction paths are resolved to their real counterparts on Windows (resolve() is a no-op on Linux), making assertions match across both platforms. * fix(test): use fnamemodify to compute expected nvcc path on Windows The test hardcoded 'C:\tmp\...' for Windows paths, but GitHub Actions runners use D: drive. Use ale#path#Simplify(fnamemodify(..., ':p')) in expected values to mirror exactly what the handler produces, making the test drive-letter-agnostic. * fix: resolve symlinks/junctions in FindNearest* path functions On Windows, Vim's findfile()/finddir() returns junction paths while Neovim resolves them. This inconsistency causes test failures when comparing paths from these functions against g:dir (set via getcwd()). Add resolve() to FindNearestFile, FindNearestDirectory, and FindNearestFileOrDirectory so they always return canonical paths, making behavior consistent across Vim and Neovim on Windows. On Linux, resolve() is a no-op for non-symlinked paths. * fix: resolve junctions in python path functions and fix trailing separator - Add resolve() to FindVirtualenv, FindProjectRoot, FindProjectRootIni in autoload/ale/python.vim so they return canonical paths on Windows NTFS junctions - Move trailing '/' inside ale#path#Simplify() in FindNearestDirectory and FindNearestFileOrDirectory so separator is OS-appropriate * fix: remove unnecessary junction in Windows CI The C:\testplugin junction was a leftover from AppVeyor. It caused C: vs D: path mismatches when resolve() canonicalized paths. Running directly from the workspace eliminates the discrepancy. * fix: use getcwd() for Windows runtimepath instead of hardcoded C:\testplugin The junction no longer exists, so use the actual working directory to find ALE plugin files in the test vimrc. * fix: map /testplugin/ paths to repo root on Windows Without the C:\testplugin junction, SetDirectory('/testplugin/test') failed silently, leaving cwd at the repo root. Now on Windows, the /testplugin/ prefix is replaced with the actual repo root derived from the script's file path. * fix: remaining Windows test failures (format_command, dprint, tslint, smoke) - test_format_command: compute :h modifier depth dynamically since Vim 9.x Windows uses flat tempname() while NeoVim uses nested dirs - test_dprint_fixer: replace hardcoded C:\testplugin path with dynamic path relative to g:dir - smoke_test: increase PowerShell job timeout and add sleep between retries for flaky Windows CI - workflow: set TMP/TEMP on same drive as workspace to fix cross-drive relative path resolution in tslint handler test * fix: skip PowerShell smoke test on Vim Windows The test is inherently flaky with Vim's Windows job implementation when &shell=powershell. NeoVim handles it reliably and still tests this code path. * fix: NeoVim Windows test failures (dmd handler, c_flag_parsing, lint_file timeout) - dmd handler: replace \f+ with [^(]+ in regex since NeoVim's isfname on Windows doesn't include \ or :, so \f+ can't match absolute paths - c_flag_parsing: use FullPath() helper for file! commands and dict keys so NeoVim v0.10.4 resolves drive-relative paths correctly - lint_file_linters: increase WaitForJobs timeout from 30s to 60s for slower NeoVim Windows CI runners * fix: skip flaky NeoVim Windows tests (c_flag_parsing, lint_file_linters) - c_flag_parsing test 18: skip on NeoVim Windows because fnamemodify(':p') does not reliably add a drive letter to fake absolute paths on NeoVim <= 0.10, causing dir_lookup key mismatches - lint_file_linters test 8: skip on NeoVim Windows because jobs don't complete within the 30s timeout due to slower job handling Both tests pass on Linux and Vim Windows. TODO comments added to restore them once the underlying NeoVim Windows issues are resolved. * ci: update checkout githuh action to v6 * Preserve Vim 8.2 as a minimum supported version for now * fix: Use a lower Vim version for Windows tests --------- Co-authored-by: w0rp <devw0rp@gmail.com>
546 lines
24 KiB
Plaintext
546 lines
24 KiB
Plaintext
*ale-development.txt* For Vim version 8.0.
|
|
*ale-dev*
|
|
*ale-development*
|
|
|
|
ALE Development Documentation
|
|
|
|
===============================================================================
|
|
CONTENTS *ale-development-contents*
|
|
|
|
1. Introduction.........................|ale-development-introduction|
|
|
2. Design Goals.........................|ale-design-goals|
|
|
3. Coding Standards.....................|ale-coding-standards|
|
|
4. Testing ALE..........................|ale-development-tests|
|
|
4.1. Writing Linter Tests.............|ale-development-linter-tests|
|
|
4.2. Writing Fixer Tests..............|ale-development-fixer-tests|
|
|
4.3. Running Tests on Windows.........|ale-development-windows-tests|
|
|
5. Contributing.........................|ale-development-contributing|
|
|
5.1. Preparing a Release..............|ale-development-release|
|
|
|
|
|
|
===============================================================================
|
|
1. Introduction *ale-development-introduction*
|
|
|
|
This document contains helpful information for ALE developers, including
|
|
design goals, information on how to run the tests, coding standards, and so
|
|
on. You should read this document if you want to get involved with ALE
|
|
development.
|
|
|
|
|
|
===============================================================================
|
|
2. Design Goals *ale-design-goals*
|
|
|
|
This section lists design goals for ALE, in no particular order. They are as
|
|
follows.
|
|
|
|
ALE code should be almost 100% VimL. This makes the plugin as portable as
|
|
possible.
|
|
|
|
ALE should run without needing any other plugins to be installed, to make
|
|
installation simple. ALE can integrate with other plugins for more advanced
|
|
functionality, non-essential functionality, or improving on basic first party
|
|
functionality.
|
|
|
|
ALE should check files with as many tools as possible by default, except where
|
|
they cause security issues or make excessive use of resources on modern
|
|
machines.
|
|
|
|
ALE should be free of breaking changes to the public API, which is comprised of
|
|
documented functions and options, until a major version is planned. Breaking
|
|
changes should be preceded by a deprecation phase complete with warnings.
|
|
Changes required for security may be an exception.
|
|
|
|
ALE supports Vim 8.2 and above, and Neovim 0.10.0 or newer. These are the
|
|
earliest versions of Vim and Neovim which support |+job|, |+timer|,
|
|
|+closure|, and |+lambda| features. All ALE code should be written so it is
|
|
compatible with these versions of Vim, or with version checks so particular
|
|
features can degrade or fail gracefully.
|
|
|
|
Just about everything should be documented and covered with tests.
|
|
|
|
By and large, people shouldn't pay for the functionality they don't use. Care
|
|
should be taken when adding new features, so supporting new features doesn't
|
|
degrade the general performance of anything ALE does.
|
|
|
|
LSP support will become more important as time goes on. ALE should provide
|
|
better support for LSP features as time goes on.
|
|
|
|
When merging pull requests, you should respond with `Cheers! :beers:`, purely
|
|
for comedy value.
|
|
|
|
|
|
===============================================================================
|
|
3. Coding Standards *ale-coding-standards*
|
|
|
|
The following general coding standards should be adhered to for Vim code.
|
|
|
|
* Check your Vim code with `Vint` and do everything it says. ALE will check
|
|
your Vim code with Vint automatically. See: https://github.com/Kuniwak/vint
|
|
Read ALE's `Dockerfile` to see which version of `Vint` it uses.
|
|
* Try to write descriptive and concise names for variables and functions.
|
|
Names shouldn't be too short or too long. Think about others reading your
|
|
code later on.
|
|
* Use `snake_case` names for variables and arguments, and `PascalCase` names
|
|
for functions. Prefix every variable name with its scope. (`l:`, `g:`, etc.)
|
|
* Try to keep lines no longer than 80 characters, but this isn't an absolute
|
|
requirement.
|
|
* Use 4 spaces for every level of indentation in Vim code.
|
|
* Add a blank line before every `function`, `if`, `for`, `while`, `try`, or `return`,
|
|
which doesn't start a new level of indentation. When adding more code on the
|
|
same indentation level, also add blank lines after every corresponding end
|
|
for those mentioned keywords. This makes the logic in your code easier to
|
|
follow.
|
|
* End every file with a trailing newline character, but not with extra blank
|
|
lines. Remove trailing whitespace from the ends of lines.
|
|
* Write the full names of commands instead of abbreviations. For example, write
|
|
`function` instead of `func`, and `endif` instead of `end`.
|
|
* Write functions with `!`, so files can be reloaded. Use the |abort| keyword
|
|
for all functions, so functions exit on the first error.
|
|
* Make sure to credit yourself in files you have authored with `Author:`
|
|
and `Description:` comments.
|
|
|
|
In addition to the above general guidelines for the style of your code, you
|
|
should also follow some additional rules designed to prevent mistakes. Some of
|
|
these are reported with ALE's `custom-linting-rules` script. See
|
|
|ale-development-tests|.
|
|
|
|
* Don't leave stray `:echo` lines in code. Write `" no-custom-checks` above
|
|
the line if you must echo something.
|
|
* For strings use |is#| instead of |==#|, `is?` instead of `==?`, `isnot#`
|
|
instead of `!=#`, and `isnot?` instead of `!=?`. This is because `'x' ==# 0`
|
|
returns 1, while `'x' is# 0` returns 0, so you will experience fewer issues
|
|
when numbers are compared with strings. `is` and `isnot` also do not throw
|
|
errors when other objects like List or Dictionaries are compared with
|
|
strings.
|
|
* Don't use the `getcwd()` function in the ALE codebase. Most of ALE's code
|
|
runs from asynchronous callback functions, and these functions can execute
|
|
from essentially random buffers. Therefore, the `getcwd()` output is
|
|
useless. Use `expand('#' . a:buffer . ':p:h')` instead. Don't use
|
|
`expand('%...')` for the same reason.
|
|
* Don't use the `simplify()` function. It doesn't simplify paths enough. Use
|
|
`ale#path#Simplify()` instead.
|
|
* Don't use the `shellescape()` function. It doesn't escape arguments properly
|
|
on Windows. Use `ale#Escape()` instead, which will avoid escaping where it
|
|
isn't needed, and generally escape arguments better on Windows.
|
|
* Don't use the `tempname()` function. It doesn't work when `$TMPDIR` isn't
|
|
set. Use `ale#util#Tempname()` instead, which temporarily sets `$TMPDIR`
|
|
appropriately where needed.
|
|
* Use `snake_case` names for linter names, so they can be used as part of
|
|
variable names. You can define `aliases` for linters, for other names people
|
|
might try to configure linters with.
|
|
* Use |v:t_TYPE| variables instead of `type()`, which are more readable.
|
|
|
|
Apply the following guidelines when writing Vader test files.
|
|
|
|
* Use 2 spaces for Vader test files, instead of the 4 spaces for Vim files.
|
|
* If you write `Before` and `After` blocks, you should typically write them at
|
|
the top of the file, so they run for all tests. There may be some tests
|
|
where it make sense to modify the `Before` and `After` code part of the way
|
|
through the file.
|
|
* If you modify any settings or global variables, reset them in `After`
|
|
blocks. The Vader `Save` and `Restore` commands can be useful for this
|
|
purpose.
|
|
* If you load or define linters in tests, write `call ale#linter#Reset()` in
|
|
an `After` block.
|
|
* Just write `Execute` blocks for Vader tests, and don't bother writing `Then`
|
|
blocks. `Then` blocks execute after `After` blocks in older versions, and
|
|
that can be confusing.
|
|
|
|
Apply the following rules when writing Bash scripts.
|
|
|
|
* Run `shellcheck`, and do everything it says.
|
|
See: https://github.com/koalaman/shellcheck
|
|
* Try to write scripts so they will run on Linux, BSD, or Mac OSX.
|
|
|
|
|
|
===============================================================================
|
|
4. Testing ALE *ale-development-tests* *ale-dev-tests* *ale-tests*
|
|
|
|
ALE is tested with a suite of tests executed via GitHub Actions. ALE runs
|
|
tests with the following versions of Vim in the following environments.
|
|
|
|
1. Vim 8.2 on Linux and Windows via GitHub Actions.
|
|
2. Vim 9.2 on Linux and Windows via GitHub Actions.
|
|
3. Neovim 0.10 on Linux and Windows via GitHub Actions.
|
|
4. Neovim 0.12 on Linux and Windows via GitHub Actions.
|
|
|
|
If you are developing ALE code on Linux, Mac OSX, or BSD, you can run ALEs
|
|
tests by installing Docker and running the `run-tests` script. Follow the
|
|
instructions on the Docker site for installing Docker.
|
|
See: https://docs.docker.com/install/
|
|
|
|
NOTE: Don't forget to add your user to the `docker` group on Linux, or Docker
|
|
just won't work. See: https://docs.docker.com/install/linux/linux-postinstall/
|
|
|
|
If you run simply `./run-tests` from the ALE repository root directory, the
|
|
latest Docker image for tests will be downloaded if needed, and the script
|
|
will run all of the tests in Vader, Vint checks, and several Bash scripts for
|
|
finding extra issues. Run `./run-tests --help` to see all of the options the
|
|
script supports. Note that the script supports selecting particular test files.
|
|
|
|
Once you get used to dealing with Vim and NeoVim compatibility issues, you
|
|
probably want to use `./run-tests --fast -q` for running tests with only the
|
|
fastest available Vim version, and with success messages from tests
|
|
suppressed.
|
|
|
|
Generally write tests for any changes you make. The following types of tests
|
|
are recommended for the following types of code.
|
|
|
|
* New/edited error handler callbacks -> Write tests in `test/handler`
|
|
* New/edited linter definition -> Write tests in `test/linter`
|
|
* New/edited fixer functions -> Write tests in `test/fixers`
|
|
|
|
Look at existing tests in the codebase for examples of how to write tests.
|
|
Refer to the Vader documentation for general information on how to write Vader
|
|
tests: https://github.com/junegunn/vader.vim
|
|
|
|
If you need to add any supporting files for tests, such as empty files present
|
|
to test searching upwards through paths for configuration files, they can be
|
|
added to the `test/test-files` directory.
|
|
|
|
See |ale-development-linter-tests| for more information on how to write linter
|
|
tests.
|
|
|
|
When you add new linters or fixers, make sure to add them into the tables in
|
|
supported-tools.md and |ale-supported-languages-and-tools.txt|. If you forget to
|
|
keep them both in sync, you should see an error like the following in the
|
|
builds run for GitHub Actions.
|
|
>
|
|
========================================
|
|
diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables
|
|
========================================
|
|
Differences follow:
|
|
|
|
--- /tmp/readme.qLjNhJdB 2018-07-01 16:29:55.590331972 +0100
|
|
+++ /tmp/doc.dAi8zfVE 2018-07-01 16:29:55.582331877 +0100
|
|
@@ -1 +1 @@
|
|
- ASM: gcc, foobar
|
|
+ ASM: gcc
|
|
<
|
|
Make sure to list documentation entries for linters and fixers in individual
|
|
help files in the table of contents, and to align help tags to the right
|
|
margin. For example, if you add a heading for an `aardvark` tool to
|
|
`ale-python.txt` with a badly aligned doc tag, you will see errors like so. >
|
|
|
|
========================================
|
|
Look for badly aligned doc tags
|
|
========================================
|
|
Badly aligned tags follow:
|
|
|
|
doc/ale-python.txt:aardvark ...
|
|
========================================
|
|
Look for table of contents issues
|
|
========================================
|
|
|
|
Check for bad ToC sorting:
|
|
|
|
Check for mismatched ToC and headings:
|
|
|
|
--- /tmp/table-of-contents.mwCFOgSI 2018-07-01 16:33:25.068811878 +0100
|
|
+++ /tmp/headings.L4WU0hsO 2018-07-01 16:33:25.076811973 +0100
|
|
@@ -168,6 +168,7 @@
|
|
pyrex (cython), ale-pyrex-options
|
|
cython, ale-pyrex-cython
|
|
python, ale-python-options
|
|
+ aardvark, ale-python-aardvark
|
|
autopep8, ale-python-autopep8
|
|
black, ale-python-black
|
|
flake8, ale-python-flake8
|
|
<
|
|
Make sure to make the table of contents match the headings, and to keep the
|
|
doc tags on the right margin.
|
|
|
|
|
|
===============================================================================
|
|
4.1 Writing Linter Tests *ale-development-linter-tests*
|
|
|
|
Tests for ALE linters take two forms.
|
|
|
|
1. Tests for handling the output of commands.
|
|
2. Tests for checking which commands are run, or connections are made.
|
|
|
|
Tests of the first form should go in the `test/handler` directory, and should
|
|
be written like so. >
|
|
|
|
Before:
|
|
" Load the file which defines the linter.
|
|
runtime ale_linters/filetype/linter_name_here.vim
|
|
|
|
After:
|
|
" Unload all linters again.
|
|
call ale#linter#Reset()
|
|
|
|
Execute(The output should be correct):
|
|
|
|
" Test that the right loclist items are parsed from the handler.
|
|
AssertEqual
|
|
\ [
|
|
\ {
|
|
\ 'lnum': 1,
|
|
\ 'type': 'E',
|
|
\ 'text': 'Something went wrong',
|
|
\ },
|
|
\ ],
|
|
\ ale_linters#filetype#linter_name#Handle(bufnr(''), [
|
|
\ '1:Something went wrong',
|
|
\ ]
|
|
<
|
|
Tests for what ALE runs should go in the `test/linter` directory, and should
|
|
be written like so. >
|
|
|
|
Before:
|
|
" Load the linter and set up a series of commands, reset linter variables,
|
|
" clear caches, etc.
|
|
"
|
|
" Vader's 'Save' command will be called here for linter variables.
|
|
call ale#assert#SetUpLinterTest('filetype', 'linter_name')
|
|
|
|
After:
|
|
" Reset linters, variables, etc.
|
|
"
|
|
" Vader's 'Restore' command will be called here.
|
|
call ale#assert#TearDownLinterTest()
|
|
|
|
Execute(The default command should be correct):
|
|
" AssertLinter checks the executable and command.
|
|
" Pass expected_executable, expected_command
|
|
AssertLinter 'some-command', ale#Escape('some-command') . ' --foo'
|
|
|
|
Execute(Check chained commands):
|
|
" GivenCommandOutput can be called with 1 or more list for passing output
|
|
" to chained commands. The output for each callback defaults to an empty
|
|
" list.
|
|
GivenCommandOutput ['v2.1.2']
|
|
" Given a List of commands, check all of them.
|
|
" Given a String, only the last command in the chain will be checked.
|
|
AssertLinter 'some-command', [
|
|
\ ale#Escape('some-command') . ' --version',
|
|
\ ale#Escape('some-command') . ' --foo',
|
|
\]
|
|
<
|
|
The full list of commands that will be temporarily defined for linter tests
|
|
given the above setup are as follows.
|
|
|
|
`GivenCommandOutput [...]` - Define output for ale#command#Run.
|
|
`AssertLinterCwd cwd` - Check the `cwd` for the linter.
|
|
`AssertLinter executable, command` - Check the executable and command.
|
|
`AssertLinterNotExecuted` - Check that linters will not be executed.
|
|
`AssertLSPLanguage language` - Check the language given to an LSP server.
|
|
`AssertLSPOptions options_dict` - Check the options given to an LSP server.
|
|
`AssertLSPConfig config_dict` - Check the config given to an LSP server.
|
|
`AssertLSPProject project_root` - Check the root given to an LSP server.
|
|
`AssertLSPAddress address` - Check the address to an LSP server.
|
|
|
|
|
|
===============================================================================
|
|
4.2 Writing Fixer Tests *ale-development-fixer-tests*
|
|
|
|
Tests for ALE fixers should go in the `test/fixers` directory, and should
|
|
be written like so. >
|
|
|
|
Before:
|
|
" Load the fixer and set up a series of commands, reset fixer variables,
|
|
" clear caches, etc.
|
|
"
|
|
" Vader's 'Save' command will be called here for fixer variables.
|
|
call ale#assert#SetUpFixerTest('filetype', 'fixer_name')
|
|
|
|
After:
|
|
" Reset fixers, variables, etc.
|
|
"
|
|
" Vader's 'Restore' command will be called here.
|
|
call ale#assert#TearDownFixerTest()
|
|
|
|
Execute(The default command should be correct):
|
|
" AssertFixer checks the result of the loaded fixer function.
|
|
AssertFixer {'command': ale#Escape('some-command') . ' --foo'}
|
|
|
|
Execute(Check chained commands):
|
|
" Same as above for linter tests.
|
|
GivenCommandOutput ['v2.1.2']
|
|
" Given a List of commands, check all of them.
|
|
" Given anything else, only the last result will be checked.
|
|
AssertFixer [
|
|
\ ale#Escape('some-command') . ' --version',
|
|
\ {'command': ale#Escape('some-command') . ' --foo'}
|
|
\]
|
|
<
|
|
The full list of commands that will be temporarily defined for fixer tests
|
|
given the above setup are as follows.
|
|
|
|
`GivenCommandOutput [...]` - Define output for ale#command#Run.
|
|
`AssertFixerCwd cwd` - Check the `cwd` for the fixer.
|
|
`AssertFixer results` - Check the fixer results
|
|
`AssertFixerNotExecuted` - Check that fixers will not be executed.
|
|
|
|
|
|
===============================================================================
|
|
4.3 Running Tests on Windows *ale-development-windows-tests*
|
|
|
|
Tests are run for ALE on Windows via GitHub Actions using the
|
|
`rhysd/action-setup-vim` action to install Vim and Neovim. These tests can
|
|
frequently break due to minor differences in paths and how escaping is done
|
|
for commands on Windows.
|
|
|
|
The GitHub Actions workflow automatically:
|
|
1. Installs the specified Vim or Neovim version.
|
|
2. Clones Vader to `C:\vader` at the pinned commit.
|
|
3. Creates a directory junction from `C:\testplugin` to the repository
|
|
checkout, so all test paths referencing `/testplugin/` resolve correctly.
|
|
4. Runs `run-tests.bat` with the installed editor.
|
|
|
|
If you are a Linux or Mac user and need to run Windows tests locally, you
|
|
can use a Windows virtual machine. Here is a process for that.
|
|
|
|
First, install a Windows image with VirtualBox. Install VirtualBox and grab
|
|
a VirtualBox image for Windows such as from here:
|
|
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
|
|
|
|
NOTE: If you need to enter a password for the virtual machine at any point,
|
|
the password is "Passw0rd!" without the double quotes.
|
|
|
|
NOTE: If your trial period for Windows runs out, run the commands like the
|
|
wallpaper tells you to.
|
|
|
|
Consult the VirtualBox documentation on how to install "Guest Additions."
|
|
You probably want to install "Guest Additions" for most things to work
|
|
properly.
|
|
|
|
After you've loaded your virtual machine image, go into "Settings" for your
|
|
virtual machine, and "Shared Folders." Add a shared folder with the name
|
|
"ale", and set the "Folder Path" to the path to your ALE repository, for
|
|
example: "/home/w0rp/ale"
|
|
|
|
Find out which drive letter "ale" has been mounted as in Windows. We'll use
|
|
"E:" as the drive letter, for example. Open the command prompt as an
|
|
administrator and type the following command to create a junction for the
|
|
"ale" directory, where "E:" is replaced with your drive letter. >
|
|
|
|
mklink /J C:\testplugin E:
|
|
<
|
|
Install Vader by opening PowerShell and running: >
|
|
|
|
git clone https://github.com/junegunn/vader.vim C:\vader
|
|
cd C:\vader
|
|
git checkout -qf c6243dd81c98350df4dec608fa972df98fa2a3af
|
|
<
|
|
Install Vim or Neovim on your Windows machine. You can download Vim from
|
|
https://github.com/vim/vim-win32-installer/releases or Neovim from
|
|
https://github.com/neovim/neovim/releases .
|
|
|
|
After you have finished installing everything, you can run the tests by
|
|
setting the `VIM_EXE` environment variable to the path of your Vim or
|
|
Neovim executable and running `run-tests.bat`. For Neovim, also set
|
|
`VIM_HEADLESS` to `--headless`. >
|
|
|
|
cd C:\testplugin
|
|
set VIM_EXE=C:\path\to\vim.exe
|
|
run-tests
|
|
<
|
|
For Neovim: >
|
|
|
|
cd C:\testplugin
|
|
set VIM_EXE=C:\path\to\nvim.exe
|
|
set VIM_HEADLESS=--headless
|
|
run-tests
|
|
<
|
|
It will probably take several minutes for all of the tests to run. Be
|
|
patient. You can run a specific test by passing the filename as an argument
|
|
to the batch file, for example: `run-tests test/test_c_flag_parsing.vader`.
|
|
This will give you results much more quickly.
|
|
|
|
|
|
===============================================================================
|
|
5. Contributing *ale-development-contributing*
|
|
|
|
All integration of new code into ALE is done through GitHub pull requests.
|
|
Using that tool streamlines the process and minimizes the time and effort
|
|
required to e.g. ensure test suites are run for every change.
|
|
|
|
As for any project hosted by GitHub, the choice of platform demands every
|
|
contributor to take care to setup an account and configure it accordingly.
|
|
|
|
Due to details of our process, a difference to many other GitHub hosted
|
|
projects is that contributors who wish to keep the author fields for their
|
|
commits unaltered need to configure a public email address in their account
|
|
and profile settings. See: https://docs.github.com/en/account-and-profile/
|
|
|
|
Unless configuring GitHub to expose contact details, commits will be rewritten
|
|
to appear by `USERNAME <RANDOM_NUMBER+USERNAME@users.noreply.github.com>` .
|
|
|
|
|
|
===============================================================================
|
|
5.1 Preparing a Release *ale-development-release*
|
|
|
|
ALE offers release packages through GitHub, for two reasons:
|
|
|
|
1. Some users like to target specific release versions rather than simply
|
|
installing the plugin from `master`. This includes users who create Linux
|
|
distribution specific packages from GitHub releases.
|
|
2. The releases provide a nice way to get an overview of what has changed in
|
|
ALE over time.
|
|
|
|
ALE has no fixed release schedule. Release versions are created whenever the
|
|
ALE developers feel the need to create one. ALE release versions follow the
|
|
typical Semantic Versioning scheme. See: https://semver.org/
|
|
|
|
Minor version releases for ALE should be the most common, followed by patch
|
|
releases. Every minor version release should be followed by a `vA.B.x` branch
|
|
such as `v2.0.x` for version `2.0.0` and every following patch version before
|
|
`2.1.0`. The `git` branch strategy for patches is to first merge a bug fix to
|
|
`master`, and then `git cherry-pick` a patch to a branch for a specific
|
|
version. ALE developers do not generally support anything but `master` or the
|
|
last minor version.
|
|
|
|
Generally ALE releases hit a major version only when there are breaking
|
|
changes to a public ALE setting or function. A "public" setting or function is
|
|
defined as any setting or function documented in the `:help` |ale.txt| file.
|
|
Major ALE versions ought to be so rare that they only come once a year at
|
|
most. ALE should not typically introduce any breaking changes.
|
|
|
|
If there are ever to be any breaking changes made for ALE, there should first
|
|
come a minor version release for ALE documenting all of the coming breaking
|
|
changes to ALE. It should be described how users can prepare for a breaking
|
|
change that is coming before it is done.
|
|
|
|
To create a release for ALE, you will need sufficient permissions in GitHub.
|
|
Once you do, follow these steps.
|
|
|
|
1. Create a new release draft, or edit an existing one. It helps to craft
|
|
drafts ahead of time and write the last commit ID checked for release notes
|
|
on the last update to a draft.
|
|
See the releases page: https://github.com/dense-analysis/ale/releases
|
|
2. Examine `git log` and read changes made between the last ID checked, or the
|
|
git tag of the previous release, and the current commit in `master`.
|
|
3. Write updates in separate sections (except where empty) for:
|
|
3.a. Breaking Changes
|
|
3.b. Deprecated Features
|
|
3.c. New Features
|
|
3.d. New Linters
|
|
3.e. New Fixers
|
|
3.f. Linter Enhancements
|
|
3.g. Fixer Enhancements
|
|
3.h. Bugs Fixed
|
|
4. Once you've finished writing the draft for the release, bump
|
|
`s:current_ale_version` in `autoload/ale.vim` to the current version, and
|
|
add a line to `test/test_ale_has.vader` to test for the version. See
|
|
|ale#Has()| documentation for more information.
|
|
5. Commit the changes after `./run-tests --fast -q` passes.
|
|
6. Tag the release with `git tag vA.B.C`, replacing `A`, `B`, and `C` with the
|
|
version numbers. See `git tag --list` for examples.
|
|
7. Run `git push` and `git push --tags` to push the commit and the tag.
|
|
8. Edit the release draft in GitHub, select the tag you just pushed, and
|
|
publish the draft.
|
|
9. If you're creating a new major or minor version: `git checkout -b vA.B.x`,
|
|
replacing `A` and `B` with the major and minor versions. `git push` the new
|
|
branch, and the GitHub branch protection settings should automatically
|
|
apply to the new release branch.
|
|
10. You have already completed the last step.
|
|
|
|
Have fun creating ALE releases. Drink responsibly, or not at all, which is the
|
|
preference of w0rp.
|
|
|
|
|
|
===============================================================================
|
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|