test bug: only attempt to compile when cc is available

This commit is contained in:
Ilan Schnell 2013-03-05 16:47:31 -06:00
commit 3c4769c58d

View file

@ -9,6 +9,7 @@ import unittest
import subprocess
import tempfile
import contextlib
from distutils.spawn import find_executable
is_py3k = sys.version_info[0] >= 3
BITS = tuple.__itemsize__ * 8
@ -31,7 +32,6 @@ import llvmpy
tests = []
# ---------------------------------------------------------------------------
if sys.version_info[:2] <= (2, 6):
@ -674,6 +674,7 @@ tests.append(TestTargetMachines)
# ---------------------------------------------------------------------------
class TestNative(TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
@ -694,8 +695,12 @@ class TestNative(TestCase):
return m
def _compile(self, src):
cc = find_executable('cc')
if not cc:
return
dst = os.path.join(self.tmpdir, 'llvmobj.out')
s = subprocess.call(['cc', '-o', dst, src])
s = subprocess.call([cc, '-o', dst, src])
if s != 0:
raise Exception("Cannot compile")