mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 20:07:02 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
1.6 KiB
Bash
Executable File
42 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ============================================================================
|
|
# Run only the tests related to files changed vs HEAD (staged, unstaged and
|
|
# untracked). Quiet: failures plus a one-line summary. Falls back to the full
|
|
# suite when a change cannot be mapped to tests. Generated by repo_contract.
|
|
# ============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
CHANGED=()
|
|
while IFS= read -r f; do
|
|
[[ -n "$f" && -e "$f" ]] && CHANGED+=("$f")
|
|
done < <({ git diff --name-only HEAD 2>/dev/null || true; git ls-files --others --exclude-standard; } | sort -u)
|
|
|
|
full=0
|
|
tests=()
|
|
for f in "${CHANGED[@]}"; do
|
|
case "$f" in
|
|
pubspec.yaml | pubspec.lock | test/flutter_test_config.dart) full=1 ;;
|
|
test/*_test.dart) tests+=("$f") ;;
|
|
lib/*.dart)
|
|
rel="${f#lib/}"
|
|
if [[ -f "test/${rel%.dart}_test.dart" ]]; then
|
|
tests+=("test/${rel%.dart}_test.dart")
|
|
else
|
|
while IFS= read -r t; do tests+=("$t"); done \
|
|
< <(git ls-files "test/*$(basename "${f%.dart}")_test.dart")
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ $full -eq 0 && ${#CHANGED[@]} -eq 0 ]]; then echo "no changes vs HEAD: nothing to test"; exit 0; fi
|
|
if [[ $full -eq 0 && ${#tests[@]} -gt 0 ]]; then flutter test --reporter=compact "${tests[@]}"; exit $?; fi
|
|
if [[ $full -eq 0 ]] && ! printf '%s\n' "${CHANGED[@]}" | grep -q '\.dart$'; then
|
|
echo "no dart changes: nothing to test"; exit 0
|
|
fi
|
|
echo "no mapped tests: running full suite"
|
|
flutter test --reporter=compact
|