From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E589CC07E9A for ; Mon, 12 Jul 2021 23:57:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1012D610A7 for ; Mon, 12 Jul 2021 23:57:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1012D610A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m35nk-0003Qh-V7 for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 19:57:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m35mw-0002b4-Qp for qemu-devel@nongnu.org; Mon, 12 Jul 2021 19:56:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m35mu-0001Tx-9J for qemu-devel@nongnu.org; Mon, 12 Jul 2021 19:56:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626134194; 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: in-reply-to:in-reply-to:references:references; bh=OYCd7k09M6qVOp8M0sZaAhZZoo/aR0SDE4CMqxpwesU=; b=DlZcsKDgYpr4SVxIs1fCqLQZU6vHZ+KE6R292adRyXtE8nzexBINwptn/AbTRoE6kXSwOl 8DUlFvtMITsXITxiCBoxUz2PiN0hx3g2hiToNUC5yjJws7hpgu1JZtzW/qsjk3FcCYKsar 9kQXW71chDz4mC5uOK8XdTsXHDvoTns= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-y4Lgsf9EMNmZPgQomhlUjg-1; Mon, 12 Jul 2021 19:56:32 -0400 X-MC-Unique: y4Lgsf9EMNmZPgQomhlUjg-1 Received: by mail-oi1-f199.google.com with SMTP id l4-20020aca57040000b0290240a9d123c6so14216184oib.0 for ; Mon, 12 Jul 2021 16:56:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OYCd7k09M6qVOp8M0sZaAhZZoo/aR0SDE4CMqxpwesU=; b=hpyS92B7O/MZLGQOe9NQDb/nyOS/RCt/bsS5giAJMDW2F9ulzy//n3Y57cM+qEDfc5 WcoAQuNiYlomQpF3sSTkR8b2j4e/5qbRZ7a7sWi78SHz5uydobWTWVLGZqEweADfrCro b3vWKLpmOalmpwn0K8ycnl7TtxEQ92Kzj2E62r6OgZ6T32wRIVggNryi3/gFrXHiEkvc Q34tF3G081AIQFI86d3/9qiUTexHh3tcLSF/WxRQ/ArL8IBhTOAOjmSGORxxKaY2YpFv M7JyRxsyQKzju8VAyxupPuZjMfmx6rkK/l4dOdbLrLjTp589KKHJildrXmmw+xIoCYqO BWDw== X-Gm-Message-State: AOAM530zjz3vETi/k3/qjgN20PZlDtsbc4wJuiLWWqdMl97Mz9mAyekJ +kym3h++2n9kR4estVoTeOW02Ke7IWO8xaAZ1Ltl4UiUlQ1xYCUUjM0UOqiEy8rX7VmejLItqoa 8wB+TpaC6LovgdU0j9cO8GfyngoSIArQ= X-Received: by 2002:a9d:20a2:: with SMTP id x31mr1107487ota.263.1626134191450; Mon, 12 Jul 2021 16:56:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7y0CRxJtItgssqbYpiSWGpkKcqaAZ0psUlNdyclW/D8cer3QULzJ9rYCG1sxeEQr8vOIEZ0g5iinir/Hy2VQ= X-Received: by 2002:a9d:20a2:: with SMTP id x31mr1107474ota.263.1626134191248; Mon, 12 Jul 2021 16:56:31 -0700 (PDT) MIME-Version: 1.0 References: <20210625182021.803227-1-jsnow@redhat.com> <20210625182021.803227-8-jsnow@redhat.com> <9c281e4f-820b-71ac-b0e6-c804e442bd96@virtuozzo.com> In-Reply-To: <9c281e4f-820b-71ac-b0e6-c804e442bd96@virtuozzo.com> From: John Snow Date: Mon, 12 Jul 2021 19:56:20 -0400 Message-ID: Subject: Re: [PATCH 07/10] iotests/297: return error code from run_linters() To: Vladimir Sementsov-Ogievskiy 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-Type: multipart/alternative; boundary="000000000000d3aa0605c6f5de20" 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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, 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 , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , qemu-devel , Cleber Rosa , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000d3aa0605c6f5de20 Content-Type: text/plain; charset="UTF-8" On Tue, Jul 6, 2021 at 5:49 AM Vladimir Sementsov-Ogievskiy < vsementsov@virtuozzo.com> wrote: > 25.06.2021 21:20, John Snow wrote: > > 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 > > --- > > 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 = '.', > > env: Optional[Mapping[str, str]] = None, > > -) -> None: > > +) -> int: > > + ret = 0 > > > > print('=== pylint ===') > > sys.stdout.flush() > > > > # Todo notes are fine, but fixme's or xxx's should probably just be > > # fixed (in tests, at least) > > - subprocess.run( > > + p = subprocess.run( > > ('python3', '-m', 'pylint', '--score=n', '--notes=FIXME,XXX', > *files), > > cwd=directory, > > env=env, > > check=False, > > + universal_newlines=True, > > ) > > + ret += p.returncode > > > > print('=== mypy ===') > > sys.stdout.flush() > > @@ -113,9 +116,12 @@ def run_linters( > > universal_newlines=True > > ) > > > > + ret += p.returncode > > if p.returncode != 0: > > print(p.stdout) > > > > + return ret > > + > > > > def main() -> None: > > for linter in ('pylint-3', 'mypy'): > > > > Hmm.. > > 1. Rather unusual for a function in python to return int error-code, more > usual is raising exceptions.. > > It is strange, but I felt that if these tests were going to run in "two contexts" that I would avoid raising Exceptions and trying to understand how it would affect either call stack. > 2. making a sum of return codes looks odd to me > > Just a cheap way to state that a 0 return is good, and a non-zero return code is failure. > 3. Do we really want to run mypy if pylint failed? Maybe better not doing > it, and just switch s/check=False/check=True/ ? This way: > > I suppose we could. For the sake of CI, I like seeing more output instead of less so that you can save yourself the trouble and fix everything before re-submitting the CI job. What do you think? > 3.1 the function becomes native wrapper for subprocess.run, and raise same > exceptions > 3.2 we don't waste CI time by running mypy when pylint failed anyway > > > -- > Best regards, > Vladimir > > --000000000000d3aa0605c6f5de20 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Jul 6, 2021 at 5:49 AM Vladim= ir Sementsov-Ogievskiy <vsem= entsov@virtuozzo.com> wrote:
25.06.2021 21:20, John Snow wrote:
> This turns run_linters() into a bit of a hybrid test; returning non-ze= ro
> on failed execution while also printing diffable information. This is<= br> > done for the benefit of the avocado simple test runner, which will soo= n
> 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' vari= able.)
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>=C2=A0 =C2=A0tests/qemu-iotests/297 | 10 ++++++++--
>=C2=A0 =C2=A01 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(
>=C2=A0 =C2=A0 =C2=A0 =C2=A0files: List[str],
>=C2=A0 =C2=A0 =C2=A0 =C2=A0directory: str =3D '.',
>=C2=A0 =C2=A0 =C2=A0 =C2=A0env: Optional[Mapping[str, str]] =3D None, > -) -> None:
> +) -> int:
> +=C2=A0 =C2=A0 ret =3D 0
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0print('=3D=3D=3D pylint =3D=3D=3D')<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0sys.stdout.flush()
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0# Todo notes are fine, but fixme's or xx= x's should probably just be
>=C2=A0 =C2=A0 =C2=A0 =C2=A0# fixed (in tests, at least)
> -=C2=A0 =C2=A0 subprocess.run(
> +=C2=A0 =C2=A0 p =3D subprocess.run(
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0('python3', '-m= 9;, 'pylint', '--score=3Dn', '--notes=3DFIXME,XXX',= *files),
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cwd=3Ddirectory,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env=3Denv,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0check=3DFalse,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 universal_newlines=3DTrue,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0)
> +=C2=A0 =C2=A0 ret +=3D p.returncode
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0print('=3D=3D=3D mypy =3D=3D=3D') >=C2=A0 =C2=A0 =C2=A0 =C2=A0sys.stdout.flush()
> @@ -113,9 +116,12 @@ def run_linters(
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0universal_newlin= es=3DTrue
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)
>=C2=A0 =C2=A0
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret +=3D p.returncode
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if p.returncode !=3D 0:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0print(p.stdout)<= br> >=C2=A0 =C2=A0
> +=C2=A0 =C2=A0 return ret
> +
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0def main() -> None:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0for linter in ('pylint-3', 'mypy= '):
>

Hmm..

1. Rather unusual for a function in python to return int error-code, more u= sual is raising exceptions..


It is strange, but I felt that if thes= e tests were going to run in "two contexts" that I would avoid ra= ising Exceptions and trying to understand how it would affect either call s= tack.
=C2=A0
2. making a sum of return codes looks odd to me


Just a cheap way to state that a 0 ret= urn is good, and a non-zero return code is failure.
=C2=A0
3. Do we really want to run mypy if pylint failed? Maybe better not doing i= t, and just switch s/check=3DFalse/check=3DTrue/ ? This way:


I suppose we could. For the sake of CI= , I like seeing more output instead of less so that you can save yourself t= he trouble and fix everything before re-submitting the CI job. What do you = think?
=C2=A0
3.1 the function becomes native wrapper for subprocess.run, and raise same = exceptions
3.2 we don't waste CI time by running mypy when pylint failed anyway

--
Best regards,
Vladimir

--000000000000d3aa0605c6f5de20--