Adds function to count tab characters in files to run_test.sh.
In case you're frustrated by mixed use of tab characters and spaces for indentation, this function finds tab characters in all the Python, CSS, Javascript and HTML files in the project, and lists out any offending files that contain tabs. Returns proper exit codes in case we someday want to gate on this check. Change-Id: I70195e9d00368a5d177cd3792921028e0bcd9b53
This commit is contained in:
parent
e9b06ca773
commit
7cd53c2506
|
@ -77,6 +77,16 @@ For more detailed code analysis you can run::
|
|||
|
||||
The output will be saved in ``./pylint.txt``.
|
||||
|
||||
Tab Characters
|
||||
--------------
|
||||
|
||||
For those who dislike having a mix of tab characters and spaces for indentation
|
||||
there's a command to check for that in Python, CSS, JavaScript and HTML files::
|
||||
|
||||
./run_tests.sh --tabs
|
||||
|
||||
This will output a total "tab count" and a list of the offending files.
|
||||
|
||||
Running the development server
|
||||
==============================
|
||||
|
||||
|
|
25
run_tests.sh
25
run_tests.sh
|
@ -22,6 +22,7 @@ function usage {
|
|||
echo " environment. Useful when dependencies have"
|
||||
echo " been added."
|
||||
echo " -p, --pep8 Just run pep8"
|
||||
echo " -t, --tabs Check for tab characters in files."
|
||||
echo " -y, --pylint Just run pylint"
|
||||
echo " -q, --quiet Run non-interactively. (Relatively) quiet."
|
||||
echo " --with-selenium Run unit tests including Selenium tests"
|
||||
|
@ -57,6 +58,7 @@ dashboard_wrapper=""
|
|||
just_pep8=0
|
||||
just_pylint=0
|
||||
just_docs=0
|
||||
just_tabs=0
|
||||
runserver=0
|
||||
quiet=0
|
||||
backup_env=0
|
||||
|
@ -74,6 +76,7 @@ function process_option {
|
|||
-p|--pep8) just_pep8=1;;
|
||||
-y|--pylint) just_pylint=1;;
|
||||
-f|--force) force=1;;
|
||||
-t|--tabs) just_tabs=1;;
|
||||
-q|--quiet) quiet=1;;
|
||||
-c|--coverage) with_coverage=1;;
|
||||
--with-selenium) selenium=1;;
|
||||
|
@ -135,6 +138,22 @@ function run_sphinx {
|
|||
echo "Build complete."
|
||||
}
|
||||
|
||||
function tab_check {
|
||||
TAB_VIOLATIONS=`find horizon/horizon openstack-dashboard/dashboard -type f -regex ".*\.\(css\|js\|py\|html\)" -print0 | xargs -0 awk '/\t/' | wc -l`
|
||||
if [ $TAB_VIOLATIONS -gt 0 ]; then
|
||||
echo "TABS! $TAB_VIOLATIONS of them! Oh no!"
|
||||
HORIZON_FILES=`find horizon/horizon openstack-dashboard/dashboard -type f -regex ".*\.\(css\|js\|py|\html\)"`
|
||||
for TABBED_FILE in $HORIZON_FILES
|
||||
do
|
||||
TAB_COUNT=`awk '/\t/' $TABBED_FILE | wc -l`
|
||||
if [ $TAB_COUNT -gt 0 ]; then
|
||||
echo "$TABBED_FILE: $TAB_COUNT"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return $TAB_VIOLATIONS;
|
||||
}
|
||||
|
||||
function destroy_buildout {
|
||||
echo "Removing buildout files..."
|
||||
rm -rf horizon/bin
|
||||
|
@ -414,6 +433,12 @@ if [ $just_pylint -eq 1 ]; then
|
|||
exit $?
|
||||
fi
|
||||
|
||||
# Tab checker
|
||||
if [ $just_tabs -eq 1 ]; then
|
||||
tab_check
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Django development server
|
||||
if [ $runserver -eq 1 ]; then
|
||||
run_server
|
||||
|
|
Loading…
Reference in New Issue