It takes a single cli argument, a path to a php file. It will rewrite paths like Flow/includes/Parsoid/Utils.php to Flow/tests/phpunit/Parsoid/UtilsTest.php and run it inside vagrant. If called with a file already within the tests/phpunit directories it just runs it inside vagrant.
#!/bin/bash
IDENTITY=~/.vagrant.d/insecure_private_key
SOURCE=$(realpath "./$1")
# If this is not from a tests/phpunit dir, adjust so it is
if [ $(expr "$SOURCE" : '.*\tests/phpunit') -eq 0 ]; then
# Rewrites mediawiki/extensions/{NAME}/includes to mediawiki/extensions/{NAME}/tests/phpunit
# The /includes at the end is optional to work with both Echo and Flow
SOURCE=$(echo $SOURCE | sed 's/mediawiki\/extensions\/\([^\/]\+\)\(\/includes\)\?/mediawiki\/extensions\/\1\/tests\/phpunit/' )
# Add Test just before .php extension
SOURCE=${SOURCE/\.php/Test.php}
fi
# If the resulting source is a file or a directory, run it with phpunit
if [ -f $SOURCE -o -d $SOURCE ]; then
REMOTE=$(sed 's/^.*mediawiki/\/vagrant\/mediawiki/' <<< "$(realpath "$SOURCE")")
echo "Running test at $REMOTE"
echo
exec ssh
vagrant@127.0.0.1 -t -p 2222 -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i $IDENTITY "sudo -u www-data php5 /vagrant/mediawiki/tests/phpunit/phpunit.php $REMOTE";
else
echo No test found!
fi