summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHenrique Barcelos <hbarcelos@users.noreply.github.com>2021-04-14 21:01:18 -0300
committerGitHub <noreply@github.com>2021-04-15 09:01:18 +0900
commit1c90d8c01875f5abb815fea29eb4545bd9a940c0 (patch)
tree3d0ad474315bf910af5b3da43aa90467f57a77b6 /test
parent1cd0c0c33b211b5fface9b29f9c58bc6ae09323e (diff)
downloadale-1c90d8c01875f5abb815fea29eb4545bd9a940c0.zip
Updated `solhint` linter to be able to use a local installation (#3682)
* fix: added support for local solhint executable * feat: added support for matching parse errors * test: added test for solhint command callback and handler * chore: removed command callback test * refactor: made solhint handler structure closer to eslint
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_solhint_handler.vader28
-rw-r--r--test/linter/test_solhint.vader28
-rw-r--r--test/test-files/solhint/Contract.sol0
-rw-r--r--test/test-files/solhint/node_modules/.bin/solhint0
-rw-r--r--test/test-files/solhint/node_modules/solhint/index.js0
-rw-r--r--test/test-files/solhint/package.json0
6 files changed, 54 insertions, 2 deletions
diff --git a/test/handler/test_solhint_handler.vader b/test/handler/test_solhint_handler.vader
index a3ed5d57..f8fffb60 100644
--- a/test/handler/test_solhint_handler.vader
+++ b/test/handler/test_solhint_handler.vader
@@ -4,7 +4,7 @@ Before:
After:
call ale#linter#Reset()
-Execute(The vint handler should parse error messages correctly):
+Execute(The solhint handler should parse linter error messages correctly):
AssertEqual
\ [
\ {
@@ -50,7 +50,7 @@ Execute(The vint handler should parse error messages correctly):
\ 'type': 'E',
\ },
\ ],
- \ ale_linters#solidity#solhint#Handle(bufnr(''), [
+ \ ale#handlers#solhint#Handle(bufnr(''), [
\ 'contracts/Bounty.sol: line 1, col 17, Warning - Compiler version must be fixed (compiler-fixed)',
\ 'contracts/Bounty.sol: line 4, col 8, Error - Use double quotes for string literals (quotes)',
\ 'contracts/Bounty.sol: line 5, col 8, Error - Use double quotes for string literals (quotes)',
@@ -58,3 +58,27 @@ Execute(The vint handler should parse error messages correctly):
\ 'contracts/Bounty.sol: line 14, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
\ 'contracts/Bounty.sol: line 47, col 3, Error - Function order is incorrect, public function can not go after internal function. (func-order)',
\ ])
+
+
+Execute(The solhint handler should parse syntax error messages correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 30,
+ \ 'col': 4,
+ \ 'text': "missing ';' at 'uint248'",
+ \ 'code': 'Parse error',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 203,
+ \ 'col': 4,
+ \ 'text': "no viable alternative at input '_loserStakeMultiplier}'",
+ \ 'code': 'Parse error',
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale#handlers#solhint#Handle(bufnr(''), [
+ \ "contracts/Bounty.sol: line 30, col 4, Error - Parse error: missing ';' at 'uint248'",
+ \ "contracts/Bounty.sol: line 203, col 4, Error - Parse error: no viable alternative at input '_loserStakeMultiplier}'",
+ \ ])
diff --git a/test/linter/test_solhint.vader b/test/linter/test_solhint.vader
new file mode 100644
index 00000000..fc5afa9b
--- /dev/null
+++ b/test/linter/test_solhint.vader
@@ -0,0 +1,28 @@
+Before:
+ call ale#assert#SetUpLinterTest('solidity', 'solhint')
+ runtime autoload/ale/handlers/solhint.vim
+
+ let b:args = ' --formatter compact %s'
+
+After:
+ unlet! b:args
+ unlet! b:executable
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinterCwd ''
+ AssertLinter 'solhint', ale#Escape('solhint') . b:args
+
+Execute(The options should be configurable):
+ let g:ale_solidity_solhint_options = '--foobar'
+
+ AssertLinter 'solhint', ale#Escape('solhint') . ' --foobar' . b:args
+
+
+Execute(solhint should be run from a containing project with solhint executable):
+ call ale#test#SetFilename('../test-files/solhint/Contract.sol')
+
+ let b:executable = ale#path#Simplify(g:dir . '/../test-files/solhint/node_modules/.bin/solhint')
+
+ AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/solhint')
+ AssertLinter b:executable, ale#Escape(b:executable) . b:args
diff --git a/test/test-files/solhint/Contract.sol b/test/test-files/solhint/Contract.sol
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/solhint/Contract.sol
diff --git a/test/test-files/solhint/node_modules/.bin/solhint b/test/test-files/solhint/node_modules/.bin/solhint
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/solhint/node_modules/.bin/solhint
diff --git a/test/test-files/solhint/node_modules/solhint/index.js b/test/test-files/solhint/node_modules/solhint/index.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/solhint/node_modules/solhint/index.js
diff --git a/test/test-files/solhint/package.json b/test/test-files/solhint/package.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/solhint/package.json