Skip to content

Instantly share code, notes, and snippets.

@fahmilatib
Created December 31, 2020 22:26
Show Gist options
  • Save fahmilatib/764b79d31f7c1904619ffd244d333193 to your computer and use it in GitHub Desktop.
Save fahmilatib/764b79d31f7c1904619ffd244d333193 to your computer and use it in GitHub Desktop.
phpunit runner
#!/bin/bash
executed_files=()
if [[ "$1" == '--all' ]]; then
file_param=$2
output_all=true
else
file_param=$1
fi
for file in $(cat "$file_param"); do
if ! [[ $file == tests/* ]]; then
# skip if not a test file
continue
fi
if [[ " ${executed_files[@]} " =~ " $file " ]]; then
# skip if same file has been run before
continue
fi
output=$(./vendor/bin/phpunit --testdox --color=always "$file")
if [[ $output_all ]]; then
output=$(grep -F -e '[ ]' -e '[x]' <<< "$output")
else
output=$(grep -F -e '[ ]' <<< "$output")
fi
if [[ $output == '' ]]; then
continue
fi
echo
echo "$file"
echo
echo "$output"
executed_files+=("$file")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment