Merge remote-tracking branch 'origin/master' into fix-swipl

* origin/master:
  Add tests for maven.vim file
  Fix grammatical error in doc
  Add maven helper file; use maven wrapper if available instead of global 'mvn' executable
  fix lint, fix variable semantics and update tests
  bibclean: update matchlist reges for bibclean > v2.11.4
  Update rubocop_auto_correct_all tag
This commit is contained in:
D. Ben Knoble
2020-10-08 11:55:39 -04:00
16 changed files with 238 additions and 11 deletions

View File

@@ -4,7 +4,7 @@ Before:
After:
call ale#linter#Reset()
Execute(The bibclean handler should parse lines correctly):
Execute(The bibclean handler should parse lines from bibclean <= v2.11.4 correctly):
AssertEqual
\ [
@@ -19,6 +19,12 @@ Execute(The bibclean handler should parse lines correctly):
\ 'type': 'E',
\ 'text': 'Expected comma after last field ``keywords''''.',
\ 'col': ' 1'
\ },
\ {
\ 'lnum': '176',
\ 'type': 'W',
\ 'text': 'Unexpected DOI in URL value ``"https://doi.org/DOI"'''': move to separate DOI = "..." key/value in this entry.',
\ 'col': '14'
\ }
\ ],
\ ale_linters#bib#bibclean#Handle(255, [
@@ -31,5 +37,52 @@ Execute(The bibclean handler should parse lines correctly):
\ "?? File positions: input [main.bib] output [stdout]",
\ "?? Entry input byte=2145 line=63 column= 1 output byte=2146 line=63 column= 0",
\ "?? Value input byte=2528 line=71 column= 2 output byte=2527 line=70 column=49",
\ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50"
\ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50",
\ "%% \"stdin\", line 176: Unexpected DOI in URL value ``\"https://doi.org/DOI\"'': move to separate DOI = \"...\" key/value in this entry.",
\ "%% File positions: input [stdin] output [stdout]",
\ "%% Entry input byte=6813 line=174 column= 1 output byte=8543 line=227 column= 0",
\ "%% Value input byte=6890 line=176 column=14 output byte=8641 line=229 column=17",
\ "%% Current input byte=6938 line=176 column=62 output byte=8641 line=229 column=17"
\ ])
Execute(The bibclean handler should parse lines of bibclean > v2.11.4 correctly):
AssertEqual
\ [
\ {
\ 'lnum': '60',
\ 'type': 'W',
\ 'text': 'Unexpected value in ``month = "09"''''.',
\ 'col': '17'
\ },
\ {
\ 'lnum': '63',
\ 'type': 'E',
\ 'text': 'Expected comma after last field ``keywords''''.',
\ 'col': ' 1'
\ },
\ {
\ 'lnum': '176',
\ 'type': 'W',
\ 'text': 'Unexpected DOI in URL value ``"https://doi.org/DOI"'''': move to separate DOI = "..." key/value in this entry.',
\ 'col': '14'
\ }
\ ],
\ ale_linters#bib#bibclean#Handle(255, [
\ "%% stdin:60:Unexpected value in ``month = \"09\"''.",
\ "%% File positions: input [main.bib] output [stdout]",
\ "%% Entry input byte=1681 line=50 column= 1 output byte=1680 line=50 column= 0",
\ "%% Value input byte=2137 line=60 column=17 output byte=2137 line=60 column=17",
\ "%% Current input byte=2139 line=60 column=19 output byte=2137 line=60 column=17",
\ "?? stdin:71:Expected comma after last field ``keywords''.",
\ "?? File positions: input [main.bib] output [stdout]",
\ "?? Entry input byte=2145 line=63 column= 1 output byte=2146 line=63 column= 0",
\ "?? Value input byte=2528 line=71 column= 2 output byte=2527 line=70 column=49",
\ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50",
\ "%% stdin:176:Unexpected DOI in URL value ``\"https://doi.org/DOI\"'': move to separate DOI = \"...\" key/value in this entry.",
\ "%% File positions: input [stdin] output [stdout]",
\ "%% Entry input byte=6813 line=174 column= 1 output byte=8543 line=227 column= 0",
\ "%% Value input byte=6890 line=176 column=14 output byte=8641 line=229 column=17",
\ "%% Current input byte=6938 line=176 column=62 output byte=8641 line=229 column=17"
\ ])

View File

View File

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

0
test/maven-test-files/mvn Executable file
View File

View File

@@ -0,0 +1,48 @@
Before:
Save $PATH
Save $PATHEXT
let $PATHEXT = '.'
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/java/javac.vim
let g:expected_wrapper = ''
if has('unix')
let g:expected_wrapper = 'mvnw'
else
let g:expected_wrapper = 'mvnw.cmd'
endif
After:
Restore
unlet! g:expected_wrapper
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(Should use 'mvnw' in classpath command if available):
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
AssertEqual
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'))
\ . ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper)
\ . ' dependency:build-classpath',
\ ale#maven#BuildClasspathCommand(bufnr(''))
Execute(Should use 'mvn' in classpath command if it is executable and 'mvnw' is unavailable):
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
let $PATH .= (has('win32') ? ';' : ':')
\ . ale#path#Simplify(g:dir . '/maven-test-files')
AssertEqual
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'))
\ . 'mvn dependency:build-classpath',
\ ale#maven#BuildClasspathCommand(bufnr(''))
Execute(Should return empty string if maven cannot be executed):
call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java')
AssertEqual
\ '',
\ ale#maven#BuildClasspathCommand(bufnr(''))

View File

@@ -0,0 +1,46 @@
Before:
Save $PATH
Save $PATHEXT
" Count the maven executable without .exe as executable on Windows
let $PATHEXT = '.'
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/java/javac.vim
let g:expected_wrapper = ''
if has('unix')
let g:expected_wrapper = 'mvnw'
else
let g:expected_wrapper = 'mvnw.cmd'
endif
After:
Restore
unlet! g:expected_wrapper
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(Should return 'mvnw' if found in parent directory):
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
AssertEqual
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper),
\ ale#maven#FindExecutable(bufnr(''))
Execute(Should return 'mvn' if 'mvnw' not found in parent directory):
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
let $PATH .= (has('win32') ? ';' : ':')
\ . ale#path#Simplify(g:dir . '/maven-test-files')
AssertEqual
\ 'mvn',
\ ale#maven#FindExecutable(bufnr(''))
Execute(Should return empty string if 'mvnw' not in parent directory and mvn not in path):
call ale#test#SetFilename('mvn-test-files/java-maven-project/module2/src/main/java/dummy2.java')
AssertEqual
\ '',
\ ale#gradle#FindExecutable(bufnr(''))

View File

@@ -0,0 +1,28 @@
Before:
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/kotlin/javac.vim
After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(Should return directory for 'mvnw' if found in parent directory):
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
AssertEqual
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'),
\ ale#maven#FindProjectRoot(bufnr(''))
Execute(Should return directory for 'pom.xml' if found in parent directory):
call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java')
AssertEqual
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'),
\ ale#maven#FindProjectRoot(bufnr(''))
Execute(Should return empty string if maven files are not found in parent directory):
call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java')
AssertEqual
\ '',
\ ale#maven#FindProjectRoot(bufnr(''))