Created
August 2, 2012 14:08
-
-
Save jakzal/3237338 to your computer and use it in GitHub Desktop.
Running tests for each Symfony component separately
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SYMFONY_PATH="src/Symfony" | |
OUTPUT_PATH="../symfony.dev/web/coverage" | |
component=$1||'' | |
if [ -f phpunit.xml ]; then | |
echo "phpunit.xml file already exists. Remove it to continue." | |
exit 1 | |
fi | |
run_phpunit() { | |
symfony_path=$1 | |
output_path=$2 | |
component_path=$3 | |
cat phpunit.xml.dist | sed -e 's#<directory>./src/Symfony/</directory>#<directory>./'$symfony_path'/'$component_path'</directory>#' > phpunit.xml | |
phpunit --coverage-html $output_path/$component_path $symfony_path/$component_path | |
rm phpunit.xml | |
} | |
run_all() { | |
symfony_path=$1 | |
output_path=$2 | |
for namespace in $(ls $symfony_path); do | |
echo "$namespace" | |
for component in $(ls $symfony_path/$namespace); do | |
echo "$component" | |
run_phpunit $symfony_path $output_path "$namespace/$component" | |
done | |
done | |
} | |
run() { | |
symfony_path=$1 | |
output_path=$2 | |
component=$3 | |
if [ -n "$component" ]; then | |
run_phpunit $symfony_path $output_path "$component" | |
else | |
run_all $symfony_path $output_path | |
fi | |
} | |
create_index() { | |
path=$1 | |
if [ ! -d $path ]; then | |
echo "Target path not found: "$path | |
exit 1 | |
fi | |
echo "<ul>" > $path/index.html | |
for namespace in $(ls $path); do | |
if [ -d $path/$namespace ] ; then | |
echo "<li><a href="$namespace">$namespace</a></li>" >> $path/index.html | |
echo "<ul>" > $path/$namespace/index.html | |
for component in $(ls $path/$namespace); do | |
if [ -d $path/$namespace/$component ] ; then | |
echo "<li><a href="$component">$component</a></li>" >> $path/$namespace/index.html | |
fi | |
done | |
echo "</ul>" >> $path/$namespace/index.html | |
fi | |
done | |
echo "</ul>" >> $path/index.html | |
} | |
run $SYMFONY_PATH $OUTPUT_PATH $component | |
create_index $OUTPUT_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment