From 3d4b736fb7bbfa8dae2de9e3c143f316f1799b3a Mon Sep 17 00:00:00 2001 From: dh-cloud <60729713+dh-cloud@users.noreply.github.com> Date: Thu, 9 Jun 2022 20:51:45 +0800 Subject: [PATCH] Fix possible wrong mocking path in mocker.py The mocker.py uses all of `os.path.abspath`, `os.path.realpath` and `os.path.relpath`. When we configure greenplum source using a soft path, unit test will error out because file relative path returned by mocker.py is wrong. Maybe we can replace `os.path.abspath` with `os.path.realpath` . However there are some special paths: fe-auth.c -> ../../../src/interfaces/libpq/fe-auth.c fe-exec.c -> ../../../src/interfaces/libpq/fe-exec.c ... Use os.path.realpath(os.path.dirname(path) can gain the correct path. --- src/test/unit/mock/mocker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/unit/mock/mocker.py b/src/test/unit/mock/mocker.py index f4b6e6ae488..ae18f3a7218 100755 --- a/src/test/unit/mock/mocker.py +++ b/src/test/unit/mock/mocker.py @@ -36,7 +36,7 @@ class CFile(object): # Currently this requires static keyword at the beginning of line. ###staticvar_pat = re.compile(r'^static.+?;', re.MULTILINE | re.DOTALL) def __init__(self, path, options): - self.path = os.path.abspath(path) + self.path = os.path.join(os.path.realpath(os.path.dirname(path)), os.path.basename(path)) self.options = options #with open(self.make_i()) as f: with open(self.path) as f: