From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] support/tests: allow properly indented config fragment
Date: Tue, 18 Jul 2017 21:45:21 +0200 [thread overview]
Message-ID: <20170718194521.GC2583@scaer> (raw)
In-Reply-To: <420f45cf-1f44-d85f-4373-56ca3aded94a@mind.be>
Arnout, All,
On 2017-07-18 21:37 +0200, Arnout Vandecappelle spake thusly:
> On 16-07-17 00:49, Yann E. MORIN wrote:
> > Currently, defining a config fragment in the runtime test infra requires
> > that the fragment not to be indented. This is beark, and causes grievance
> > when looking at the code (e.g. to fix it).
> >
> > Just strip out all leading spaces/tabs when writing the configuration
> > lines into the config file.
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > ---
> > support/testing/infra/builder.py | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/support/testing/infra/builder.py b/support/testing/infra/builder.py
> > index a475bb0a30..81735dec96 100644
> > --- a/support/testing/infra/builder.py
> > +++ b/support/testing/infra/builder.py
> > @@ -16,7 +16,8 @@ class Builder(object):
> >
> > config_file = os.path.join(self.builddir, ".config")
> > with open(config_file, "w+") as cf:
> > - cf.write(self.config)
> > + for line in self.config.splitlines():
> > + cf.write("{}\n".format(line.lstrip()))
>
> I like nitpicking :-)
Please nit-pick, python is not my cup of tea, you know well! ;-)
> I would do this in BRTest instead of down here, so that self.config contains a
> correct config file. In fact, I would do it in its constructor instead of in
> setUp(), so that it is done only once even if a class has two test functions.
Meh, I have no real clue on how those class- or instance-scoped
variables play iwth each others... I think this is sad that we use
class-scoped config variable for the actual tests; they should be
instance-scoped instead, but that requires one to actually write an
__init__ function, so a classscoped is quicker to write.
Be if we ever want to derive a Test class into another, then we'll have
issues I guess...
But if I understand you correctly, you'd prefer (code elided for
brevity):
class BRTest():
def __init__(self):
self.config = '\n'.join(map(str.lstrip, self.config.splitlines()))
Right?
> I would also do it as a oneliner:
> self.config = '\n'.join(map(str.lstrip, self.config.splitlines()))
> but some people don't like oneliners :-)
Well, I prefer it, because it is rather self-explanatory. But I could
not have wrote it myself (I did not know about map() ).
Thanks!
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
next prev parent reply other threads:[~2017-07-18 19:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-15 22:49 [Buildroot] [PATCH] support/tests: allow properly indented config fragment Yann E. MORIN
2017-07-16 7:18 ` Thomas Petazzoni
2017-07-16 8:11 ` Yann E. MORIN
2017-07-18 19:37 ` Arnout Vandecappelle
2017-07-18 19:45 ` Yann E. MORIN [this message]
2017-07-18 19:55 ` Arnout Vandecappelle
2017-07-18 19:58 ` Yann E. MORIN
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=20170718194521.GC2583@scaer \
--to=yann.morin.1998@free.fr \
--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 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.