Loading files
ec334891fThis file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/tulipcc-498083946.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
ec334891fThis file is pinned to the selected release. Download the original to open it in your design tool.
#------------------------------------------------------------------------------
# pycparser: test_util.py
#
# Utility code for tests.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# This file contributed by vit9696@users.noreply.github.com
# License: BSD
#------------------------------------------------------------------------------
import os
import platform
import subprocess
import sys
def cpp_supported():
"""Is cpp (the C preprocessor) supported as a native command?"""
return platform.system() == 'Linux'
def cpp_path():
"""Path to cpp command."""
if platform.system() == 'Darwin':
return 'gcc'
return 'cpp'
def cpp_args(args=[]):
"""Turn args into a suitable format for passing to cpp."""
if isinstance(args, str):
args = [args]
if platform.system() == 'Darwin':
return ['-E'] + args
return args
def _bytes2str(b):
return b.decode('latin-1')
def run_exe(exe_path, args=[], echo=False):
""" Runs the given executable as a subprocess, given the
list of arguments. Captures its return code (rc) and stdout and
returns a tuple: rc, stdout, stderr
"""
popen_cmd = [exe_path] + args
if os.path.splitext(exe_path)[1] == '.py':
popen_cmd.insert(0, sys.executable)
if echo:
print('[cmd]', ' '.join(popen_cmd))
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
return proc.returncode, _bytes2str(stdout), _bytes2str(stderr)