blob: 212f34d334064354776d9f48c554a6638e24f880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
" Author: januswel, w0rp
Before:
Save g:ale_textlint_executable
Save g:ale_textlint_use_global
Save g:ale_textlint_options
unlet! g:ale_textlint_executable
unlet! b:ale_textlint_executable
unlet! g:ale_textlint_use_global
unlet! b:ale_textlint_use_global
unlet! g:ale_textlint_options
unlet! b:ale_textlint_options
runtime autoload/ale/handlers/textlint.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
Restore
unlet! b:command_tail
unlet! b:ale_textlint_executable
unlet! b:ale_textlint_use_global
unlet! b:ale_textlint_options
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The executable should be configurable):
AssertEqual 'textlint', ale#handlers#textlint#GetExecutable(bufnr(''))
let b:ale_textlint_executable = 'foobar'
AssertEqual 'foobar', ale#handlers#textlint#GetExecutable(bufnr(''))
Execute(The executable should be used in the command):
AssertEqual
\ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
let b:ale_textlint_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
\
Execute(The options should be configurable):
let b:ale_textlint_options = '--something'
AssertEqual
\ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
Execute(The local executable from .bin should be used if available):
call ale#test#SetFilename('textlint_paths/with_bin_path/foo.txt')
AssertEqual
\ ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'),
\ ale#handlers#textlint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'))
\ . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
Execute(The local executable from textlint/bin should be used if available):
call ale#test#SetFilename('textlint_paths/with_textlint_bin_path/foo.txt')
AssertEqual
\ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
\ ale#handlers#textlint#GetExecutable(bufnr(''))
if has('win32')
AssertEqual
\ ale#Escape('node.exe') . ' ' . ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
\ . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
else
AssertEqual
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
\ . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#textlint#GetCommand(bufnr(''))
endif
|