Skip to content

Improve TAP test infrastructure#329

Merged
mason-sharp merged 1 commit intomainfrom
task/improve-tap-test-infrastructure
Feb 11, 2026
Merged

Improve TAP test infrastructure#329
mason-sharp merged 1 commit intomainfrom
task/improve-tap-test-infrastructure

Conversation

@rasifr
Copy link
Member

@rasifr rasifr commented Feb 4, 2026

Makefile changes:

  • Add TESTLOGDIR variable for centralized log location
  • Parse test schedule file to run only configured tests
  • Add PATH setup with pg_config bindir
  • Add --timer flag to show test execution times
  • Clean and recreate log directory before each run
  • Add test log directories to EXTRA_CLEAN

SpockTest.pm changes:

  • Derive log filename from test name instead of PID
  • Use File::Basename to extract test name from script path
  • Log files now named as 001_basic.log, 002_create_subscriber.log, etc.
  • Makes it easier to identify which log belongs to which test

Result: Better organized test logs and real-time test progress visibility

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Adds TAP regression scheduling and structured test logging: Makefile gains TESTLOGDIR, SCHEDULE_FILE, and TAPS_REGRESS with updated prove_check; test runner exports TESTLOGDIR; SpockTest.pm derives per-test log names, creates log dirs, hardens psql environment, and passes -X to psql.

Changes

Cohort / File(s) Summary
Build System Test Configuration
Makefile
Adds TESTLOGDIR, SCHEDULE_FILE, TAPS_REGRESS; extends EXTRA_CLEAN; updates prove_check to recreate test log dir, adjust PATH with PG_CONFIG bindir, set TESTDIR/TESTLOGDIR, run prove with verbose timing, and use computed TAP list when present.
Test Runner Export
tests/tap/run_tests.sh
Exports TESTLOGDIR as an absolute path (export TESTLOGDIR="$(pwd)/$LOG_DIR"), making the log-dir path available to test harnesses.
Per-test Logging & psql hardening
tests/tap/t/SpockTest.pm
Uses File::Basename to name per-test logs (basename($0,'.pl')) and writes to ${TESTLOGDIR}/${test_name}.log; ensures log dir creation; redirects STDERR and command logs into per-test logs; sets psql options -X and nulls PSQLRC/HISTFILE; updates cluster/startup logging to use configurable LOG_DIR.

Poem

🐰 I hop where test logs softly grow,
Each script a name in evening's glow,
Timers tick and outputs sing,
Psql silent, neat—no stray thing.
Logs lined up in tidy rows, hooray, let's go!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Improve TAP test infrastructure' directly aligns with the main changes, which comprehensively enhance TAP test logging, scheduling, and execution visibility.
Description check ✅ Passed The description is detailed and clearly related to the changeset, explaining modifications to Makefile and SpockTest.pm with specific examples of improvements to test logging and execution.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task/improve-tap-test-infrastructure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Makefile`:
- Around line 28-29: Remove the unused cleanup path 'tests/tap/t/logs' from the
EXTRA_CLEAN variable in the Makefile: edit the line that defines EXTRA_CLEAN
(which currently includes "$(control_path) spock_compat.bc \ tests/logs
tests/tap/logs tests/tap/t/logs") and delete the 'tests/tap/t/logs' entry so
only actual log directories (e.g. tests/logs and tests/tap/logs) remain.
🧹 Nitpick comments (1)
Makefile (1)

107-109: TESTLOGDIR is created but not used by tests.

The TESTLOGDIR variable is set and the directory is created (lines 112-113), but it's not passed to the tests. SpockTest.pm creates its own logs/ directory in the working directory and doesn't reference TESTLOGDIR.

If the intent is to centralize logs to TESTLOGDIR, consider passing it via environment variable:

🔧 Suggested enhancement
 cd $(srcdir)/tests/tap && \
     TESTDIR='$(CURDIR)' \
+    SPOCKTEST_LOG_DIR='$(TESTLOGDIR)' \
     PATH="$(shell $(PG_CONFIG) --bindir):$$PATH" \

And update SpockTest.pm to use it:

my $log_dir = $ENV{SPOCKTEST_LOG_DIR} // "logs";
my $LOG_FILE = $ENV{SPOCKTEST_LOG_FILE} // "${log_dir}/${test_name}.log";
eval { make_path($log_dir) };

Makefile changes:
- Add TESTLOGDIR variable for centralized log location
- Parse test schedule file to run only configured tests
- Add PATH setup with pg_config bindir
- Add --timer flag to show test execution times
- Clean and recreate log directory before each run
- Add test log directories to EXTRA_CLEAN

SpockTest.pm changes:
- Derive log filename from test name instead of PID
- Use File::Basename to extract test name from script path
- Log files now named as 001_basic.log, 002_create_subscriber.log, etc.
- Makes it easier to identify which log belongs to which test
- Fix psqlrc interference by setting PSQLRC=/dev/null and adding -X flag
- Centralize logs using TESTLOGDIR environment variable

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@rasifr rasifr force-pushed the task/improve-tap-test-infrastructure branch from 2153377 to b8ce09d Compare February 6, 2026 06:21
Copy link
Contributor

@ibrarahmad ibrarahmad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mason-sharp mason-sharp merged commit c45f722 into main Feb 11, 2026
10 checks passed
@mason-sharp mason-sharp deleted the task/improve-tap-test-infrastructure branch February 11, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants