Fix test_compile() with debug and clang on macOS

This commit is contained in:
Kovid Goyal
2021-09-24 08:31:16 +05:30
parent c2641458e7
commit 558fad1630

View File

@@ -6,6 +6,7 @@ import argparse
import glob import glob
import json import json
import os import os
import platform
import re import re
import runpy import runpy
import shlex import shlex
@@ -13,14 +14,14 @@ import shutil
import subprocess import subprocess
import sys import sys
import sysconfig import sysconfig
import platform import tempfile
import time import time
from contextlib import suppress from contextlib import suppress
from functools import partial from functools import partial
from pathlib import Path from pathlib import Path
from typing import ( from typing import (
Callable, Dict, Iterable, Iterator, List, NamedTuple, Optional, Callable, Dict, Iterable, Iterator, List, NamedTuple, Optional, Sequence,
Sequence, Set, Tuple, Union Set, Tuple, Union
) )
from glfw import glfw # noqa from glfw import glfw # noqa
@@ -238,11 +239,12 @@ def test_compile(
ldflags: Iterable[str] = (), ldflags: Iterable[str] = (),
) -> bool: ) -> bool:
src = src or 'int main(void) { return 0; }' src = src or 'int main(void) { return 0; }'
p = subprocess.Popen( with tempfile.NamedTemporaryFile() as f:
[cc] + list(cflags) + ([] if link_also else ['-c']) + ['-x', lang, '-o', os.devnull, '-'] + p = subprocess.Popen(
[f'-l{x}' for x in libraries] + list(ldflags), [cc] + list(cflags) + ([] if link_also else ['-c']) + ['-x', lang, '-o', f.name, '-'] +
stdout=subprocess.DEVNULL, stdin=subprocess.PIPE, stderr=None if show_stderr else subprocess.DEVNULL [f'-l{x}' for x in libraries] + list(ldflags),
) stdout=subprocess.DEVNULL, stdin=subprocess.PIPE, stderr=None if show_stderr else subprocess.DEVNULL
)
stdin = p.stdin stdin = p.stdin
assert stdin is not None assert stdin is not None
try: try: