check_symbol_exports on Python3, Mac

subprocess.Popen returns byte data by default. Python2 was happy
to try to execute string operations on such data and hope for the
best, but python3 is more persnickety. Luckily, there's a simple
way to indicate to the Popen class that text data is wanted that
benefits the script. Just specifying universal_newlines will cause
the returned data to be text and also convert any system-specific
newlines to '\n' which the script relies on anyway.

Enabled on Mac as an incidental change after confirming that the
script works there just as well as it does on Linux.

It probably works on FreeBSD too, but I retired my BSD system years
ago. So I have no way to check.

Don't run it on Windows.
- It didn't work after all. It was just detecting non-posix and
  returning success.
This commit is contained in:
Greg Roth 2018-06-27 11:47:38 -06:00 коммит произвёл David Neto
Родитель f393b0e480
Коммит 878b3b400b
2 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -168,7 +168,7 @@ endif()
find_host_package(PythonInterp)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
macro(spvtools_check_symbol_exports TARGET)
add_test(NAME spirv-tools-symbol-exports-${TARGET}
COMMAND ${PYTHON_EXECUTABLE}

Просмотреть файл

@ -35,7 +35,8 @@ def command_output(cmd, directory):
p = subprocess.Popen(cmd,
cwd=directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
universal_newlines=True)
(stdout, _) = p.communicate()
if p.returncode != 0:
raise RuntimeError('Failed to run %s in %s' % (cmd, directory))