Skip to content

Commit

Permalink
Add CI check for unecessary template tests
Browse files Browse the repository at this point in the history
When the regression tests output differs between PG versions we create a
template test file (*.sql.in) and add several different output files for
each supported version.

Over time we support new PG version and deprecate older ones, for
example nowadays we're working on PG16 support and removed PG12 so we
need to check if we still need template files.
  • Loading branch information
fabriziomello committed Oct 13, 2023
1 parent 5752c33 commit 26d5c48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/code_style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
git diff --exit-code
misc_checks:
name: Check license, update scripts, git hooks and missing gitignore entries
name: Check license, update scripts, git hooks, missing gitignore entries and unecessary template tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand All @@ -124,3 +124,7 @@ jobs:
- name: Check for missing gitignore entries for template test files
if: always()
run: ./scripts/check_missing_gitignore_for_template_tests.sh
- name: Check for unecessary template test files
if: always()
run: ./scripts/check_unecessary_template_tests.sh

17 changes: 17 additions & 0 deletions scripts/check_unecessary_template_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

ERROR=0

for FILE in $(git ls-files test/sql/*.sql.in tsl/test/sql/*.sql.in)
do
DIRNAME=$(dirname "${FILE}" | sed 's/sql/expected/g')
TESTNAME=$(basename "${FILE}" .sql.in)

if diff --from-file ${DIRNAME}/${TESTNAME}-*.out > /dev/null 2>&1; then
echo "ERROR: all template output test files are equal: \"${DIRNAME}/${TESTNAME}-*.out\""
echo "HINT: Please turn template test file \"${FILE}\" into a regular test file"
ERROR=1
fi
done

exit ${ERROR}

0 comments on commit 26d5c48

Please sign in to comment.