From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@vger.kernel.org
Subject: Re: [PATCH] semanage/test-semanage.py: Return non-zero value when some of unittest tests fail
Date: Wed, 13 May 2020 17:10:03 +0200 [thread overview]
Message-ID: <20200513151003.GA184087@workstation> (raw)
In-Reply-To: <20200511112308.23523-1-plautrba@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2122 bytes --]
On Mon, May 11, 2020 at 01:23:08PM +0200, Petr Lautrbach wrote:
> Previously python/semanage/test-semanage.py returned 0 even when there was a
> fail in some test and `make test` didn't indicate any problem.
>
> Fixes:
> $ make test
> ...
> Ran 10 tests in 110.854s
> FAILED (failures=4)
> $ echo $?
> 0
>
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
> Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Applied.
> ---
> python/semanage/test-semanage.py | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/python/semanage/test-semanage.py b/python/semanage/test-semanage.py
> index c8f6ec231fc2..d99e3fdaa211 100644
> --- a/python/semanage/test-semanage.py
> +++ b/python/semanage/test-semanage.py
> @@ -233,7 +233,7 @@ def semanage_custom_suite(test_list):
>
>
> def semanage_run_test(suite):
> - unittest.TextTestRunner(verbosity=2).run(suite)
> + return unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful()
>
>
> class CheckTest(argparse.Action):
> @@ -255,9 +255,9 @@ def semanage_args(args):
> for i in semanage_test_list:
> print(i)
> if args.all:
> - semanage_run_test(semanage_suite())
> + return semanage_run_test(semanage_suite())
> if args.test:
> - semanage_run_test(semanage_custom_suite(args.test))
> + return semanage_run_test(semanage_custom_suite(args.test))
>
>
> def gen_semanage_test_args(parser):
> @@ -281,8 +281,10 @@ if __name__ == "__main__":
> gen_semanage_test_args(parser)
> try:
> args = parser.parse_args()
> - args.func(args)
> - sys.exit(0)
> + if args.func(args):
> + sys.exit(0)
> + else:
> + sys.exit(1)
> except ValueError as e:
> sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e)))
> sys.exit(1)
--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2020-05-13 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 11:23 [PATCH] semanage/test-semanage.py: Return non-zero value when some of unittest tests fail Petr Lautrbach
2020-05-12 19:40 ` Nicolas Iooss
2020-05-13 15:10 ` Petr Lautrbach [this message]
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=20200513151003.GA184087@workstation \
--to=plautrba@redhat.com \
--cc=selinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.