summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/gradle-report13
-rwxr-xr-xtest/run-tests.sh11
2 files changed, 21 insertions, 3 deletions
diff --git a/bin/gradle-report b/bin/gradle-report
index bbee2b7..cc0de03 100755
--- a/bin/gradle-report
+++ b/bin/gradle-report
@@ -25,7 +25,11 @@ EXTRA=("$@")
case "$KIND" in
detekt) TASK=":app:detekt"; REPORT="$PROJECT_DIR/app/build/reports/detekt/detekt.xml" ;;
- lint) TASK=":app:lintDebug"; REPORT="$PROJECT_DIR/app/build/lint-results-debug.xml" ;;
+ # AGP has moved this file between versions, so locate it rather than assuming. A hardcoded
+ # path that stops resolving turns into "MISSING ... PASS", which is worse than no check.
+ lint) TASK=":app:lintDebug"
+ REPORT=$(find "$PROJECT_DIR/app/build" -name "lint-results-debug.xml" 2>/dev/null | head -1)
+ REPORT=${REPORT:-$PROJECT_DIR/app/build/reports/lint-results-debug.xml} ;;
*) die "kind must be 'detekt' or 'lint', got '$KIND'" ;;
esac
@@ -58,10 +62,13 @@ if grep -qiE "is misspelled or does not exist|configuration file is invalid|inva
fi
if [ ! -f "$REPORT" ]; then
+ # Falling back to the exit code here is how a broken path becomes a silent pass. Say that
+ # the check did not actually happen.
echo "report : MISSING ($REPORT)"
- echo "result : $([ $STATUS -eq 0 ] && echo 'PASS (no report produced, nothing to read)' || echo 'FAIL')"
+ echo "hint : the report path may have moved; this check did NOT inspect any findings"
+ echo "result : FAIL — no report to read (gradle exit $STATUS)"
rm -f "$LOG"
- exit $STATUS
+ exit 1
fi
if [ "$REPORT" -ot "$MARKER" ] && [ $ALLOW_STALE -eq 0 ]; then
diff --git a/test/run-tests.sh b/test/run-tests.sh
index 0e655d0..1c75cd7 100755
--- a/test/run-tests.sh
+++ b/test/run-tests.sh
@@ -219,6 +219,17 @@ fi
out=$("$BIN/gradle-report" "$tmproot/nope" detekt 2>&1); rc=$?
if [ $rc -eq 2 ]; then ok "missing project dir is fatal"; else bad "missing dir" "rc=$rc"; fi
+# A missing report must fail, not fall through to the exit code. A hardcoded path that stops
+# resolving would otherwise report PASS forever while inspecting nothing.
+d="$tmproot/report-noreport"
+make_project "$d" 0
+out=$("$BIN/gradle-report" "$d" detekt 2>&1); rc=$?
+if [ $rc -ne 0 ] && printf '%s' "$out" | grep -qi "did NOT inspect"; then
+ ok "a missing report fails instead of passing on exit code"
+else
+ bad "missing report" "rc=$rc out=$out"
+fi
+
printf '=== android-ui ===\n'
# 16. Usage validation without a device.