From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645500622195.8469235866719; Fri, 25 Jun 2021 11:25:00 -0700 (PDT) Received: from localhost ([::1]:36136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqVf-0003mY-6h for importer@patchew.org; Fri, 25 Jun 2021 14:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRU-0003pg-CQ for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRL-0005dx-EQ for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-pWXe5S-LPjm9KHi97lSbtg-1; Fri, 25 Jun 2021 14:20:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46668800D62; Fri, 25 Jun 2021 18:20:28 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id B41585D9C6; Fri, 25 Jun 2021 18:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=am/0gdEOxqcd8xXgJhMYqAsk3E79a1Bp5ocdzcBRkBU=; b=WR3KpKfSNa7fSwy/2/iyw8prVveZ5GDXuyhq82SSQryvbh3CxrG7X8yYnNdpPqH7fRfjnm zafi3QJI39nEpCsaGg98VPjOejh66QDkYBd41cBXNarBq1DJXt89ctRbMr+rsXnrXg7PN+ Wz8dHnda9A6eGApYCalwA3gST8Ls2Tg= X-MC-Unique: pWXe5S-LPjm9KHi97lSbtg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/10] iotests/297: modify is_python_file to work from any CWD Date: Fri, 25 Jun 2021 14:20:12 -0400 Message-Id: <20210625182021.803227-2-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a directory argument to is_python_file to allow it to work correctly no matter what CWD we happen to run it from. This is done in anticipation of running the iotests from another directory (./python/). Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 433b732336..493dda17fb 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -39,14 +39,16 @@ SKIP_FILES =3D ( ) =20 =20 -def is_python_file(filename): - if not os.path.isfile(filename): +def is_python_file(filename: str, directory: str =3D '.') -> bool: + filepath =3D os.path.join(directory, filename) + + if not os.path.isfile(filepath): return False =20 if filename.endswith('.py'): return True =20 - with open(filename) as f: + with open(filepath) as f: try: first_line =3D f.readline() return re.match('^#!.*python', first_line) is not None --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645650865140.20528012734667; Fri, 25 Jun 2021 11:27:30 -0700 (PDT) Received: from localhost ([::1]:42728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqY6-0008Eu-4J for importer@patchew.org; Fri, 25 Jun 2021 14:27:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRV-0003ry-O8 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRM-0005f0-O5 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-KXaZ3oQvMR6QtfGlgjbRRw-1; Fri, 25 Jun 2021 14:20:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7285918A0733; Fri, 25 Jun 2021 18:20:29 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CF8D5D9C6; Fri, 25 Jun 2021 18:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mame4HQPDWbV868hCi4po3XFIQyBxQT18b4NcI6B/5g=; b=WmIvEn4kJFQc5d9PyKA2CbR5wg8w9cUyUzcgNW02rRucvDSHnIhekaqPtL272p/fs4KADo gi7R0D4u/AyrWyRBgUG8NMIYJt1rjwAPXp77JzRIRcjLjQxKX2jOaOspGyVUKSdRfywqUt ki3enqwvY2jSJj0lq3cf8XjEQUQMGp0= X-MC-Unique: KXaZ3oQvMR6QtfGlgjbRRw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/10] iotests/297: Add get_files() function Date: Fri, 25 Jun 2021 14:20:13 -0400 Message-Id: <20210625182021.803227-3-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Split out file discovery into its own method to begin separating out the "environment setup" and "test execution" phases. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 493dda17fb..0bc1195805 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -21,6 +21,7 @@ import re import shutil import subprocess import sys +from typing import List =20 import iotests =20 @@ -56,9 +57,15 @@ def is_python_file(filename: str, directory: str =3D '.'= ) -> bool: return False =20 =20 +def get_test_files(directory: str =3D '.') -> List[str]: + return [ + f for f in (set(os.listdir(directory)) - set(SKIP_FILES)) + if is_python_file(f, directory) + ] + + def run_linters(): - files =3D [filename for filename in (set(os.listdir('.')) - set(SKIP_F= ILES)) - if is_python_file(filename)] + files =3D get_test_files() =20 iotests.logger.debug('Files to be checked:') iotests.logger.debug(', '.join(sorted(files))) --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645401070250.393514994822; Fri, 25 Jun 2021 11:23:21 -0700 (PDT) Received: from localhost ([::1]:56066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqU4-0006k4-7X for importer@patchew.org; Fri, 25 Jun 2021 14:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRc-0003x2-F7 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRR-0005h5-Ee for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-7w7LHbv6NUKOpJ5I-OShOA-1; Fri, 25 Jun 2021 14:20:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0063800D62; Fri, 25 Jun 2021 18:20:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 898D55D9C6; Fri, 25 Jun 2021 18:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wb9NB4SkrkvqqM3I/jv+E6tPsJn0M3ulgHiFWY0OeXg=; b=J6IGLIHdcFv6z/iT305e+lG+y76zZths+hRRVdzMFF+6mV/XFxw2BQSrqHP8ltowqNUE+q 55EqGQ1fI7HHQdcH6p605N9BkqnG8cYjlEU4eBtvMhWrGDM+TcwVQHgb28oTEXpxQ1vp0R AtDtCgPcEQl28aXIcPtXNSofdVFaP3A= X-MC-Unique: 7w7LHbv6NUKOpJ5I-OShOA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/10] iotests/297: Don't rely on distro-specific linter binaries Date: Fri, 25 Jun 2021 14:20:14 -0400 Message-Id: <20210625182021.803227-4-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 'pylint-3' is another Fedora-ism. Use "python3 -m pylint" or "python3 -m mypy" to access these scripts instead. This style of invocation will prefer the "correct" tool when run in a virtual environment. Note that we still check for "pylint-3" before the test begins -- this check is now "overly strict", but shouldn't cause anything that was already running correctly to start failing. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 45 ++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 0bc1195805..43af361622 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -82,8 +82,11 @@ def run_linters(): env['PYTHONPATH'] +=3D os.pathsep + qemu_module_path except KeyError: env['PYTHONPATH'] =3D qemu_module_path - subprocess.run(('pylint-3', '--score=3Dn', '--notes=3DFIXME,XXX', *fil= es), - env=3Denv, check=3DFalse) + subprocess.run( + ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), + env=3Denv, + check=3DFalse, + ) =20 print('=3D=3D=3D mypy =3D=3D=3D') sys.stdout.flush() @@ -94,23 +97,27 @@ def run_linters(): # must not both define the __main__ module). env['MYPYPATH'] =3D env['PYTHONPATH'] for filename in files: - p =3D subprocess.run(('mypy', - '--warn-unused-configs', - '--disallow-subclassing-any', - '--disallow-any-generics', - '--disallow-incomplete-defs', - '--disallow-untyped-decorators', - '--no-implicit-optional', - '--warn-redundant-casts', - '--warn-unused-ignores', - '--no-implicit-reexport', - '--namespace-packages', - filename), - env=3Denv, - check=3DFalse, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT, - universal_newlines=3DTrue) + p =3D subprocess.run( + ( + 'python3', '-m', 'mypy', + '--warn-unused-configs', + '--disallow-subclassing-any', + '--disallow-any-generics', + '--disallow-incomplete-defs', + '--disallow-untyped-decorators', + '--no-implicit-optional', + '--warn-redundant-casts', + '--warn-unused-ignores', + '--no-implicit-reexport', + '--namespace-packages', + filename, + ), + env=3Denv, + check=3DFalse, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + universal_newlines=3DTrue + ) =20 if p.returncode !=3D 0: print(p.stdout) --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645398705998.5053181624653; Fri, 25 Jun 2021 11:23:18 -0700 (PDT) Received: from localhost ([::1]:55890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqU1-0006dD-Pg for importer@patchew.org; Fri, 25 Jun 2021 14:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRT-0003nz-5V for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRR-0005gy-Du for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-45dHnK7iPr29DA-KwBD3LQ-1; Fri, 25 Jun 2021 14:20:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC5C6EC1A5; Fri, 25 Jun 2021 18:20:32 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 069225D9C6; Fri, 25 Jun 2021 18:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0jX7yk0O1NPPE3uaqh1423z/2OzDLkTkDu67rmIolag=; b=MbILGq8GgDNg23m2v1efxXbxx7balt7qCY68O3VgfpzRfBk4sg52/bF2mrDPLr/cWOefo2 Q0SqRGgKZJ33BvGNB/l/s5Oewf55kdDs6Fa3w12v2WvP1GKN8SwIxoFh0RHq6aPzX0+oGk vwtnbWnwG4MoBnUDSacGRk7AsLXgpN4= X-MC-Unique: 45dHnK7iPr29DA-KwBD3LQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/10] iotests/297: Create main() function Date: Fri, 25 Jun 2021 14:20:15 -0400 Message-Id: <20210625182021.803227-5-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of running "run_linters" directly, create a main() function that will be responsible for environment setup, leaving run_linters() responsible only for execution of the linters. (That environment setup will be moved over in forthcoming commits.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 43af361622..f35687d021 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -123,8 +123,12 @@ def run_linters(): print(p.stdout) =20 =20 -for linter in ('pylint-3', 'mypy'): - if shutil.which(linter) is None: - iotests.notrun(f'{linter} not found') +def main() -> None: + for linter in ('pylint-3', 'mypy'): + if shutil.which(linter) is None: + iotests.notrun(f'{linter} not found') =20 -iotests.script_main(run_linters) + run_linters() + + +iotests.script_main(main) --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645505474652.4998558728456; Fri, 25 Jun 2021 11:25:05 -0700 (PDT) Received: from localhost ([::1]:36176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqVj-0003o6-0D for importer@patchew.org; Fri, 25 Jun 2021 14:25:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRU-0003q5-Lq for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRR-0005hD-EQ for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-7fasYH_APsWqVOsH4vgs2Q-1; Fri, 25 Jun 2021 14:20:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B314804144; Fri, 25 Jun 2021 18:20:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DEA55D9C6; Fri, 25 Jun 2021 18:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VsK8NJ5U2WqLbHkco10ewQdZb4ZPMCWjJRMdS+ZEPvo=; b=YYc+AEe3pHXwfVk0YHJgbzNTYes3wawrcDvaH3Xaz2ClPoKfcYAQWJ/SvcRRc9x73wAHE7 Kg5SpEyEtZwpicvDWk2mL7MEdZr32K49/6Qmi30R0EKmtRAMMTqwKcUj0PGp4+JHuz+Loz UYsm/TDfWPoUzJe5ixwYfi2s7FhsJAc= X-MC-Unique: 7fasYH_APsWqVOsH4vgs2Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/10] iotests/297: Separate environment setup from test execution Date: Fri, 25 Jun 2021 14:20:16 -0400 Message-Id: <20210625182021.803227-6-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Move environment setup into main(), leaving pure test execution behind in run_linters(). Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index f35687d021..c7428af901 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -21,7 +21,7 @@ import re import shutil import subprocess import sys -from typing import List +from typing import List, Mapping, Optional =20 import iotests =20 @@ -64,24 +64,16 @@ def get_test_files(directory: str =3D '.') -> List[str]: ] =20 =20 -def run_linters(): - files =3D get_test_files() - - iotests.logger.debug('Files to be checked:') - iotests.logger.debug(', '.join(sorted(files))) +def run_linters( + files: List[str], + env: Optional[Mapping[str, str]] =3D None, +) -> None: =20 print('=3D=3D=3D pylint =3D=3D=3D') sys.stdout.flush() =20 # Todo notes are fine, but fixme's or xxx's should probably just be # fixed (in tests, at least) - env =3D os.environ.copy() - qemu_module_path =3D os.path.join(os.path.dirname(__file__), - '..', '..', 'python') - try: - env['PYTHONPATH'] +=3D os.pathsep + qemu_module_path - except KeyError: - env['PYTHONPATH'] =3D qemu_module_path subprocess.run( ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), env=3Denv, @@ -95,7 +87,6 @@ def run_linters(): # will interpret all given files as belonging together (i.e., they # may not both define the same classes, etc.; most notably, they # must not both define the __main__ module). - env['MYPYPATH'] =3D env['PYTHONPATH'] for filename in files: p =3D subprocess.run( ( @@ -128,7 +119,22 @@ def main() -> None: if shutil.which(linter) is None: iotests.notrun(f'{linter} not found') =20 - run_linters() + files =3D get_test_files() + + iotests.logger.debug('Files to be checked:') + iotests.logger.debug(', '.join(sorted(files))) + + env =3D os.environ.copy() + qemu_module_path =3D os.path.join(os.path.dirname(__file__), + '..', '..', 'python') + try: + env['PYTHONPATH'] +=3D os.pathsep + qemu_module_path + except KeyError: + env['PYTHONPATH'] =3D qemu_module_path + + env['MYPYPATH'] =3D env['PYTHONPATH'] + + run_linters(files, env=3Denv) =20 =20 iotests.script_main(main) --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645412691797.43715833329; Fri, 25 Jun 2021 11:23:32 -0700 (PDT) Received: from localhost ([::1]:57220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqUF-0007Uy-Tw for importer@patchew.org; Fri, 25 Jun 2021 14:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRe-0003xc-59 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRT-0005ha-9r for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-8sIwZ6GNPyiTQ4Ga3g7uDg-1; Fri, 25 Jun 2021 14:20:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53DCE804140; Fri, 25 Jun 2021 18:20:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0CDE5D9C6; Fri, 25 Jun 2021 18:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oDs5v73CsCtSj2btPaaa4wMqzX5hjh/DRcfmw1iqoD8=; b=LJgZXvKI13yBecGsOhUQXVhXAk8Nr7n3PM2pOXIRMvJBmf/NaGajjweIMxSkD8FSf6E9ST BEMR5Gwb4vdU/XSgDmsatzQHRdrZYDutqmx60NvWaClus0NpBcRujGF4CGw3AxMPUnu32q Om04VNRdls81VBk9mbrwROvt1s/4PGs= X-MC-Unique: 8sIwZ6GNPyiTQ4Ga3g7uDg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/10] iotests/297: Add 'directory' argument to run_linters Date: Fri, 25 Jun 2021 14:20:17 -0400 Message-Id: <20210625182021.803227-7-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Allow run_linters to work well if it's executed from a different directory. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index c7428af901..1e8334d1d4 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -66,6 +66,7 @@ def get_test_files(directory: str =3D '.') -> List[str]: =20 def run_linters( files: List[str], + directory: str =3D '.', env: Optional[Mapping[str, str]] =3D None, ) -> None: =20 @@ -76,6 +77,7 @@ def run_linters( # fixed (in tests, at least) subprocess.run( ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), + cwd=3Ddirectory, env=3Denv, check=3DFalse, ) @@ -103,6 +105,7 @@ def run_linters( '--namespace-packages', filename, ), + cwd=3Ddirectory, env=3Denv, check=3DFalse, stdout=3Dsubprocess.PIPE, --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645655779820.9078900203851; Fri, 25 Jun 2021 11:27:35 -0700 (PDT) Received: from localhost ([::1]:43086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqYB-0008Tc-2s for importer@patchew.org; Fri, 25 Jun 2021 14:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRj-0003yz-3m for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRY-0005kF-2o for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-509-J9MCMCOKOpq2FRw_PlSxcQ-1; Fri, 25 Jun 2021 14:20:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 760FD100C618; Fri, 25 Jun 2021 18:20:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D9E45D9C6; Fri, 25 Jun 2021 18:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z8uSIxi5rAOVWnauFYWfs9lVeBg1hNx6H6z3MJHiOug=; b=BSk8VQOIiCnWS6KsxAu9gdqDAfrRHSxe/IzG5Ax7sTg5ac7gh7K31EbVv72sNkhK4LL7vm W2e45vtp1s64Ay2kAU8BgjSIeIrBcxjRyBYfBqvyalao2TfZAXxWHUS0WngxXykBn6KbLu esV+kD+y5mf/GdXAW8ikfXvHDqoZQ2E= X-MC-Unique: J9MCMCOKOpq2FRw_PlSxcQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/10] iotests/297: return error code from run_linters() Date: Fri, 25 Jun 2021 14:20:18 -0400 Message-Id: <20210625182021.803227-8-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This turns run_linters() into a bit of a hybrid test; returning non-zero on failed execution while also printing diffable information. This is done for the benefit of the avocado simple test runner, which will soon be attempting to execute this test from a different environment. (Note: universal_newlines is added to the pylint invocation for type consistency with the mypy run -- it's not strictly necessary, but it avoids some typing errors caused by our re-use of the 'p' variable.) Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 1e8334d1d4..7db1f9ed45 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -68,19 +68,22 @@ def run_linters( files: List[str], directory: str =3D '.', env: Optional[Mapping[str, str]] =3D None, -) -> None: +) -> int: + ret =3D 0 =20 print('=3D=3D=3D pylint =3D=3D=3D') sys.stdout.flush() =20 # Todo notes are fine, but fixme's or xxx's should probably just be # fixed (in tests, at least) - subprocess.run( + p =3D subprocess.run( ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), cwd=3Ddirectory, env=3Denv, check=3DFalse, + universal_newlines=3DTrue, ) + ret +=3D p.returncode =20 print('=3D=3D=3D mypy =3D=3D=3D') sys.stdout.flush() @@ -113,9 +116,12 @@ def run_linters( universal_newlines=3DTrue ) =20 + ret +=3D p.returncode if p.returncode !=3D 0: print(p.stdout) =20 + return ret + =20 def main() -> None: for linter in ('pylint-3', 'mypy'): --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162464551583826.341298517509472; Fri, 25 Jun 2021 11:25:15 -0700 (PDT) Received: from localhost ([::1]:36472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqVv-00041Q-3T for importer@patchew.org; Fri, 25 Jun 2021 14:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRh-0003yW-Ok for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRW-0005k7-7T for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:20:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-FE4WMexFPlqVc1v-khWlCQ-1; Fri, 25 Jun 2021 14:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94C9E804145; Fri, 25 Jun 2021 18:20:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D52F5D9C6; Fri, 25 Jun 2021 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wo36FDWzF1MYo7jlo158g+uIjoUi1gGo4HT6fgSn9OM=; b=IhNOQTsbdPBlVm4D0r7+8685onu/Fm1YwIZypvvQFCLB6ErX0HqtWigT9o5GIgQl5ou8m5 ++8mOfJ57+XZ/jQL1OGd7I8fpimTcItW0NSzDE63h3VGLSyahwCDsju0b/M6Xw/FSlzrfW Acc2OxD9FJAP9OIlcOpmWXAlzblDINE= X-MC-Unique: FE4WMexFPlqVc1v-khWlCQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/10] iotests/297: split linters.py off from 297 Date: Fri, 25 Jun 2021 14:20:19 -0400 Message-Id: <20210625182021.803227-9-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Split the linter execution itself out from 297, leaving just environment setup in 297. This is done so that non-iotest code can invoke the linters without needing to worry about imports of unpackaged iotest code. Eventually, it should be possible to replace linters.py with mypy.ini and pylintrc files that instruct these tools how to run properly in this directory, but ... not yet, and not in this series. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/297 | 105 ++---------------------------- tests/qemu-iotests/linters.py | 117 ++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 101 deletions(-) create mode 100755 tests/qemu-iotests/linters.py diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 index 7db1f9ed45..3d29af5b78 100755 --- a/tests/qemu-iotests/297 +++ b/tests/qemu-iotests/297 @@ -17,110 +17,13 @@ # along with this program. If not, see . =20 import os -import re import shutil -import subprocess -import sys -from typing import List, Mapping, Optional =20 import iotests +import linters =20 =20 -# TODO: Empty this list! -SKIP_FILES =3D ( - '030', '040', '041', '044', '045', '055', '056', '057', '065', '093', - '096', '118', '124', '132', '136', '139', '147', '148', '149', - '151', '152', '155', '163', '165', '169', '194', '196', '199', '202', - '203', '205', '206', '207', '208', '210', '211', '212', '213', '216', - '218', '219', '222', '224', '228', '234', '235', '236', '237', '238', - '240', '242', '245', '246', '248', '255', '256', '257', '258', '260', - '262', '264', '266', '274', '277', '280', '281', '295', '296', '298', - '299', '302', '303', '304', '307', - 'nbd-fault-injector.py', 'qcow2.py', 'qcow2_format.py', 'qed.py' -) - - -def is_python_file(filename: str, directory: str =3D '.') -> bool: - filepath =3D os.path.join(directory, filename) - - if not os.path.isfile(filepath): - return False - - if filename.endswith('.py'): - return True - - with open(filepath) as f: - try: - first_line =3D f.readline() - return re.match('^#!.*python', first_line) is not None - except UnicodeDecodeError: # Ignore binary files - return False - - -def get_test_files(directory: str =3D '.') -> List[str]: - return [ - f for f in (set(os.listdir(directory)) - set(SKIP_FILES)) - if is_python_file(f, directory) - ] - - -def run_linters( - files: List[str], - directory: str =3D '.', - env: Optional[Mapping[str, str]] =3D None, -) -> int: - ret =3D 0 - - print('=3D=3D=3D pylint =3D=3D=3D') - sys.stdout.flush() - - # Todo notes are fine, but fixme's or xxx's should probably just be - # fixed (in tests, at least) - p =3D subprocess.run( - ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), - cwd=3Ddirectory, - env=3Denv, - check=3DFalse, - universal_newlines=3DTrue, - ) - ret +=3D p.returncode - - print('=3D=3D=3D mypy =3D=3D=3D') - sys.stdout.flush() - - # We have to call mypy separately for each file. Otherwise, it - # will interpret all given files as belonging together (i.e., they - # may not both define the same classes, etc.; most notably, they - # must not both define the __main__ module). - for filename in files: - p =3D subprocess.run( - ( - 'python3', '-m', 'mypy', - '--warn-unused-configs', - '--disallow-subclassing-any', - '--disallow-any-generics', - '--disallow-incomplete-defs', - '--disallow-untyped-decorators', - '--no-implicit-optional', - '--warn-redundant-casts', - '--warn-unused-ignores', - '--no-implicit-reexport', - '--namespace-packages', - filename, - ), - cwd=3Ddirectory, - env=3Denv, - check=3DFalse, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT, - universal_newlines=3DTrue - ) - - ret +=3D p.returncode - if p.returncode !=3D 0: - print(p.stdout) - - return ret +# Looking for the list of excluded tests? See linters.py ! =20 =20 def main() -> None: @@ -128,7 +31,7 @@ def main() -> None: if shutil.which(linter) is None: iotests.notrun(f'{linter} not found') =20 - files =3D get_test_files() + files =3D linters.get_test_files() =20 iotests.logger.debug('Files to be checked:') iotests.logger.debug(', '.join(sorted(files))) @@ -143,7 +46,7 @@ def main() -> None: =20 env['MYPYPATH'] =3D env['PYTHONPATH'] =20 - run_linters(files, env=3Denv) + linters.run_linters(files, env=3Denv) =20 =20 iotests.script_main(main) diff --git a/tests/qemu-iotests/linters.py b/tests/qemu-iotests/linters.py new file mode 100755 index 0000000000..6fa7ba2d22 --- /dev/null +++ b/tests/qemu-iotests/linters.py @@ -0,0 +1,117 @@ +# Copyright (C) 2020 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import re +import subprocess +import sys +from typing import List, Mapping, Optional + + +# TODO: Empty this list! +SKIP_FILES =3D ( + '030', '040', '041', '044', '045', '055', '056', '057', '065', '093', + '096', '118', '124', '132', '136', '139', '147', '148', '149', + '151', '152', '155', '163', '165', '169', '194', '196', '199', '202', + '203', '205', '206', '207', '208', '210', '211', '212', '213', '216', + '218', '219', '222', '224', '228', '234', '235', '236', '237', '238', + '240', '242', '245', '246', '248', '255', '256', '257', '258', '260', + '262', '264', '266', '274', '277', '280', '281', '295', '296', '298', + '299', '302', '303', '304', '307', + 'nbd-fault-injector.py', 'qcow2.py', 'qcow2_format.py', 'qed.py' +) + + +def is_python_file(filename: str, directory: str =3D '.') -> bool: + filepath =3D os.path.join(directory, filename) + + if not os.path.isfile(filepath): + return False + + if filename.endswith('.py'): + return True + + with open(filepath) as f: + try: + first_line =3D f.readline() + return re.match('^#!.*python', first_line) is not None + except UnicodeDecodeError: # Ignore binary files + return False + + +def get_test_files(directory: str =3D '.') -> List[str]: + return [ + f for f in (set(os.listdir(directory)) - set(SKIP_FILES)) + if is_python_file(f, directory) + ] + + +def run_linters( + files: List[str], + directory: str =3D '.', + env: Optional[Mapping[str, str]] =3D None, +) -> int: + ret =3D 0 + + print('=3D=3D=3D pylint =3D=3D=3D') + sys.stdout.flush() + + # Todo notes are fine, but fixme's or xxx's should probably just be + # fixed (in tests, at least) + p =3D subprocess.run( + ('python3', '-m', 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX', = *files), + cwd=3Ddirectory, + env=3Denv, + check=3DFalse, + universal_newlines=3DTrue, + ) + ret +=3D p.returncode + + print('=3D=3D=3D mypy =3D=3D=3D') + sys.stdout.flush() + + # We have to call mypy separately for each file. Otherwise, it + # will interpret all given files as belonging together (i.e., they + # may not both define the same classes, etc.; most notably, they + # must not both define the __main__ module). + for filename in files: + p =3D subprocess.run( + ( + 'python3', '-m', 'mypy', + '--warn-unused-configs', + '--disallow-subclassing-any', + '--disallow-any-generics', + '--disallow-incomplete-defs', + '--disallow-untyped-decorators', + '--no-implicit-optional', + '--warn-redundant-casts', + '--warn-unused-ignores', + '--no-implicit-reexport', + '--namespace-packages', + filename, + ), + cwd=3Ddirectory, + env=3Denv, + check=3DFalse, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + universal_newlines=3DTrue + ) + + ret +=3D p.returncode + if p.returncode !=3D 0: + print(p.stdout) + + return ret --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16246456580721002.8699824410123; Fri, 25 Jun 2021 11:27:38 -0700 (PDT) Received: from localhost ([::1]:43366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqYD-0000DQ-BD for importer@patchew.org; Fri, 25 Jun 2021 14:27:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRo-00043v-Si for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:21:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRY-0005kU-3T for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:21:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-zuQTsIxsOBCnK71QaMRs9Q-1; Fri, 25 Jun 2021 14:20:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3641100C611; Fri, 25 Jun 2021 18:20:39 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB1705D9C6; Fri, 25 Jun 2021 18:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8i8xinDtZ6m5roDKOuknYSg2NFaliuXZZJDWKqJlH+Q=; b=b5LCOoaJTsw95r0kL0/+ZmUeGDVk/vWdPcbpRyRcA319W2+SRiDK3oYFLV3odKIRZWJc2l up7tpgUS+2Nqz9zOH1e9iYykMLjrFzBuIGSkaISpxr2dle9qsINvRKJPaGucZ87KXFgYMO oVcJEhrvA/ok71cdAIiY0vWVHzJpN6k= X-MC-Unique: zuQTsIxsOBCnK71QaMRs9Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/10] iotests/linters: Add entry point for Python CI linters Date: Fri, 25 Jun 2021 14:20:20 -0400 Message-Id: <20210625182021.803227-10-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a main() function to linters.py so that the Python CI infrastructure has something it can run. Now, linters.py represents an invocation of the linting scripts that more resembles a "normal" execution of pylint/mypy, like you'd expect to use if 'qemu' was a bona-fide package you obtained from PyPI. 297, by contrast, now represents the iotests-specific configuration bits you need to get it to function correctly as a part of iotests, and with 'qemu' as a namespace package that isn't "installed" to the current environment, but just lives elsewhere in our source tree. By doing this, we will able to run the same linting configuration from the Python CI tests without calling iotest logging functions or messing around with PYTHONPATH / MYPYPATH. iotest 297 continues to operate in a standalone fashion for now -- presumably, it's convenient for block maintainers and contributors to run in this manner. See the following commit for how this is used from the Python packaging sid= e. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/linters.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qemu-iotests/linters.py b/tests/qemu-iotests/linters.py index 6fa7ba2d22..1bbcfd1088 100755 --- a/tests/qemu-iotests/linters.py +++ b/tests/qemu-iotests/linters.py @@ -115,3 +115,16 @@ def run_linters( print(p.stdout) =20 return ret + + +def main() -> int: + """ + Used by the Python CI system as an entry point to run these linters. + """ + directory =3D os.path.dirname(os.path.realpath(__file__)) + files =3D get_test_files(directory) + return run_linters(files, directory) + + +if __name__ =3D=3D '__main__': + sys.exit(main()) --=20 2.31.1 From nobody Sat May 18 19:47:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624645811034613.1806936007025; Fri, 25 Jun 2021 11:30:11 -0700 (PDT) Received: from localhost ([::1]:50978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwqaf-0005IJ-Ky for importer@patchew.org; Fri, 25 Jun 2021 14:30:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRo-000432-Gw for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:21:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwqRY-0005mu-4S for qemu-devel@nongnu.org; Fri, 25 Jun 2021 14:21:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-whR5dDSdMoaOh6VInRICdQ-1; Fri, 25 Jun 2021 14:20:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF13510C1ADC; Fri, 25 Jun 2021 18:20:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8A915D9C6; Fri, 25 Jun 2021 18:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624645243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aAOB/E5CPaLjPwAcFGN/NLfEOV/TwQV7VnVyCc7I0nw=; b=SUhbVx1+GecB4j4nN2U5sYBSDRFx+d+4ImGsCk6z5MOh8dpdN7qF9yfRgZG7O3ssskqxXH YH4n5G6SLPNgFbWZu2BIUYIrOa/jPCqAS12oS9XbtP3RNn4ePWzqu182Wu+OYtVVq/hg/d pHPPTljHxt3qx+/2DGHoSyA8FkGcqiA= X-MC-Unique: whR5dDSdMoaOh6VInRICdQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/10] python: Add iotest linters to test suite Date: Fri, 25 Jun 2021 14:20:21 -0400 Message-Id: <20210625182021.803227-11-jsnow@redhat.com> In-Reply-To: <20210625182021.803227-1-jsnow@redhat.com> References: <20210625182021.803227-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Cleber Rosa , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As a convenience, since iotests is an extremely prominent user of the qemu.qmp and qemu.machine packages and already implements a linting regime, run those tests as well so that it's very hard to miss regressions caused by changes to the python library. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- python/tests/iotests.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 python/tests/iotests.sh diff --git a/python/tests/iotests.sh b/python/tests/iotests.sh new file mode 100755 index 0000000000..ec2fc58066 --- /dev/null +++ b/python/tests/iotests.sh @@ -0,0 +1,2 @@ +#!/bin/sh -e +PYTHONPATH=3D../tests/qemu-iotests/ python3 -m linters --=20 2.31.1