Skip to content

Commit 36d6f60

Browse files
authored
Fix test_bootstrap_without_em_config (#25754)
This tests was broken on systems where the python executable lives in path that also contains clang executable. We were remove PATH elements here, but we cannot remove the one that contains the python executable otherwise the bootstrap script cannot run at all.
1 parent 5d4d2fa commit 36d6f60

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/test_sanity.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import shutil
1010
import stat
11+
import sys
1112
import time
1213
from pathlib import Path
1314
from subprocess import PIPE, STDOUT
@@ -822,9 +823,20 @@ def test_bootstrap_without_em_config(self):
822823
for e in ['LLVM_ROOT', 'EMSDK_NODE', 'EMSDK_PYTHON', 'EMSDK', 'EMSCRIPTEN', 'BINARYEN_ROOT', 'EMCC_SKIP_SANITY_CHECK', 'EM_CONFIG']:
823824
env.pop(e, None)
824825

826+
python_path = os.path.normpath(os.path.dirname(sys.executable))
827+
825828
# Remove from PATH every directory that contains clang.exe so that bootstrap.py cannot
826829
# accidentally succeed by virtue of locating tools in PATH.
827-
new_path = [d for d in env['PATH'].split(os.pathsep) if not os.path.isfile(os.path.join(d, utils.exe_suffix('clang')))]
830+
def ignore_path(p):
831+
clang_bin = utils.exe_suffix('clang')
832+
# We cannot ignore a path element that contains the python executable itself, otherwise
833+
# the bootstrap script will fail
834+
if os.path.isfile(os.path.join(p, clang_bin)) and os.path.normpath(p) != python_path:
835+
return True
836+
return False
837+
838+
old_path = env['PATH'].split(os.pathsep)
839+
new_path = [d for d in old_path if not ignore_path(d)]
828840
env['PATH'] = os.pathsep.join(new_path)
829841

830842
# Running bootstrap.py should not fail

0 commit comments

Comments
 (0)