From 768b28c06c5e62aec3f3ba250900617700975db4 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Sep 2015 16:54:11 +0200 Subject: Try to show new lint issues in check-lint-count.sh --- scripts/check-lint-count.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'scripts/check-lint-count.sh') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index 4848e62..bd8d05c 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -8,11 +8,8 @@ # number of lint warnings that existed. DEFAULT_NUMBER=207 -if [[ $# != 3 || ! -f $1 ]]; then \ - echo "Usage: $0 " - exit 1 -elif [[ ! -d $(dirname $3) ]]; then \ - echo "Error: directory $(dirname $3) does not exist." +if [[ $# != 2 || ! -f $1 ]]; then \ + echo "Usage: $0 " exit 1 fi @@ -27,21 +24,31 @@ if [[ ! -x $xmllint ]]; then \ exit 1 fi -if [[ -f $historical_file ]]; then \ - historical_count="$(cat $historical_file)" -else \ - historical_count=$DEFAULT_NUMBER +if [[ ! -f $2 ]]; then \ + # no cache history, store this one and exit + cp $1 $2 + exit 0 fi -new_count="$($xmllint --xpath 'count(//issue)' "$lint_file")" +echo "cat //issue/location" | xmllint --shell $historical_file | grep '/tmp/hist.$$ +echo "cat //issue/location" | xmllint --shell $lint_file | grep '/tmp/lint.$$ + +old_count=$(cat /tmp/hist.$$ | wc -l) +new_count=$(cat /tmp/lint.$$ | wc -l) -if [[ $new_count > $historical_count ]]; then \ - echo "FAILURE: lint issues increased from $historical_count to $new_count" +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.$$ 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! - echo $new_count > $success_file + mv $lint_file $historical_file fi -- cgit v1.2.3 From 6df617186401290a6204d1941685fe3a19b01807 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Sep 2015 19:16:35 +0200 Subject: Remove unused variables --- scripts/check-lint-count.sh | 5 ----- 1 file changed, 5 deletions(-) (limited to 'scripts/check-lint-count.sh') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index bd8d05c..a029edb 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -4,10 +4,6 @@ # Travis CI builds to fail when the number increases by exploiting the # caching mechanism. -# This is to prime the system: when I submitted this change, this is the -# number of lint warnings that existed. -DEFAULT_NUMBER=207 - if [[ $# != 2 || ! -f $1 ]]; then \ echo "Usage: $0 " exit 1 @@ -15,7 +11,6 @@ fi lint_file="$1" historical_file="$2" -success_file="$3" xmllint="$(which xmllint)" -- cgit v1.2.3 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/check-lint-count.sh') 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 From 5c258b35b67c48991a0b32806629bad2241a8483 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Sep 2015 20:14:50 +0200 Subject: trap signals --- scripts/check-lint-count.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/check-lint-count.sh') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index 866829b..1491f9a 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -26,7 +26,7 @@ if [[ ! -f $historical_file ]]; then \ fi tmp_dir="$(mktemp -d lint.XXXXXXXX)" -trap "rm -rf $tmp_dir" EXIT ERROR +trap "rm -rf $tmp_dir" 1 2 3 6 9 14 15 lint_file="$tmp_dir/lint.txt" hist_file="$tmp_dir/hist.txt" -- cgit v1.2.3 From dafabce039b18fe8be0d25623b59c53f17d06805 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 3 Sep 2015 20:26:07 +0200 Subject: lint_file variable used twice ! --- scripts/check-lint-count.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'scripts/check-lint-count.sh') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index 1491f9a..4d7c8f3 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -28,30 +28,30 @@ fi tmp_dir="$(mktemp -d lint.XXXXXXXX)" trap "rm -rf $tmp_dir" 1 2 3 6 9 14 15 -lint_file="$tmp_dir/lint.txt" -hist_file="$tmp_dir/hist.txt" +lint_results="$tmp_dir/lint.txt" +hist_results="$tmp_dir/hist.txt" echo "cat //issue/location" | \ xmllint --shell $historical_file | \ - grep '$lint_file + grep '$lint_results echo "cat //issue/location" | \ xmllint --shell $lint_file | \ - grep '$hist_file + grep '$hist_results -old_count=$(cat $lint_file | wc -l) -new_count=$(cat $hist_file | wc -l) +old_count=$(cat $lint_results | wc -l) +new_count=$(cat $hist_results | 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 $lint_file $hist_file + diff $lint_results $hist_results exit 2 fi 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! - mv $lint_file $historical_file + cp $lint_file $historical_file fi -- cgit v1.2.3 From 79e6ef48a6738065821d9fbc984221f399acbcb3 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 4 Sep 2015 23:19:34 +0200 Subject: trap ERR & EXIT --- scripts/check-lint-count.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/check-lint-count.sh') diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh index 4d7c8f3..5184e13 100755 --- a/scripts/check-lint-count.sh +++ b/scripts/check-lint-count.sh @@ -26,7 +26,7 @@ if [[ ! -f $historical_file ]]; then \ fi tmp_dir="$(mktemp -d lint.XXXXXXXX)" -trap "rm -rf $tmp_dir" 1 2 3 6 9 14 15 +trap "rm -rf $tmp_dir" ERR EXIT lint_results="$tmp_dir/lint.txt" hist_results="$tmp_dir/hist.txt" -- cgit v1.2.3