From b0a758d46f3a9be973736fe529f796f5b3a9b65f Mon Sep 17 00:00:00 2001 From: Maxim Samsonov Date: Sat, 28 Oct 2023 18:21:42 +0300 Subject: [PATCH] Fixed GPGHOME setup for native Windows environment --- .github/workflows/windows-native.yml | 4 ++++ src/tests/cli_common.py | 9 +++++---- src/tests/cli_tests.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/windows-native.yml b/.github/workflows/windows-native.yml index 3f96e1c61a..9ff1e386f0 100644 --- a/.github/workflows/windows-native.yml +++ b/.github/workflows/windows-native.yml @@ -112,6 +112,10 @@ jobs: echo "VCPKG_DIR_U=$dir_u" >> $GITHUB_ENV vcpkg install --triplet ${{ matrix.arch.triplet }} bzip2 zlib json-c getopt dirent ${{ matrix.backend }} + - name: Install gnupg + # There is gnupg on the runner but it is MSys version + run: choco install gnupg -y + - name: Set OPENSSL_ROOT_DIR # Ensure consistent access to openssl installation for test_backend_version test # There is another one instance of ssl at /mingw and /mingw/bin is always at the first position at PATH diff --git a/src/tests/cli_common.py b/src/tests/cli_common.py index f8d7001fc8..e66ca61459 100644 --- a/src/tests/cli_common.py +++ b/src/tests/cli_common.py @@ -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 @@ -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)) @@ -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()) diff --git a/src/tests/cli_tests.py b/src/tests/cli_tests.py index 1f4981005f..87ab8a2086 100755 --- a/src/tests/cli_tests.py +++ b/src/tests/cli_tests.py @@ -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()