回归测试:
makefile的代码为:
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)
回归测试SQL文件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;
在my_extension
上运行make installcheck
后,出现错误:
已尝试设置环境变量PGUSER PGUSER=postgres make installcheck
得到错误:
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
链接到Github问题:https://github.com/IshaanAdarsh/Postgres-extension-tutorial/issues/15(更多详情和扩展代码)
1条答案
按热度按时间vhmi4jdf1#
您需要提供
expected/my_extension--regress.out
,以便回归测试可以与实际结果进行比较。通常情况下,您可以这样操作:
results/my_extension--regress.out
并查看输出是否与预期相同results/my_extension--regress.out
复制到expected/my_extension--regress.out