Created
August 2, 2017 20:28
-
-
Save w0rp/a8d8b50e0d1a0bdaf4b1978aeb1fa4da to your computer and use it in GitHub Desktop.
Create Vader tests for ALE linters callbacks quickly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# A script for quickly creating Vader tests for ALE linter callbacks. | |
# Generate boilerplate for variables. | |
variables=() | |
while read -r; do | |
variables+=("ale_$REPLY") | |
done < <(grep 'ale#Set' "$1" | grep -o '[a-z]\+_[a-z_]\+') | |
echo 'Before:' | |
for var in "${variables[@]}"; do | |
echo " Save $var" | |
done | |
echo | |
for var in "${variables[@]}"; do | |
echo " unlet! $var" | |
done | |
# Add junk for loading the linter Vim script and resetting the linters. | |
echo | |
echo " runtime $1" | |
echo | |
echo 'After:' | |
echo ' Restore' | |
echo | |
echo ' call ale#linter#Reset()' | |
# Add some blank Execute blocks with some assertions for each function. | |
function_names=() | |
while read -r; do | |
function_names+=("$REPLY") | |
done < <(grep '^function!' "$1" | grep -o 'ale_linters[#a-zA-Z_]\+') | |
for name in "${function_names[@]}"; do | |
echo | |
echo "Execute(Test $name):" | |
echo " AssertEqual [], $name(bufnr(''))" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment