From patchwork Wed Dec 17 02:27:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 944 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938528; bh=XAE7Gcvbq1ZKVlq17yh3U0KN7hUWEhpAeu/EnR6g1sE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ibx6AoImL9A/Hsmn1c2tEViypf7AxOjUr1UBS43gRHk0wcCWulcjK9+WhTaOG0/op bHLm9XuarLijoSeA4pC9uEnffEdPH9Ul7ugIz7UYmX9H014RtM1Hlbbs3s6WTfW3ZM NAuYE25IQh0s+N4kqehBWP03ogIhE81Znr637XUOA6J76bk0DE3WrRuU+dAvhnI8Pp Q3iNHHfC3zyHYPi8rDdl4YRD5goa5Ho2xlvyhXmU5qJ/C4xcm9dD9fXCz35Kd18bYi s/HNyPkr6WMS2HGvq0CF4b47H6PughQGKOzVGdLLE7dv6qW6Nb2c5pcQeK5bC0ve/m 9KAGFWwL6ikOA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7A83A68BB6 for ; Tue, 16 Dec 2025 19:28:48 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GWdfJfQWyvd5 for ; Tue, 16 Dec 2025 19:28:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938528; bh=XAE7Gcvbq1ZKVlq17yh3U0KN7hUWEhpAeu/EnR6g1sE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ibx6AoImL9A/Hsmn1c2tEViypf7AxOjUr1UBS43gRHk0wcCWulcjK9+WhTaOG0/op bHLm9XuarLijoSeA4pC9uEnffEdPH9Ul7ugIz7UYmX9H014RtM1Hlbbs3s6WTfW3ZM NAuYE25IQh0s+N4kqehBWP03ogIhE81Znr637XUOA6J76bk0DE3WrRuU+dAvhnI8Pp Q3iNHHfC3zyHYPi8rDdl4YRD5goa5Ho2xlvyhXmU5qJ/C4xcm9dD9fXCz35Kd18bYi s/HNyPkr6WMS2HGvq0CF4b47H6PughQGKOzVGdLLE7dv6qW6Nb2c5pcQeK5bC0ve/m 9KAGFWwL6ikOA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68B2868BAC for ; Tue, 16 Dec 2025 19:28:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938527; bh=hpD8GXq2fGF+9H3HdXGzEroWBqOS/GNm4H20yVORW6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLwpTa4JEiZLtYkfPfkiGbXke1VNapiU3EwOzJq9LMa5SZV7ZOIp0mOC5Ykp2uiwV PuD4R8YooRG5XXKewxPBhWPef33+ESSKj4nVMT5rAG2EEQXSf31df0VWvuEX0B7l9S gmhOq/mceMic8E+PBYki9aZUuLzF/L7ZZHqo1bWCEbl/nzqgV21oKj5cIRIBBetQZI BU+dZJ/8Y1G0zOJ7otwyx0Lb6uzFX38x6ROLm257f1Lkk/yDSHGddIxKu08iRgbhGV 35MGxoQTREOpNrHkNEgOciPm68aVCvdMQU8QsTse0fx5DOeO/IwPScvvJ9Ao7I6ErC ty38QxCGYYpcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 60B4968AFF; Tue, 16 Dec 2025 19:28:47 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id ponWsSNy8xDw; Tue, 16 Dec 2025 19:28:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938523; bh=cK8ZdjRlhmdrzz13CjmkqeerVfCpYb+m+JY4+pZLmxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TsAuOMrb6Fm8YgvUc0QaloV2zjNvH+kZWR5r8XWIAIhtKzbmwzc0kyt4H+bOzJBeA 5ARQ+lzSbeIUvqqpmrgwJiQ90QlgtpR/3h/B900TNYqfhab4k4q61fGzJ4+tWORD1I AGSZJIvSNV9c/hQxtVALiwZemv8oUeROh9mqX7BunFTgg4bzVWfloYliKIpCG9aN5G KadGIopocWY9ec8iRcOIMlkAKfaisl/px+Hb7JGvp0gagJS+0xe82cRQpNLfxkgqBg 0lS35qteK24B+iiC2fjbut728CTkzFGmDRnljCVwbraXAWJ7LI0+KwRf1h3sAzGI+d 4MeIW2MFrXsOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E288C6884F; Tue, 16 Dec 2025 19:28:42 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 16 Dec 2025 19:27:50 -0700 Message-ID: <20251217022823.392557-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217022823.392557-1-sjg@u-boot.org> References: <20251217022823.392557-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GEUNGUUI5ZBTWSE7QOXLUKWLTKVBI7GM X-Message-ID-Hash: GEUNGUUI5ZBTWSE7QOXLUKWLTKVBI7GM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/24] pickman: Add terminal.capture() to tests for silent output List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add terminal.capture() context manager to tests that may produce terminal output, ensuring tests run silently unless explicitly checking output content. Fix a few pyline warnings while here. Signed-off-by: Simon Glass Co-developed-by: Claude Opus 4.5 --- tools/pickman/ftest.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/pickman/ftest.py b/tools/pickman/ftest.py index e5ed187bdf6..8e3b91df750 100644 --- a/tools/pickman/ftest.py +++ b/tools/pickman/ftest.py @@ -51,7 +51,8 @@ class TestRunGit(unittest.TestCase): result = command.CommandResult(stdout=' output with spaces \n') command.TEST_RESULT = result try: - out = control.run_git(['status']) + with terminal.capture(): + out = control.run_git(['status']) self.assertEqual(out, 'output with spaces') finally: command.TEST_RESULT = None @@ -73,7 +74,8 @@ class TestCompareBranches(unittest.TestCase): command.TEST_RESULT = handle_command try: - count, commit = control.compare_branches('master', 'source') + with terminal.capture(): + count, commit = control.compare_branches('master', 'source') self.assertEqual(count, 42) self.assertEqual(commit.hash, 'abc123def456789') @@ -96,7 +98,8 @@ class TestCompareBranches(unittest.TestCase): command.TEST_RESULT = handle_command try: - count, commit = control.compare_branches('branch1', 'branch2') + with terminal.capture(): + count, commit = control.compare_branches('branch1', 'branch2') self.assertEqual(count, 0) self.assertEqual(commit.short_hash, 'def456a') @@ -1071,13 +1074,15 @@ class TestCheckAvailable(unittest.TestCase): def test_check_available_false(self): """Test check_available returns False when gitlab not installed.""" with mock.patch.object(gitlab_api, 'AVAILABLE', False): - result = gitlab_api.check_available() + with terminal.capture(): + result = gitlab_api.check_available() self.assertFalse(result) def test_check_available_true(self): """Test check_available returns True when gitlab is installed.""" with mock.patch.object(gitlab_api, 'AVAILABLE', True): - result = gitlab_api.check_available() + with terminal.capture(): + result = gitlab_api.check_available() self.assertTrue(result) @@ -1190,7 +1195,8 @@ class TestStep(unittest.TestCase): return_value=[mock_mr]): args = argparse.Namespace(cmd='step', source='us/next', remote='ci', target='master') - ret = control.do_step(args, None) + with terminal.capture(): + ret = control.do_step(args, None) self.assertEqual(ret, 0) @@ -1200,7 +1206,8 @@ class TestStep(unittest.TestCase): return_value=None): args = argparse.Namespace(cmd='step', source='us/next', remote='ci', target='master') - ret = control.do_step(args, None) + with terminal.capture(): + ret = control.do_step(args, None) self.assertEqual(ret, 1) @@ -1212,7 +1219,8 @@ class TestStep(unittest.TestCase): return_value=None): args = argparse.Namespace(cmd='step', source='us/next', remote='ci', target='master') - ret = control.do_step(args, None) + with terminal.capture(): + ret = control.do_step(args, None) self.assertEqual(ret, 1) @@ -1241,7 +1249,8 @@ class TestReview(unittest.TestCase): with mock.patch.object(gitlab_api, 'get_open_pickman_mrs', return_value=[]): args = argparse.Namespace(cmd='review', remote='ci') - ret = control.do_review(args, None) + with terminal.capture(): + ret = control.do_review(args, None) self.assertEqual(ret, 0) @@ -1250,7 +1259,8 @@ class TestReview(unittest.TestCase): with mock.patch.object(gitlab_api, 'get_open_pickman_mrs', return_value=None): args = argparse.Namespace(cmd='review', remote='ci') - ret = control.do_review(args, None) + with terminal.capture(): + ret = control.do_review(args, None) self.assertEqual(ret, 1) @@ -1287,7 +1297,7 @@ class TestPoll(unittest.TestCase): """Test poll stops gracefully on KeyboardInterrupt.""" call_count = [0] - def mock_step(args, dbs): + def mock_step(_args, _dbs): call_count[0] += 1 if call_count[0] >= 2: raise KeyboardInterrupt @@ -1299,7 +1309,8 @@ class TestPoll(unittest.TestCase): cmd='poll', source='us/next', interval=1, remote='ci', target='master' ) - ret = control.do_poll(args, None) + with terminal.capture(): + ret = control.do_poll(args, None) self.assertEqual(ret, 0) self.assertEqual(call_count[0], 2)