diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2025-07-31 13:21:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-31 13:21:14 -0700 |
commit | bf7afe1dc9c36011457c57b87cbe48e89f105ce4 (patch) | |
tree | 0d55f4b10d40f67e70fede0daabdef7f24768fce /lldb/packages/Python/lldbsuite/test/dotest.py | |
parent | fd175fafa6353f6ddb2101c025d45efdfe25209b (diff) | |
download | llvm-bf7afe1dc9c36011457c57b87cbe48e89f105ce4.zip llvm-bf7afe1dc9c36011457c57b87cbe48e89f105ce4.tar.gz llvm-bf7afe1dc9c36011457c57b87cbe48e89f105ce4.tar.bz2 |
[lldb] Don't use NamedTemporaryFile to test compiler support (#151387)
You cannot use a NamedTempFile with an external process because it may
not be flushed to disk. The safest and most portable approach is to
close the file, call the other process and then unlink the file
manually.
Presumably this works fine on Linux, but it fails on Darwin when
targeting remote-linux.
See https://bugs.python.org/issue29573
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/dotest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/dotest.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 31b48dc..47a3c2e 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -43,6 +43,7 @@ from . import lldbtest_config from . import test_categories from . import test_result from ..support import seven +from ..support import temp_file def is_exe(fpath): @@ -785,8 +786,8 @@ def canRunLibcxxTests(): return True, "libc++ always present" if platform == "linux": - with tempfile.NamedTemporaryFile() as f: - cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"] + with temp_file.OnDiskTempFile() as f: + cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.path, "-"] p = subprocess.Popen( cmd, stdin=subprocess.PIPE, @@ -845,8 +846,8 @@ def canRunMsvcStlTests(): if platform != "windows": return False, f"Don't know how to build with MSVC's STL on {platform}" - with tempfile.NamedTemporaryFile() as f: - cmd = [configuration.compiler, "-xc++", "-o", f.name, "-E", "-"] + with temp_file.OnDiskTempFile() as f: + cmd = [configuration.compiler, "-xc++", "-o", f.path, "-E", "-"] p = subprocess.Popen( cmd, stdin=subprocess.PIPE, |