summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-04-25 15:28:44 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2022-04-26 11:51:26 +0800
commit3471c22f52a396fc04eb064eb363afa8f098cd6a (patch)
tree0b7f014915ad083af2b9d0d8192b6dc7dd5b5545 /testsuite
parent3af4d53945dd92b955ba1fee45d9a2957b6af8c4 (diff)
downloadgtk+-3471c22f52a396fc04eb064eb363afa8f098cd6a.tar.gz
testsuite: Fix introspection test on Windows
...when we are using Python 3.8.x or later. Python 3.8.x or later on Windows require one to call os.add_dll_directory() on every directory that contains dependent non-system DLLs of a module that are not bundled/installed with the module. Since we are very likely running programs that rely on dependent items in %PATH%, make things easier for people by calling os.add_dll_directory() on all the valid paths in %PATH% in api.py, so that the test will run successfully on Windows with Python 3.8.x or later.
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/introspection/api.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/testsuite/introspection/api.py b/testsuite/introspection/api.py
index c35b2b7448..a0afd6be57 100755
--- a/testsuite/introspection/api.py
+++ b/testsuite/introspection/api.py
@@ -1,6 +1,19 @@
#! /usr/bin/env python3
+import os
import sys
+
+# Python 3.8.x or later on Windows require os.add_dll_directory()
+# to be called on every directory that contains the required
+# non-bundled, non-system DLLs of a module so that the module can
+# be loaded successfully by Python. Make things easiler for people
+# by calling os.add_dll_directory() on the valid paths in %PATH%.
+if hasattr(os, 'add_dll_directory'):
+ paths = os.environ['PATH'].split(os.pathsep)
+ for path in paths:
+ if path != '' and os.path.isdir(path):
+ os.add_dll_directory(path)
+
import gi
gi.require_version('Gtk', '4.0')