public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Pierre-Marie de Rodat <derodat@adacore.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] Introduce testsuite support to run Python tests
Date: Wed, 26 Jul 2017 16:25:00 -0000	[thread overview]
Message-ID: <1501086319.10760.56.camel@redhat.com> (raw)
In-Reply-To: <20170726160040.6516-2-derodat@adacore.com>

On Wed, 2017-07-26 at 18:00 +0200, Pierre-Marie de Rodat wrote:
[...snip...]

> diff --git a/gcc/testsuite/python/testutils.py
> b/gcc/testsuite/python/testutils.py
> new file mode 100644
> index 00000000000..503105ad9d0
> --- /dev/null
> +++ b/gcc/testsuite/python/testutils.py
> @@ -0,0 +1,45 @@
> +# Copyright (C) 2017 Free Software Foundation, 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 3 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 GCC; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +# Helpers to drive a testcase
> +
> +def print_pass(message):
> +    """Emit a PASS message.
> +
> +    :param str message: Message to emit.
> +    """
> +    print('PASS: {}'.format(message))

str.format was introduced in Python 2.6, so presumably the minimum
python 2 version here is at least 2.6+; for Python 3 I believe it was
present in Python 3.0 onwards.

> +
> +def print_fail(message):
> +    """Emit a FAIL message.
> +
> +    :param str message: Message to emit.
> +    """
> +    print('FAIL: {}'.format(message))
> +
> +
> +def check(predicate, message):
> +    """
> +    If `predicate` is True, emit a PASS message, otherwise emit a
> FAIL one.

A very nitpicky nitpick: this comment should be spelled as "is true"
(lowercase), rather than "is True" since the requirement is that
predicate's "truth value" is true, rather than predicate *is* the
boolean "True" singleton; e.g. if someone passes in an int as
predicate, its nonzero-ness would be used, rather than always being
false (since no int *is* the boolean singleton "True").

> +
> +    :param bool predicate: Whether the test should pass.
> +    :param str message: Message to emit.
> +    """
> +    if predicate:
> +        print_pass(message)
> +    else:
> +        print_fail(message)

  reply	other threads:[~2017-07-26 16:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26 16:01 [PATCH 0/2] Python testcases to check DWARF output Pierre-Marie de Rodat
2017-07-26 16:01 ` [PATCH 1/2] Introduce testsuite support to run Python tests Pierre-Marie de Rodat
2017-07-26 16:25   ` David Malcolm [this message]
2017-07-26 16:35     ` Pierre-Marie de Rodat
2017-07-26 16:48       ` David Malcolm
2017-07-27  8:49         ` Pierre-Marie de Rodat
2017-07-27 13:40           ` David Malcolm
2017-08-02 18:43         ` Jeff Law
2017-08-03  8:27           ` Pierre-Marie de Rodat
2017-07-27  8:50   ` Matthias Klose
2017-07-27 10:09     ` Pierre-Marie de Rodat
2017-07-26 16:01 ` [PATCH 2/2] Introduce Python testcases to check DWARF output Pierre-Marie de Rodat
2017-07-26 17:10   ` David Malcolm
2017-07-27  8:59     ` Pierre-Marie de Rodat
2017-07-27  8:36   ` Richard Biener
2017-07-27 10:09     ` Pierre-Marie de Rodat
2017-07-26 16:16 ` [PATCH 0/2] " David Malcolm
2017-07-26 16:26   ` Pierre-Marie de Rodat
2017-07-26 21:25 ` Mike Stump
2017-07-27  7:52   ` Richard Biener
2017-07-27  9:09     ` Pierre-Marie de Rodat
2017-08-03 22:23       ` Mike Stump
2017-08-06 14:35         ` Iain Buclaw
2017-08-02 15:44     ` Jeff Law
2017-08-02 15:43 ` Jeff Law
2017-08-03  8:27   ` Pierre-Marie de Rodat
2017-08-03 16:13     ` Jeff Law

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=1501086319.10760.56.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).