-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Context
update-setup-files.sh has thorough unit tests (test/standard/update-setup-files.bats in pgxntool-test) that test 3-way merge scenarios in isolation. But there is no test for the full make pgxntool-sync flow: git subtree pull → update-setup-files.sh.
This test is needed before adding subdirectory support (#TBD), since that work will modify the sync target's -P prefix logic.
Approach
Create test/standard/pgxntool-sync.bats in pgxntool-test that:
-
Creates a local, temporary git repo inside the test's
$TEST_DIRas a pgxntool source (this is NOT a third GitHub repo — it's a throwaway repo that gets cleaned up with the test environment). This is needed becausegit subtree pullrequires pulling from a real git repo, and the actual pgxntool repo may be dirty during test runs. -
Tags two versions in that temp repo (v1 = baseline, v2 = adds a marker line to
_.gitignore) -
Creates a test extension repo using
git subtree addfrom v1 -
Runs
make pgxntool-sync-testto pull v2 -
Verifies:
- pgxntool files reflect v2 after sync
.gitignorewas auto-updated byupdate-setup-files.sh- A merge commit was created
How pgxntool-sync works
pgxntool-sync-%:
@old_commit=$$(git log -1 --format=%H -- pgxntool/) && \
git subtree pull -P pgxntool --squash -m "Pull pgxntool from $($@)" $($@) && \
pgxntool/update-setup-files.sh "$$old_commit"The % pattern is looked up as a make variable, e.g.:
make pgxntool-sync-local→$(pgxntool-sync-local)=../pgxntool master- Custom:
make pgxntool-sync-foo 'pgxntool-sync-foo=/path/to/repo branch'
The test uses the custom variable approach to point at the local temp repo.