[llvm] f1431bb - [lit] Set __COMPAT_LAYER=RunAsInvoker when running tests on Windows

Alvin Wong via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 01:28:52 PDT 2023


Author: Alvin Wong
Date: 2023-04-27T16:28:34+08:00
New Revision: f1431bbfb17cd7167adda9fc8521bb6eec52c300

URL: https://github.com/llvm/llvm-project/commit/f1431bbfb17cd7167adda9fc8521bb6eec52c300
DIFF: https://github.com/llvm/llvm-project/commit/f1431bbfb17cd7167adda9fc8521bb6eec52c300.diff

LOG: [lit] Set __COMPAT_LAYER=RunAsInvoker when running tests on Windows

Windows heuristics try to detect old installer programs and run them as
elevated. These heuristics include checking for certain substrings in
file names, e.g. "patch", "update", "setup". When lit tries to run
affected executables, it produces "[WinError 740] The requested
operation requires elevation" instead. Several tests have been affected
by this issue (see https://reviews.llvm.org/D137772,
https://reviews.llvm.org/D148988, https://reviews.llvm.org/D149004).

We should set this environment variable to disable this heuristic once
and for all, instead of setting it in inidividual test suites. There
should be no lit tests that legitimately want to run as elevated.

Differential Revision: https://reviews.llvm.org/D149064

Added: 
    

Modified: 
    llvm/utils/lit/lit/TestingConfig.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/TestingConfig.py b/llvm/utils/lit/lit/TestingConfig.py
index 6995a9a1f61c4..01f5ca4946264 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -75,6 +75,14 @@ def fromdefaults(litConfig):
                 'USERPROFILE',
             ]
             environment['PYTHONBUFFERED'] = '1'
+            # Avoid Windows heuristics which try to detect potential installer
+            # programs (which may need to run with elevated privileges) and ask
+            # if the user wants to run them in that way. This heuristic may
+            # match for executables containing the substrings "patch" (which is
+            # a substring of "dispatch"), "update", "setup", etc. Set this
+            # environment variable indicating that we want to execute them with
+            # the current user.
+            environment['__COMPAT_LAYER'] = 'RunAsInvoker'
 
         for var in pass_vars:
             val = os.environ.get(var, '')


        


More information about the llvm-commits mailing list