summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader1
-rw-r--r--test/command_callback/test_flake8_command_callback.vader11
-rw-r--r--test/handler/test_gcc_handler.vader11
-rw-r--r--test/test_flow_command.vader1
-rw-r--r--test/test_semver_utils.vader62
5 files changed, 57 insertions, 29 deletions
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index d808e197..10535516 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -17,6 +17,7 @@ After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
+ call ale#semver#ResetVersionCache()
Execute(An empty string should be returned for the cargo executable when there's no Cargo.toml file):
AssertEqual
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index a510f4c1..47d5c0fd 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -23,7 +23,7 @@ After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- call ale_linters#python#flake8#ClearVersionCache()
+ call ale#semver#ResetVersionCache()
Execute(The flake8 callbacks should return the correct default values):
AssertEqual
@@ -35,8 +35,9 @@ Execute(The flake8 callbacks should return the correct default values):
AssertEqual
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+
" Try with older versions.
- call ale_linters#python#flake8#ClearVersionCache()
+ call ale#semver#ResetVersionCache()
AssertEqual
\ ale#Escape('flake8') . ' --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
@@ -49,7 +50,9 @@ Execute(The flake8 command callback should let you set options):
\ . ' --some-option --format=default'
\ . ' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4'])
- call ale_linters#python#flake8#ClearVersionCache()
+
+ call ale#semver#ResetVersionCache()
+
AssertEqual
\ ale#Escape('flake8')
\ . ' --some-option --format=default -',
@@ -140,7 +143,7 @@ Execute(Using `python -m flake8` should be supported for running flake8):
\ ale#Escape('python') . ' -m flake8 --some-option --format=default -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
- call ale_linters#python#flake8#ClearVersionCache()
+ call ale#semver#ResetVersionCache()
" Leading spaces shouldn't matter
let g:ale_python_flake8_options = ' -m flake8 --some-option'
diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader
index 9324273e..79f17899 100644
--- a/test/handler/test_gcc_handler.vader
+++ b/test/handler/test_gcc_handler.vader
@@ -71,17 +71,6 @@ Execute(GCC errors from included files should be parsed correctly):
\ ' ^',
\ ])
-Execute(GCC versions should be parsed correctly):
- AssertEqual [4, 9, 1], ale#handlers#gcc#ParseGCCVersion([
- \ 'g++ (GCC) 4.9.1 20140922 (Red Hat 4.9.1-10)',
- \])
- AssertEqual [4, 8, 4], ale#handlers#gcc#ParseGCCVersion([
- \ 'gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4',
- \ 'Copyright (C) 2013 Free Software Foundation, Inc.',
- \ 'This is free software; see the source for copying conditions. There is NO',
- \ 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.',
- \])
-
Execute(The GCC handler shouldn't complain about #pragma once for headers):
silent file! test.h
diff --git a/test/test_flow_command.vader b/test/test_flow_command.vader
index 32ceb57c..49546e94 100644
--- a/test/test_flow_command.vader
+++ b/test/test_flow_command.vader
@@ -5,6 +5,7 @@ Before:
After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
+ call ale#semver#ResetVersionCache()
Execute(flow should return a command to run if a .flowconfig file exists):
call ale#test#SetFilename('flow/a/sub/dummy')
diff --git a/test/test_semver_utils.vader b/test/test_semver_utils.vader
index 9730b74b..30e9e818 100644
--- a/test/test_semver_utils.vader
+++ b/test/test_semver_utils.vader
@@ -1,16 +1,50 @@
-Execute(ParseSemver should return the correct results):
+After:
+ call ale#semver#ResetVersionCache()
+
+Execute(GetVersion should return the version from the lines of output):
" We should be able to parse the semver string from flake8
- AssertEqual [3, 0, 4], ale#semver#Parse('3.0.4 (mccabe: 0.5.2, pyflakes: 1.2.3, pycodestyle: 2.0.0) CPython 2.7.12 on Linux')
+ AssertEqual [3, 0, 4], ale#semver#GetVersion('dummy', [
+ \ '3.0.4 (mccabe: 0.5.2, pyflakes: 1.2.3, pycodestyle: 2.0.0) CPython 2.7.12 on Linux',
+ \ '1.2.3',
+ \])
+
+Execute(GetVersion should return an empty list when no vesrion can be found):
+ AssertEqual [], ale#semver#GetVersion('dummy', ['x'])
+ AssertEqual [], ale#semver#GetVersion('dummy', [])
+
+Execute(GetVersion should cache the version):
+ AssertEqual [], ale#semver#GetVersion('dummy', [])
+ AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', ['Version 3.4.7'])
+ AssertEqual [3, 4, 7], ale#semver#GetVersion('dummy', [])
+
+Execute(HasVersion should return 1 when the version has been cached):
+ call ale#semver#GetVersion('dummy', [])
+ AssertEqual 0, ale#semver#HasVersion('dummy')
+ call ale#semver#GetVersion('dummy', ['3.4.7'])
+ AssertEqual 1, ale#semver#HasVersion('dummy')
+
+Execute(GTE should compare triples correctly):
+ Assert ale#semver#GTE([3, 0, 4], [3, 0, 0])
+ Assert ale#semver#GTE([3, 0, 0], [3, 0, 0])
+ Assert ale#semver#GTE([3, 0, 0], [2, 0, 0])
+ Assert ale#semver#GTE([3, 1, 0], [3, 1, 0])
+ Assert ale#semver#GTE([3, 2, 0], [3, 1, 0])
+ Assert ale#semver#GTE([3, 2, 2], [3, 1, 6])
+ Assert ale#semver#GTE([3, 2, 5], [3, 2, 5])
+ Assert ale#semver#GTE([3, 2, 6], [3, 2, 5])
+ Assert !ale#semver#GTE([2, 9, 1], [3, 0, 0])
+ Assert !ale#semver#GTE([3, 2, 3], [3, 3, 3])
+ Assert !ale#semver#GTE([3, 3, 2], [3, 3, 3])
+
+Execute(GTE should compare pairs correctly):
+ Assert ale#semver#GTE([3, 0], [3, 0, 0])
+ Assert ale#semver#GTE([3, 0], [3, 0])
+ Assert ale#semver#GTE([3, 1], [3, 0])
+ Assert ale#semver#GTE([3, 1], [3, 0, 0])
+ Assert ale#semver#GTE([3, 0, 1], [3, 0])
+ Assert !ale#semver#GTE([3, 0], [3, 0, 1])
+ Assert !ale#semver#GTE([3, 0], [3, 1])
+ Assert !ale#semver#GTE([2, 9, 11], [3, 0])
-Execute(GreaterOrEqual should compare triples correctly):
- Assert ale#semver#GreaterOrEqual([3, 0, 4], [3, 0, 0])
- Assert ale#semver#GreaterOrEqual([3, 0, 0], [3, 0, 0])
- Assert ale#semver#GreaterOrEqual([3, 0, 0], [2, 0, 0])
- Assert ale#semver#GreaterOrEqual([3, 1, 0], [3, 1, 0])
- Assert ale#semver#GreaterOrEqual([3, 2, 0], [3, 1, 0])
- Assert ale#semver#GreaterOrEqual([3, 2, 2], [3, 1, 6])
- Assert ale#semver#GreaterOrEqual([3, 2, 5], [3, 2, 5])
- Assert ale#semver#GreaterOrEqual([3, 2, 6], [3, 2, 5])
- Assert !ale#semver#GreaterOrEqual([2, 9, 1], [3, 0, 0])
- Assert !ale#semver#GreaterOrEqual([3, 2, 3], [3, 3, 3])
- Assert !ale#semver#GreaterOrEqual([3, 3, 2], [3, 3, 3])
+Execute(GTE should permit the LHS to be an empty List):
+ Assert !ale#semver#GTE([], [0, 0, 0])