Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions META.in.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "test_factory",
"abstract": "Framework for managing test data",
"description": "Provides functions for registering commands to create test data and obtaining data during testing",
"version": "0.5.0",
"version": "1.0.0",
"maintainer": "Jim Nasby <Jim.Nasby@BlueTreble.com>",
"license": {"BSD 2 Clause": "http://opensource.org/licenses/bsd-license.php"},

Expand All @@ -12,31 +12,31 @@
"abstract": "Framework for managing test data",
"file": "sql/test_factory.sql",
"docfile": "doc/test_factory.asc",
"version": "0.5.0"
"version": "1.0.0"
},
"test_factory_pgtap": {
"abstract": "pgTap extension for test_factory",
"file": "sql/test_factory_pgtap.sql",
"docfile": "doc/test_factory.asc",
"version": "0.1.0"
"version": "1.0.0"
}
},


"release_status": "stable",

"generated_by": "Jim Nasby <Jim.Nasby@BlueTreble.com>",
"generated_by": "Jim Nasby <Jim.Nasby@gmail.com>",

"tags": [ "testing", "unit test", "tests", "test data", "test factory" ],

"resources": {
"homepage": "http://github.com/BlueTreble/test_factory/",
"homepage": "http://github.com/Postgres-Extensions/test_factory/",
"bugtracker": {
"web": "http://github.com/BlueTreble/test_factory/issues"
"web": "http://github.com/Postgres-Extensions/test_factory/issues"
},
"repository": {
"url": "git://github.com/BlueTreble/test_factory.git",
"web": "http://github.com/BlueTreble/test_factory/",
"url": "git://github.com/Postgres-Extensions/test_factory.git",
"web": "http://github.com/Postgres-Extensions/test_factory/",
"type": "git"
}
},
Expand Down
16 changes: 8 additions & 8 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "test_factory",
"abstract": "Framework for managing test data",
"description": "Provides functions for registering commands to create test data and obtaining data during testing",
"version": "0.5.0",
"version": "1.0.0",
"maintainer": "Jim Nasby <Jim.Nasby@BlueTreble.com>",
"license": {"BSD 2 Clause": "http://opensource.org/licenses/bsd-license.php"},

Expand All @@ -15,31 +15,31 @@
"abstract": "Framework for managing test data",
"file": "sql/test_factory.sql",
"docfile": "doc/test_factory.asc",
"version": "0.5.0"
"version": "1.0.0"
},
"test_factory_pgtap": {
"abstract": "pgTap extension for test_factory",
"file": "sql/test_factory_pgtap.sql",
"docfile": "doc/test_factory.asc",
"version": "0.1.0"
"version": "1.0.0"
}
},


"release_status": "stable",

"generated_by": "Jim Nasby <Jim.Nasby@BlueTreble.com>",
"generated_by": "Jim Nasby <Jim.Nasby@gmail.com>",

"tags": [ "testing", "unit test", "tests", "test data", "test factory" ],

"resources": {
"homepage": "http://github.com/BlueTreble/test_factory/",
"homepage": "http://github.com/Postgres-Extensions/test_factory/",
"bugtracker": {
"web": "http://github.com/BlueTreble/test_factory/issues"
"web": "http://github.com/Postgres-Extensions/test_factory/issues"
},
"repository": {
"url": "git://github.com/BlueTreble/test_factory.git",
"web": "http://github.com/BlueTreble/test_factory/",
"url": "git://github.com/Postgres-Extensions/test_factory.git",
"web": "http://github.com/Postgres-Extensions/test_factory/",
"type": "git"
}
},
Expand Down
9 changes: 9 additions & 0 deletions pgxntool/HISTORY.asc
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
1.1.0
-----
== Use unique database names for tests
Tests now use a unique database name based on the project name and a hash of the current directory. This prevents test conflicts when running tests for multiple projects in parallel.

== Add 3-way merge support for setup files after pgxntool-sync
New `update-setup-files.sh` script handles merging changes to files initially copied by `setup.sh` (`.gitignore`, `test/deps.sql`). After running `make pgxntool-sync`, the script performs a 3-way merge if both you and pgxntool have modified the same file, using git's native conflict markers for resolution.


1.0.0
-----
== Fix broken multi-extension support
Expand Down
19 changes: 17 additions & 2 deletions pgxntool/base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ TEST__SOURCE__SQL_FILES = $(patsubst $(TESTDIR)/input/%.source,$(TESTDIR)/sql/%
TEST__SOURCE__EXPECTED_FILES = $(patsubst $(TESTDIR)/output/%.source,$(TESTDIR)/expected/%.out,$(TEST__SOURCE__OUTPUT_FILES))
REGRESS = $(sort $(notdir $(subst .source,,$(TEST_FILES:.sql=)))) # Sort is to get unique list
REGRESS_OPTS = --inputdir=$(TESTDIR) --outputdir=$(TESTOUT) # See additional setup below

# Generate unique database name for tests to prevent conflicts across projects
# Uses project name + first 5 chars of md5 hash of current directory
# This prevents multiple test runs in different directories from clobbering each other
REGRESS_DBHASH := $(shell echo $(CURDIR) | (md5 2>/dev/null || md5sum) | cut -c1-5)
REGRESS_DBNAME := $(or $(PGXN),regression)_$(REGRESS_DBHASH)
REGRESS_OPTS += --dbname=$(REGRESS_DBNAME)
MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
ifeq ($(strip $(MODULES)),)
MODULES =# Set to NUL so PGXS doesn't puke
Expand Down Expand Up @@ -291,17 +298,25 @@ print-% : ; $(info $* is $(flavor $*) variable set to "$($*)") @true
#
# This is setup to allow any number of pull targets by defining special
# variables. pgxntool-sync-release is an example of this.
.PHONY: pgxn-sync-%
#
# After the subtree pull, we run update-setup-files.sh to handle files that
# were initially copied by setup.sh (like .gitignore). This script does a
# 3-way merge if both you and pgxntool changed the file.
.PHONY: pgxntool-sync-%
pgxntool-sync-%:
git subtree pull -P pgxntool --squash -m "Pull pgxntool from $($@)" $($@)
@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"
pgxntool-sync: pgxntool-sync-release

# DANGER! Use these with caution. They may add extra crap to your history and
# could make resolving merges difficult!
pgxntool-sync-release := git@github.com:decibel/pgxntool.git release
pgxntool-sync-stable := git@github.com:decibel/pgxntool.git stable
pgxntool-sync-master := git@github.com:decibel/pgxntool.git master
pgxntool-sync-local := ../pgxntool release # Not the same as PGXNTOOL_DIR!
pgxntool-sync-local-stable := ../pgxntool stable # Not the same as PGXNTOOL_DIR!
pgxntool-sync-local-master := ../pgxntool master # Not the same as PGXNTOOL_DIR!

distclean:
rm -f $(PGXNTOOL_distclean)
Expand Down
17 changes: 17 additions & 0 deletions pgxntool/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
# This file is meant to be sourced by other scripts, not executed directly.
# Usage: source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"

# =============================================================================
# SETUP FILES CONFIGURATION
# =============================================================================
# Files copied by setup.sh and tracked by update-setup-files.sh for sync updates.
# Format: "source_in_pgxntool:destination_in_project"
# =============================================================================
SETUP_FILES=(
"_.gitignore:.gitignore"
"test/deps.sql:test/deps.sql"
)

# Symlinks created by setup.sh and verified by update-setup-files.sh
# Format: "destination:target"
SETUP_SYMLINKS=(
"test/pgxntool:../pgxntool/test/pgxntool"
)

# Error function - outputs to stderr but doesn't exit
# Usage: error "message"
error() {
Expand Down
41 changes: 32 additions & 9 deletions pgxntool/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,44 @@ safecp () {
fi
}

safecp pgxntool/_.gitignore .gitignore
safecp pgxntool/META.in.json META.in.json
# =============================================================================
# SETUP FILES
# =============================================================================
# SETUP_FILES and SETUP_SYMLINKS are defined in lib.sh
# These are also used by update-setup-files.sh for sync updates.
# =============================================================================

# Copy tracked setup files (defined in lib.sh)
for entry in "${SETUP_FILES[@]}"; do
src="pgxntool/${entry%%:*}"
dest="${entry##*:}"
# Create parent directory if needed
mkdir -p "$(dirname "$dest")"
safecp "$src" "$dest"
done

# Create tracked symlinks (defined in lib.sh)
for entry in "${SETUP_SYMLINKS[@]}"; do
dest="${entry%%:*}"
target="${entry##*:}"
mkdir -p "$(dirname "$dest")"
if [ ! -e "$dest" ]; then
echo "Creating symlink $dest -> $target"
ln -s "$target" "$dest"
git add "$dest"
else
echo "$dest already exists"
fi
done

# META.in.json and Makefile are NOT in SETUP_FILES because users heavily customize them
safecp pgxntool/META.in.json META.in.json
safecreate Makefile include pgxntool/base.mk

make META.json
git add META.json

mkdir -p sql test src

cd test
mkdir -p sql
safecp ../pgxntool/test/deps.sql deps.sql
[ -d pgxntool ] || ln -s ../pgxntool/test/pgxntool .
git add pgxntool
mkdir -p sql test/sql src
git status

echo "If you won't be creating C code then you can:
Expand Down
Loading