aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-10-21 12:01:26 -0700
committerKenny Root <kenny@the-b.org>2015-10-21 12:01:26 -0700
commit3d9dedb3479875db2bb2b46b09ed413bab8f35cf (patch)
tree920b675e7914fb44795f4129af9fab3d8e4043fa
parent5d72d76cedba826185b82704cc3011137f6067f7 (diff)
parent5d0a7919825c7ae01f29050b059559aad5ad6d46 (diff)
downloadconnectbot-3d9dedb3479875db2bb2b46b09ed413bab8f35cf.tar.gz
connectbot-3d9dedb3479875db2bb2b46b09ed413bab8f35cf.tar.bz2
connectbot-3d9dedb3479875db2bb2b46b09ed413bab8f35cf.zip
Merge pull request #309 from kruton/lint-xqilla
Better lint output for Travis-CI
-rw-r--r--.travis.yml4
-rwxr-xr-xscripts/check-lint-count.bash57
-rwxr-xr-xscripts/check-lint-count.sh57
3 files changed, 59 insertions, 59 deletions
diff --git a/.travis.yml b/.travis.yml
index c3ea0d5..ef9e16c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,7 +25,7 @@ addons:
- ia32-libs-multiarch
- libgd2-xpm
- p7zip-full
- - libxml2-utils # ./scripts/check-lint-count.sh
+ - xqilla # ./scripts/check-lint-count.bash
coverity_scan:
project:
name: "connectbot/connectbot"
@@ -55,6 +55,6 @@ android:
script:
- ./gradlew clean build check jacocoUnitTestDebugReport
- - ./scripts/check-lint-count.sh app/build/outputs/lint-results.xml $HOME/.cache/lint/lint-results.xml
+ - ./scripts/check-lint-count.bash app/build/outputs/lint-results.xml $HOME/.cache/lint/lint-results.xml
after_success: ./gradlew coveralls
diff --git a/scripts/check-lint-count.bash b/scripts/check-lint-count.bash
new file mode 100755
index 0000000..c02f70e
--- /dev/null
+++ b/scripts/check-lint-count.bash
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+#
+# Checks the number of lint issues against historical values. Used in
+# Travis CI builds to fail when the number increases by exploiting the
+# caching mechanism.
+
+if [[ $# != 2 || ! -f $1 ]]; then \
+ echo "Usage: $0 <lint.xml file> <historical.xml file>"
+ exit 1
+fi
+
+lint_file="$1"
+historical_file="$2"
+
+xqilla="$(which xqilla)"
+
+if [[ ! -x $xqilla ]]; then \
+ echo "Error: cannot find xqilla"
+ exit 1
+fi
+
+if [[ ! -f $historical_file ]]; then \
+ # no cache history, store this one and exit
+ cp "$lint_file" "$historical_file"
+ exit 0
+fi
+
+tmp_dir="$(mktemp -d lint.XXXXXXXX)"
+trap 'rm -rf $tmp_dir' ERR EXIT
+
+lint_results="$tmp_dir/lint.txt"
+hist_results="$tmp_dir/hist.txt"
+
+run_query() {
+ local xqilla_script='string-join(//issue/location/(concat("file=", @file, " line=", @line, " column=", @column, " reason=", ../@summary)), "&#10;")'
+ xqilla -i "$1" <(echo "$xqilla_script") | sed "s,$PWD/,,g" > "$2"
+}
+
+run_query "$lint_file" "$lint_results"
+run_query "$historical_file" "$hist_results"
+
+old_count=$(wc -l < "$hist_results")
+new_count=$(wc -l < "$lint_results")
+
+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 -u "$hist_results" "$lint_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!
+ cp "$lint_file" "$historical_file"
+fi
diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh
deleted file mode 100755
index 5184e13..0000000
--- a/scripts/check-lint-count.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env bash
-#
-# Checks the number of lint issues against historical values. Used in
-# Travis CI builds to fail when the number increases by exploiting the
-# caching mechanism.
-
-if [[ $# != 2 || ! -f $1 ]]; then \
- echo "Usage: $0 <lint.xml file> <historical.xml file>"
- exit 1
-fi
-
-lint_file="$1"
-historical_file="$2"
-
-xmllint="$(which xmllint)"
-
-if [[ ! -x $xmllint ]]; then \
- echo "Error: cannot find xmllint"
- exit 1
-fi
-
-if [[ ! -f $historical_file ]]; then \
- # no cache history, store this one and exit
- cp $lint_file $historical_file
- exit 0
-fi
-
-tmp_dir="$(mktemp -d lint.XXXXXXXX)"
-trap "rm -rf $tmp_dir" ERR EXIT
-
-lint_results="$tmp_dir/lint.txt"
-hist_results="$tmp_dir/hist.txt"
-
-echo "cat //issue/location" | \
- xmllint --shell $historical_file | \
- grep '<location' >$lint_results
-
-echo "cat //issue/location" | \
- xmllint --shell $lint_file | \
- grep '<location' >$hist_results
-
-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_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!
- cp $lint_file $historical_file
-fi