Thanks. I add hacks and scripts like this to the talk page of our beloved
:) process page.

https://www.mediawiki.org/wiki/Talk:Flow/Team/Processes

On Wed, Sep 24, 2014 at 10:01 PM, Erik Bernhardson <
[email protected]> wrote:

> 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/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 [email protected] -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
>
>
> _______________________________________________
> EE mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/ee
>
>


-- 
=S Page  Features engineer
_______________________________________________
EE mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/ee

Reply via email to