postgresql 回归测试问题[make installcheck]

r7knjye2  于 2023-06-29  发布在  PostgreSQL
关注(0)|答案(1)|浏览(134)

回归测试:

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(更多详情和扩展代码)

vhmi4jdf

vhmi4jdf1#

您需要提供expected/my_extension--regress.out,以便回归测试可以与实际结果进行比较。
通常情况下,您可以这样操作:

  • 运行回归测试并获得您看到的错误消息
  • 查看results/my_extension--regress.out并查看输出是否与预期相同
  • 如果您对结果满意,请将results/my_extension--regress.out复制到expected/my_extension--regress.out

相关问题