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_DIR as 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 because git subtree pull requires 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 add from v1
-
Runs make pgxntool-sync-test to pull v2
-
Verifies:
- pgxntool files reflect v2 after sync
.gitignore was auto-updated by update-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.
Context
update-setup-files.shhas thorough unit tests (test/standard/update-setup-files.batsin pgxntool-test) that test 3-way merge scenarios in isolation. But there is no test for the fullmake pgxntool-syncflow: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
-Pprefix logic.Approach
Create
test/standard/pgxntool-sync.batsin 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 v1Runs
make pgxntool-sync-testto pull v2Verifies:
.gitignorewas auto-updated byupdate-setup-files.shHow pgxntool-sync works
The
%pattern is looked up as a make variable, e.g.:make pgxntool-sync-local→$(pgxntool-sync-local)=../pgxntool mastermake pgxntool-sync-foo 'pgxntool-sync-foo=/path/to/repo branch'The test uses the custom variable approach to point at the local temp repo.