qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v2 1/8] iotests/297: Allow checking all Python test files
Date: Wed, 13 Jan 2021 13:01:00 -0600	[thread overview]
Message-ID: <b2f9c75d-0753-32f0-a540-58d93aac050d@redhat.com> (raw)
In-Reply-To: <20210113175752.403022-2-mreitz@redhat.com>

On 1/13/21 11:57 AM, Max Reitz wrote:
> I.e., all Python files in the qemu-iotests/ directory.
> 
> Most files of course do not pass, so there is an extensive skip list for
> now.  (The only files that do pass are 209, 254, 283, and iotests.py.)
> 
> (Alternatively, we could have the opposite, i.e. an explicit list of
> files that we do want to check, but I think it is better to check files
> by default.)

Concur with the choice for default.

> 
> I decided to include the list of files checked in the reference output,
> so we do not accidentally lose coverage of anything.  That means adding
> new Python tests will require a change to 297.out, but that should not
> be a problem.

I'm okay with that.

> 
> On the other hand, I decided to hide mypy's "Success" lines from the
> reference output, because they do not add anything useful.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/297     | 66 ++++++++++++++++++++++++++++++++++----
>  tests/qemu-iotests/297.out |  6 +++-
>  2 files changed, 65 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
> index 5c5420712b..b1a7d6d5e8 100755
> --- a/tests/qemu-iotests/297
> +++ b/tests/qemu-iotests/297
> @@ -30,13 +30,67 @@ if ! type -p "mypy" > /dev/null; then
>      _notrun "mypy not found"
>  fi
>  
> -pylint-3 --score=n iotests.py
> +# TODO: Empty this list!

:)


> +file_list=()
> +for file in *; do
> +    # Check files with a .py extension or a Python shebang
> +    # (Unless they are in the skip_files list)
> +    if [ -f "$file" ] && ((echo "$file" | grep -q '\.py$') ||
> +                          (head -n 1 "$file" | grep -q '^#!.*python'))

Bash has an (obsolete) operator (()) (behaves like a mix of $(()) and
'if'); when nesting subshells, POSIX recommends inserting a space to
avoid inadvertent triggering of the alternate semantics of the operator.
 But why do you need nested subshells?  This is equivalent:

if [ -f "$file" ] && (echo  "$file" | grep -q '\.py$' ||
                      head -n 1 "$file" | grep -q '^#!.*python')

> +    then
> +        skip_file=false
> +        for skip in "${skip_files[@]}"; do

bashism, but iotests require bash, so fine.

> +            if [ "$skip" = "$file" ]; then
> +                skip_file=true
> +                break
> +            fi
> +        done
> +
> +        if ! $skip_file; then
> +            file_list+=("$file")

Likewise.

Whether or not you strip the extra (),
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2021-01-13 19:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 17:57 [PATCH v2 0/8] iotests: Fix 129 and expand 297’s reach Max Reitz
2021-01-13 17:57 ` [PATCH v2 1/8] iotests/297: Allow checking all Python test files Max Reitz
2021-01-13 19:01   ` Eric Blake [this message]
2021-01-14  9:23     ` Max Reitz
2021-01-13 19:27   ` Vladimir Sementsov-Ogievskiy
2021-01-13 20:28     ` Vladimir Sementsov-Ogievskiy
2021-01-14  9:31       ` Max Reitz
2021-01-14 10:53         ` Vladimir Sementsov-Ogievskiy
2021-01-14  9:27     ` Max Reitz
2021-01-13 17:57 ` [PATCH v2 2/8] iotests: Move try_remove to iotests.py Max Reitz
2021-01-13 19:28   ` Vladimir Sementsov-Ogievskiy
2021-01-13 17:57 ` [PATCH v2 3/8] iotests/129: Remove test images in tearDown() Max Reitz
2021-01-13 17:57 ` [PATCH v2 4/8] iotests/129: Do not check @busy Max Reitz
2021-01-13 17:57 ` [PATCH v2 5/8] iotests/129: Use throttle node Max Reitz
2021-01-13 19:02   ` Eric Blake
2021-01-13 20:33   ` Vladimir Sementsov-Ogievskiy
2021-01-13 17:57 ` [PATCH v2 6/8] iotests/129: Actually test a commit job Max Reitz
2021-01-13 17:57 ` [PATCH v2 7/8] iotests/129: Limit mirror job's buffer size Max Reitz
2021-01-13 17:57 ` [PATCH v2 8/8] iotests/129: Clean up pylint and mypy complaints Max Reitz
2021-01-13 19:04   ` Eric Blake
2021-01-13 20:38   ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2f9c75d-0753-32f0-a540-58d93aac050d@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).