Skip to content

Instantly share code, notes, and snippets.

@w0rp
Created August 2, 2017 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w0rp/a8d8b50e0d1a0bdaf4b1978aeb1fa4da to your computer and use it in GitHub Desktop.
Save w0rp/a8d8b50e0d1a0bdaf4b1978aeb1fa4da to your computer and use it in GitHub Desktop.
Create Vader tests for ALE linters callbacks quickly
#!/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