Skip to content

Commit 1eb4071

Browse files
committed
Add DarwinExecutor
1 parent fcf3bee commit 1eb4071

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

scripts/tests/chiptest/darwin.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env -S python3 -B
2+
3+
# Copyright (c) 2025 Project CHIP Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import subprocess
18+
from .runner import Executor, SubprocessInfo
19+
20+
class DarwinExecutor(Executor):
21+
def run(self, subproc: SubprocessInfo, stdin, stdout, stderr):
22+
# Try harder to avoid any stdout buffering in our tests
23+
wrapped = wrapped.wrap_with('stdbuf', '-o0', '-i0')
24+
s = subprocess.Popen(wrapped.to_cmd(), stdin=stdin, stdout=stdout, stderr=stderr)
25+
return s

scripts/tests/chiptest/runner.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ def __init__(self, executor=None, capture_delegate=None):
155155
self.capture_delegate = capture_delegate
156156

157157
def RunSubprocess(self, subproc: SubprocessInfo, name: str, wait=True, dependencies=[], timeout_seconds: typing.Optional[int] = None, stdin=None):
158-
if sys.platform == 'darwin':
159-
# Try harder to avoid any stdout buffering in our tests
160-
subproc = subproc.wrap_with('stdbuf', '-o0', '-i0')
161-
162158
logging.info('RunSubprocess starting application %s' % subproc)
163159
cmd = subproc.to_cmd()
164160

scripts/tests/run_test_suite.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,10 @@ def build_app(arg_value, kind: str, key: str):
409409
ble_controller_tool = 1 # Bind tool to the second BLE controller
410410

411411
executor = chiptest.linux.LinuxNamespacedExecutor(ns)
412-
runner = runner = chiptest.runner.Runner(executor=executor)
412+
runner = chiptest.runner.Runner(executor=executor)
413+
elif sys.platform == 'darwin':
414+
executor = chiptest.darwin.DarwinExecutor()
415+
runner = chiptest.runner.Runner(executor=executor)
413416
else:
414417
runner = chiptest.runner.Runner()
415418

0 commit comments

Comments
 (0)