Use Python shlex instead of the deprecated pipes

pipes is deprecated since Python 3.11 and is scheduled for removal in
Python 3.13 (https://peps.python.org/pep-0594/#deprecated-modules), with
shlex.quote being available since Python 3.3.

This was already implemented downstream in Chromium at
https://chromium.googlesource.com/chromium/src/+/8dc44aaeff04 without
following the instructions in third_party/crashpad/README.chromium, and
collided during the update at
https://chromium-review.googlesource.com/c/5766975.

Bug: 1453653
Change-Id: If54bd260e6f571c58f44568e79adafade5b1987e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5767512
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Mark Mentovai 2024-08-06 16:21:25 -04:00
parent 9b3ff691e9
commit b8658f3806

View File

@ -16,9 +16,9 @@
import argparse import argparse
import os import os
import pipes
import posixpath import posixpath
import re import re
import shlex
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
@ -185,9 +185,9 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
script_commands = [] script_commands = []
for k, v in env.items(): for k, v in env.items():
script_commands.append('export %s=%s' % script_commands.append('export %s=%s' %
(pipes.quote(k), pipes.quote(v))) (shlex.quote(k), shlex.quote(v)))
script_commands.extend([ script_commands.extend([
' '.join(pipes.quote(x) for x in command_args), 'status=${?}', ' '.join(shlex.quote(x) for x in command_args), 'status=${?}',
'echo "status=${status}"', 'exit ${status}' 'echo "status=${status}"', 'exit ${status}'
]) ])
adb_command.append('; '.join(script_commands)) adb_command.append('; '.join(script_commands))
@ -333,7 +333,9 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False, gtest_filter=None):
} }
} }
if gtest_filter: if gtest_filter:
module_data['CommandLineArguments'] = ['--gtest_filter='+gtest_filter] module_data['CommandLineArguments'] = [
'--gtest_filter=' + gtest_filter
]
return {test: module_data} return {test: module_data}
def xcuitest(binary_dir, test): def xcuitest(binary_dir, test):
@ -372,8 +374,12 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False, gtest_filter=None):
xctestrun_path = f.name + ".xctestrun" xctestrun_path = f.name + ".xctestrun"
print(xctestrun_path) print(xctestrun_path)
command = [ command = [
'xcodebuild', 'test-without-building', '-xctestrun', xctestrun_path, 'xcodebuild',
'-destination', 'platform=iOS Simulator,OS=17.4,name=iPhone 15', 'test-without-building',
'-xctestrun',
xctestrun_path,
'-destination',
'platform=iOS Simulator,OS=17.4,name=iPhone 15',
] ]
with open(xctestrun_path, 'wb') as fp: with open(xctestrun_path, 'wb') as fp:
if is_xcuitest: if is_xcuitest: