EXTENSION = my_extension
DATA = my_extension--1.0.sql
REGRESS = my_extension--regress.sql
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
my_extension--regress.sql
:-- regression test script for my_extension
-- Create the my_table table
CREATE TABLE my_table (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL
);
-- Test the my_function function
SELECT my_function();
-- Verify the data in the my_table table
SELECT * FROM my_table;
After running make installcheck
on my_extension
getting error:
Tried to set the environment variable PGUSER
PGUSER=postgres make installcheck
Got the error:
echo "+++ regress install-check in +++" && /Users/spartacus/.pgenv/pgsql-15.0/lib/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/Users/spartacus/.pgenv/pgsql-15.0/bin' --dbname=contrib_regression my_extension--regress
+++ regress install-check in +++
(using postmaster on Unix socket, default port)
============== dropping database "contrib_regression" ==============
SET
DROP DATABASE
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
============== running regression test queries ==============
test my_extension--regress ... diff: /Users/spartacus/Desktop/GSoC/CODE/my_extension/expected/my_extension--regress.out: No such file or directory
diff command failed with status 512: diff "/Users/spartacus/Desktop/GSoC/CODE/my_extension/expected/my_extension--regress.out" "/Users/spartacus/Desktop/GSoC/CODE/my_extension/results/my_extension--regress.out" > "/Users/spartacus/Desktop/GSoC/CODE/my_extension/results/my_extension--regress.out.diff"
make: *** [installcheck] Error 2
Link to the Github issue: https://github.com/IshaanAdarsh/Postgres-extension-tutorial/issues/15 (for more details and the extension code)
You need to provide expected/my_extension--regress.out
so that the regression tests have something to compare the actual results with.
Typically, you proceed like this:
run the regression tests and get the error message you see
look at results/my_extension--regress.out
and see if the output is as it should be
if you are happy with the results, copy results/my_extension--regress.out
to expected/my_extension--regress.out