-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set working directory for Elvis linter (#4726)
Most of the time it works to assume that the current working directory is the root of the project. However, this is not the case for Rebar3 checked out dependencies, for example. It's also worth noting that because of the way Elvis handles file patterns, and because directories in configuration are relative to the project root, the path supplied to command must be also relative.
- Loading branch information
1 parent
5e8904c
commit b74cd02
Showing
3 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,52 @@ | ||
Before: | ||
let b:file = fnamemodify(bufname(''), ':.') | ||
call ale#assert#SetUpLinterTest('erlang', 'elvis') | ||
|
||
After: | ||
unlet! b:root | ||
|
||
call ale#assert#TearDownLinterTest() | ||
|
||
Execute(Default command should be correct): | ||
AssertLinter 'elvis', | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' . ale#Escape(b:file) | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(expand('%:.')) | ||
|
||
Execute(Executable should be configurable): | ||
let b:ale_erlang_elvis_executable = '/path/to/elvis' | ||
|
||
AssertLinter '/path/to/elvis', | ||
\ ale#Escape('/path/to/elvis') . ' rock --output-format=parsable ' . ale#Escape(b:file) | ||
\ ale#Escape('/path/to/elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(expand('%:.')) | ||
|
||
Execute(Project root should be detected using elvis.config): | ||
let b:root = '../test-files/erlang/app_with_elvis_config' | ||
|
||
call ale#test#SetFilename(b:root . '/src/app.erl') | ||
AssertLinter 'elvis', | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(ale#path#Simplify('src/app.erl')) | ||
AssertLinterCwd ale#test#GetFilename(b:root) | ||
|
||
Execute(Root of Rebar3 project should be detected): | ||
let b:root = '../test-files/erlang/rebar3_app' | ||
|
||
call ale#test#SetFilename(b:root . '/src/app.erl') | ||
AssertLinter 'elvis', | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(ale#path#Simplify('src/app.erl')) | ||
AssertLinterCwd ale#test#GetFilename(b:root) | ||
|
||
call ale#test#SetFilename(b:root . '/_checkouts/dep/src/dep.erl') | ||
AssertLinter 'elvis', | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(ale#path#Simplify('src/dep.erl')) | ||
AssertLinterCwd ale#test#GetFilename(b:root . '/_checkouts/dep') | ||
|
||
Execute(Root of Erlang.mk project should be detected): | ||
let b:root = '../test-files/erlang/erlang_mk_app' | ||
|
||
call ale#test#SetFilename(b:root . '/src/app.erl') | ||
AssertLinter 'elvis', | ||
\ ale#Escape('elvis') . ' rock --output-format=parsable ' | ||
\ . ale#Escape(ale#path#Simplify('src/app.erl')) | ||
AssertLinterCwd ale#test#GetFilename(b:root) |
Empty file.