]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: add check to verify the completeness of convert_async_to_sync
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 8 Oct 2023 10:33:47 +0000 (12:33 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 11 Oct 2023 21:45:39 +0000 (23:45 +0200)
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

index 5932dd7cbb00679968d842a22478d63532403109..76a6e4b0696a39bdab82f59fdca89626bfc185fa 100755 (executable)
@@ -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