From e41e312abf1750fefd43546a0c173f779272d5f2 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 8 Oct 2023 12:33:47 +0200 Subject: [PATCH] test: add check to verify the completeness of convert_async_to_sync Verify that all the files commented as having been automatically converted are actually included in the script converting them. --- tools/convert_async_to_sync.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/convert_async_to_sync.sh b/tools/convert_async_to_sync.sh index 5932dd7cb..76a6e4b06 100755 --- a/tools/convert_async_to_sync.sh +++ b/tools/convert_async_to_sync.sh @@ -73,4 +73,24 @@ if [[ $check ]]; then if ! git diff --exit-code $outputs; then error "sync and async files... out of sync!" fi + + # Verify that all the transformed files are included in this script + # Note: the 'cd' early in the script ensures that cwd is the project root. + checked=0 + errors=0 + for fn in $(find psycopg psycopg_pool tests -type f -name \*.py); do + # Skip files ignored by git (build artifacts) + ! git status --porcelain --ignored "${fn}" | grep -q '!!' || continue + # Skip non-auto-generated files + grep -q "auto-generated by 'async_to_sync.py'" "${fn}" || continue + + checked=$(( $checked + 1 )) + afn=${fn/.py/_async.py} + if ! grep -q $afn tools/$(basename $0); then + errors=$(( $errors + 1 )) + log "file '${fn}' seems converted but not included in '$(basename $0)'" + fi + done + [[ $checked -gt 0 ]] || error "No file found to check. Script bitrot?" + [[ $errors -eq 0 ]] || error "Some files are not included in async-to-sync conversion." fi -- 2.47.3