Skip to content

Commit

Permalink
Fixed GPGHOME setup for native Windows environment
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Oct 28, 2023
1 parent 9f2d6e9 commit 0db4ca5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/tests/cli_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def is_windows():

def path_for_gpg(path):
# GPG built for mingw/msys doesn't work with Windows paths
if re.match(r'^[a-z]:[\\\/].*', path.lower()):
# Native Windows program cannot work with MSys paths either
if re.match(r'^[a-z]:[\\\/].*', path.lower()) and sys.platform.startswith('msys'):
path = '/' + path[0] + '/' + path[3:].replace('\\', '/')
return path

Expand Down Expand Up @@ -100,7 +101,7 @@ def rnp_file_path(relpath, check = True):

def run_proc_windows(proc, params, stdin=None):
exe = os.path.basename(proc)
# test special quote cases
# test special quote cases
params = list(map(lambda st: st.replace('"', '\\"'), params))
# We need to escape empty parameters/ones with spaces with quotes
params = tuple(map(lambda st: st if (st and not any(x in st for x in [' ','\r','\t'])) else '"%s"' % st, [exe] + params))
Expand Down Expand Up @@ -176,9 +177,9 @@ def run_proc_windows(proc, params, stdin=None):
err = file_text(stderr_path).replace('\r\n', '\n')
os.unlink(stdout_path)
os.unlink(stderr_path)
if stdin:
if stdin:
os.unlink(stdin_path)
if passfo:
if passfo:
os.unlink(pass_path)
logging.debug(err.strip())
logging.debug(out.strip())
Expand Down
2 changes: 1 addition & 1 deletion src/tests/cli_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def setup(loglvl):
os.environ["RNP_LOG_CONSOLE"] = "1"

GPGDIR = os.path.join(WORKDIR, '.gpg')
GPGHOME = path_for_gpg(GPGDIR) if is_windows() else GPGDIR
GPGHOME = path_for_gpg(GPGDIR)
GPG = os.getenv('RNP_TESTS_GPG_PATH') or find_utility('gpg')
GPGCONF = os.getenv('RNP_TESTS_GPGCONF_PATH') or find_utility('gpgconf')
gpg_check_features()
Expand Down

0 comments on commit 0db4ca5

Please sign in to comment.