From: Ricardo Martincoski <ricardo.martincoski@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [RFC 1/4] support/testing: add perl test
Date: Thu, 22 Nov 2018 00:39:23 -0200 [thread overview]
Message-ID: <5bf616db678fd_17c33fb41a00a68c70974@ultri5.mail> (raw)
In-Reply-To: CAB0FRsuJV2wv8QqtFdZQkgdbOWQqE0=6pjvAXHmca30zc9Xd4A@mail.gmail.com
Hello,
On Wed, Nov 21, 2018 at 02:26 PM, Fran?ois Perrad wrote:
> Le lun. 19 nov. 2018 ? 02:11, Ricardo Martincoski <
> ricardo.martincoski at gmail.com> a ?crit :
[snip]
>> > + cmd = "perl -v"
>>
>> What about using this instead?
>> cmd = "perl -v | grep 'This is perl 5'"
>>
>
> As tester, I don't like this kind of code, because I never know which exit
> code is available, the one from perl or the one from grep.
> Code written for test must be obvious.
> See the following example:
>
> #!/usr/bin/env python
> import unittest
> import subprocess
>
> class DeveloperWay(unittest.TestCase):
> def testPerl(self):
> retcode = subprocess.call("perl -v | grep 'This is perl 5'",
> shell=True)
> self.assertEqual(retcode, 0)
>
> class TesterWay(unittest.TestCase):
> def testPerl(self):
> retcode = subprocess.call('perl -v', shell=True)
> self.assertEqual(retcode, 0)
> output = subprocess.check_output('perl -v', shell=True)
> self.assert_('This is perl 5' in output)
>
> unittest.main()
Sure. Much better to have an error message that makes obvious what failed.
Regards,
Ricardo
next prev parent reply other threads:[~2018-11-22 2:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-17 17:52 [Buildroot] [RFC 0/4] suppport/testing: Perl, Lua and their modules Francois Perrad
2018-11-17 17:52 ` [Buildroot] [RFC 1/4] support/testing: add perl test Francois Perrad
2018-11-19 1:11 ` Ricardo Martincoski
2018-11-21 16:26 ` François Perrad
2018-11-22 2:39 ` Ricardo Martincoski [this message]
2018-11-17 17:52 ` [Buildroot] [RFC 2/4] support/testing: add perl-time-hires test Francois Perrad
2018-11-19 1:14 ` Ricardo Martincoski
2018-11-19 19:29 ` François Perrad
2018-11-19 22:57 ` Ricardo Martincoski
2018-11-17 17:52 ` [Buildroot] [RFC 3/4] support/testing: add lua test Francois Perrad
2018-11-17 17:52 ` [Buildroot] [RFC 4/4] support/testing: add lpeg test Francois Perrad
2018-11-19 0:27 ` [Buildroot] [RFC 0/4] suppport/testing: Perl, Lua and their modules Ricardo Martincoski
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=5bf616db678fd_17c33fb41a00a68c70974@ultri5.mail \
--to=ricardo.martincoski@gmail.com \
--cc=buildroot@busybox.net \
/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