summaryrefslogtreecommitdiff
path: root/test/test_filename_mapping.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-23 19:55:42 +0100
committerw0rp <devw0rp@gmail.com>2020-08-23 19:55:42 +0100
commitba3dd0d02735e7b23918200ae58410b0deed2f62 (patch)
tree83012a41e42d746629fbf07293a1b3e7b7ed0fe6 /test/test_filename_mapping.vader
parent2b785688ead505dcbc1007374d3dca9914aa247a (diff)
downloadale-ba3dd0d02735e7b23918200ae58410b0deed2f62.zip
Close #2556 - Support filename mapping
ALE now supports mapping files between different systems for running linters and fixers with Docker, in virtual machines, in servers, etc.
Diffstat (limited to 'test/test_filename_mapping.vader')
-rw-r--r--test/test_filename_mapping.vader62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/test_filename_mapping.vader b/test/test_filename_mapping.vader
new file mode 100644
index 00000000..5b6e4f12
--- /dev/null
+++ b/test/test_filename_mapping.vader
@@ -0,0 +1,62 @@
+Before:
+ Save g:ale_filename_mappings
+ Save b:ale_filename_mappings
+
+ let g:ale_filename_mappings = {}
+ unlet! b:ale_filename_mappings
+
+After:
+ Restore
+
+Execute(ale#GetFilenameMappings should return the correct mappings for given linters/fixers):
+ let g:ale_filename_mappings = {'a': [['foo', 'bar']], 'b': [['baz', 'foo']]}
+
+ AssertEqual [['foo', 'bar']], ale#GetFilenameMappings(bufnr(''), 'a')
+ AssertEqual [['baz', 'foo']], ale#GetFilenameMappings(bufnr(''), 'b')
+ AssertEqual [], ale#GetFilenameMappings(bufnr(''), 'c')
+
+ let b:ale_filename_mappings = {'b': [['abc', 'xyz']]}
+
+ AssertEqual [], ale#GetFilenameMappings(bufnr(''), 'a')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), 'b')
+ AssertEqual [], ale#GetFilenameMappings(bufnr(''), 'c')
+
+Execute(ale#GetFilenameMappings should return Lists set for use with all tools):
+ let g:ale_filename_mappings = [['foo', 'bar']]
+
+ AssertEqual [['foo', 'bar']], ale#GetFilenameMappings(bufnr(''), 'a')
+ AssertEqual [['foo', 'bar']], ale#GetFilenameMappings(bufnr(''), '')
+ AssertEqual [['foo', 'bar']], ale#GetFilenameMappings(bufnr(''), v:null)
+
+ let b:ale_filename_mappings = [['abc', 'xyz']]
+
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), 'a')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), '')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), v:null)
+
+Execute(ale#GetFilenameMappings should let you use * as a fallback):
+ let g:ale_filename_mappings = {'a': [['foo', 'bar']], '*': [['abc', 'xyz']]}
+
+ AssertEqual [['foo', 'bar']], ale#GetFilenameMappings(bufnr(''), 'a')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), 'b')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), '')
+ AssertEqual [['abc', 'xyz']], ale#GetFilenameMappings(bufnr(''), v:null)
+
+Execute(ale#filename_mapping#Invert should invert filename mappings):
+ AssertEqual
+ \ [['b', 'a'], ['y', 'x']],
+ \ ale#filename_mapping#Invert([['a', 'b'], ['x', 'y']])
+ \
+Execute(ale#filename_mapping#Map return the filename as-is if there are no mappings):
+ AssertEqual
+ \ '/foo//bar',
+ \ ale#filename_mapping#Map('/foo//bar', [['/bar', '/data/']])
+
+Execute(ale#filename_mapping#Map should map filenames):
+ AssertEqual
+ \ '/data/bar',
+ \ ale#filename_mapping#Map('/foo//bar', [
+ \ ['/data', '/baz'],
+ \ ['/foo', '/data'],
+ \ ['/foo', '/xyz'],
+ \ ])