summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authorGordon Fontenot <gmoney@gitpushgitpaid.com>2017-08-09 12:26:38 -0500
committerGordon Fontenot <gmoney@gitpushgitpaid.com>2017-08-09 12:41:21 -0500
commit4709e676275000f01975aa433f702e825d6a2353 (patch)
tree3a990b604fbc46eebf403ff6d613fecd2507e1e3 /test/fixers
parent2b546a50dc8a07e4ca7bb554eb3db7e405eb8c9f (diff)
downloadale-4709e676275000f01975aa433f702e825d6a2353.zip
Add support for SwiftFormat as a fixer
SwiftFormat is a tool that can be used to format Swift files. This commit adds support for using SwiftFormat as a fixer from ALE. It looks for executables in the Pods directory, then the Pods directory for a React Native project, then finally falls back to the globally installed instance if neither of those were found. https://github.com/nicklockwood/SwiftFormat
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_swiftformat_fixer_callback.vader38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/fixers/test_swiftformat_fixer_callback.vader b/test/fixers/test_swiftformat_fixer_callback.vader
new file mode 100644
index 00000000..e3674ded
--- /dev/null
+++ b/test/fixers/test_swiftformat_fixer_callback.vader
@@ -0,0 +1,38 @@
+Before:
+ Save g:ale_swift_swiftformat_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_swift_swiftformat_executable = 'xxxinvalid'
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The swiftformat callback should return the correct default values):
+ call ale#test#SetFilename('swift_paths/dummy.swift')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_swift_swiftformat_executable)
+ \ . ' %t ',
+ \ },
+ \ ale#fixers#swiftformat#Fix(bufnr(''))
+
+Execute(The swiftformat callback should include any additional options):
+ call ale#test#SetFilename('swift_paths/dummy.swift')
+ let g:ale_swift_swiftformat_options = '--some-option'
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_swift_swiftformat_executable)
+ \ . ' %t --some-option',
+ \ },
+ \ ale#fixers#swiftformat#Fix(bufnr(''))