Skip to content

Add end-to-end test for make pgxntool-sync #16

@jnasbyupgrade

Description

@jnasbyupgrade

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 pullupdate-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:

  1. 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.

  2. Tags two versions in that temp repo (v1 = baseline, v2 = adds a marker line to _.gitignore)

  3. Creates a test extension repo using git subtree add from v1

  4. Runs make pgxntool-sync-test to pull v2

  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions