Regression testing Issue [make installcheck] 反回归测试问题 [make installcheck]

huangapple go评论55阅读模式
英文:

Regression testing Issue [make installcheck]

问题

用于回归测试的部分:

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

-- 用于 my_extension 的回归测试脚本

-- 创建 my_table 表
CREATE TABLE my_table (
  id SERIAL PRIMARY KEY,
  name VARCHAR(100) NOT NULL
);

-- 测试 my_function 函数
SELECT my_function();

-- 验证 my_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  +++
(使用 Unix 套接字上的 postmaster,默认端口)
============== 删除数据库 "contrib_regression" ==============
SET
DROP DATABASE
============== 创建数据库 "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
ALTER DATABASE
============== 运行回归测试查询        ==============
test my_extension--re
gress        ... 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(以获取更多详细信息和扩展代码)

英文:

For the regression tests:

The code for the makefile is:

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)

Regression testing SQL file 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)

答案1

得分: 0

你需要提供 expected/my_extension--regress.out,以便回归测试可以将实际结果与之进行比较。

通常情况下,您可以按照以下步骤进行操作:

  • 运行回归测试并获取您看到的错误消息

  • 查看 results/my_extension--regress.out,看输出是否符合预期

  • 如果结果满意,将 results/my_extension--regress.out 复制到 expected/my_extension--regress.out

英文:

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

huangapple
  • 本文由 发表于 2023年6月26日 22:10:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557490.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定