Random script that I use regularly, thought someone else might find it usefull. This script simply takes a filename within Echo or Flow and runs the related tests. I bind this script to ^k in my editor to run the tests associated with whatever file I'm currently editing.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.Nothing elegant but useful:#!/bin/bashIDENTITY=~/.vagrant.d/insecure_private_keySOURCE=$(realpath "./$1")# If this is not from a tests/phpunit dir, adjust so it isif [ $(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 FlowSOURCE=$(echo $SOURCE | sed 's/mediawiki\/extensions\/\([^\/]\+\)\(\/includes\)\?/mediawiki\/extensions\/\1\/tests\/phpunit/' )# Add Test just before .php extensionSOURCE=${SOURCE/\.php/Test.php}fi# If the resulting source is a file or a directory, run it with phpunitif [ -f $SOURCE -o -d $SOURCE ]; thenREMOTE=$(sed 's/^.*mediawiki/\/vagrant\/mediawiki/' <<< "$(realpath "$SOURCE")")echo "Running test at $REMOTE"echoexec 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";elseecho No test found!fi
_______________________________________________
EE mailing list
EE@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/ee