Skip to content

Commit

Permalink
Fix possible wrong mocking path in mocker.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dh-cloud authored and reshke committed Feb 13, 2025
1 parent 6c53ab4 commit 3d4b736
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/test/unit/mock/mocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3d4b736

Please sign in to comment.