From ca596e839233a5712cefbab12609b3a6386e54c7 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Sep 2015 19:52:59 +0200 Subject: Update check-lint-count.sh --- scripts/check-lint-count.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index a029edb..866829b 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -19,29 +19,37 @@ if [[ ! -x $xmllint ]]; then \ exit 1 fi -if [[ ! -f $2 ]]; then \ +if [[ ! -f $historical_file ]]; then \ # no cache history, store this one and exit - cp $1 $2 + cp $lint_file $historical_file exit 0 fi -echo "cat //issue/location" | xmllint --shell $historical_file | grep '/tmp/hist.$$ -echo "cat //issue/location" | xmllint --shell $lint_file | grep '/tmp/lint.$$ +tmp_dir="$(mktemp -d lint.XXXXXXXX)" +trap "rm -rf $tmp_dir" EXIT ERROR -old_count=$(cat /tmp/hist.$$ | wc -l) -new_count=$(cat /tmp/lint.$$ | wc -l) +lint_file="$tmp_dir/lint.txt" +hist_file="$tmp_dir/hist.txt" + +echo "cat //issue/location" | \ + xmllint --shell $historical_file | \ + grep '$lint_file + +echo "cat //issue/location" | \ + xmllint --shell $lint_file | \ + grep '$hist_file + +old_count=$(cat $lint_file | wc -l) +new_count=$(cat $hist_file | wc -l) echo "Historical count : $old_count, new count : $new_count" if [[ $new_count > $old_count ]]; then \ echo "FAILURE: lint issues increased from $old_count to $new_count" - diff /tmp/lint.$$ /tmp/hist.$$ - rm -f /tmp/lint.$$ /tmp/hist.$$ + diff $lint_file $hist_file exit 2 fi -rm -f /tmp/lint.$$ /tmp/hist.$$ - if [[ $TRAVIS_PULL_REQUEST == false ]]; then \ # Okay, we either stayed the same or reduced our number. # Write it out so we can check it next build! -- cgit v1.2.3