From c220c61dbd2073bc9492b315a568b9adbbec48e0 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Thu, 28 Apr 2016 13:03:16 +0530 Subject: [PATCH] tools/check-py3: Speed up and add --find-fixers. Now tools/check-py3 will by default run all fixers together. This is quicker but doesn't indicate which fixers caused the failure. The newly added option --find-fixers falls back to the old way of checking each fixer separately if the quick check fails. Fixes #710. --- tools/check-py3 | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tools/check-py3 b/tools/check-py3 index 8136f4ca7e..d810fe0d57 100755 --- a/tools/check-py3 +++ b/tools/check-py3 @@ -59,17 +59,39 @@ if [ -z "$python_files" ]; then exit 0 fi -failed=0 +quick=1 +if [ "$1" == "--find-fixers" ]; then + quick=0 +fi + +fixer_options="" for fixer in $fixers; do - echo "Running Python 3 compatibility test $fixer" - echo "$python_files" | xargs futurize -f $fixer -j4 -n -w >/dev/null 2>/dev/null - if ! git diff --exit-code; then - # Clear the output from this one - git reset --hard >/dev/null - failed=1 - fi + fixer_options+="-f $fixer " done +failed=0 +# run quick check +echo "Running quick Python 3 compatibility test" +echo "$python_files" | xargs futurize $fixer_options -j4 -n -w >/dev/null 2>/dev/null +if ! git diff --exit-code; then + # Clear the output from this one + git reset --hard >/dev/null + failed=1 +fi + +# run slow check +if [ "$failed" = "1" -a "$quick" == "0" ]; then + echo "Running each fixer separately to find out which fixers need to be applied" + for fixer in $fixers; do + echo "Running Python 3 compatibility test $fixer" + echo "$python_files" | xargs futurize -f $fixer -j4 -n -w >/dev/null 2>/dev/null + if ! git diff --exit-code; then + # Clear the output from this one + git reset --hard >/dev/null + fi + done +fi + # The dict fixer tries to add list() even in for loops over an # iterator where it's just counterproductive. To address this, we run # the fixer but check for lines which don't include code that works