[libcxx] r346878 - [libcxx] [test] Fix running tests on macOS with python3

Alexander Richardson arichardson.kde at gmail.com
Wed Nov 14 09:58:55 PST 2018


Author: arichardson
Date: Wed Nov 14 09:58:55 2018
New Revision: 346878

URL: http://llvm.org/viewvc/llvm-project?rev=346878&view=rev
Log:
[libcxx] [test] Fix running tests on macOS with python3

Summary:
The result of subprocess.check_output() is bytes in python3 which we need
to convert to str(). Simplify this by using the executeCommand() helper.

Reviewers: ldionne, EricWF

Reviewed By: ldionne

Subscribers: christof, libcxx-commits

Differential Revision: https://reviews.llvm.org/D54522

Modified:
    libcxx/trunk/utils/libcxx/test/target_info.py

Modified: libcxx/trunk/utils/libcxx/test/target_info.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/target_info.py?rev=346878&r1=346877&r2=346878&view=diff
==============================================================================
--- libcxx/trunk/utils/libcxx/test/target_info.py (original)
+++ libcxx/trunk/utils/libcxx/test/target_info.py Wed Nov 14 09:58:55 2018
@@ -15,6 +15,8 @@ import re
 import subprocess
 import sys
 
+from libcxx.util import executeCommand
+
 class DefaultTargetInfo(object):
     def __init__(self, full_config):
         self.full_config = full_config
@@ -127,14 +129,13 @@ class DarwinLocalTI(DefaultTargetInfo):
             cmd = ['xcrun', '--sdk', name, '--show-sdk-path']
         else:
             cmd = ['xcrun', '--show-sdk-path']
-        try:
-            out = subprocess.check_output(cmd).strip()
-            res = 0
-        except OSError:
-            res = -1
-        if res == 0 and out:
-            sdk_path = out
+        out, err, exit_code = executeCommand(cmd)
+        if exit_code != 0:
+            self.full_config.lit_config.warning("Could not determine macOS SDK path! stderr was " + err)
+        if exit_code == 0 and out:
+            sdk_path = out.strip()
             self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path)
+            assert isinstance(sdk_path, str)
             flags += ["-isysroot", sdk_path]
 
     def add_cxx_link_flags(self, flags):




More information about the libcxx-commits mailing list