eclass/tests/tests-common.sh: debug-print family of functions
Hello,
I'd like to add the tests-common*() family of functions to the
eclass/tests/tests-common.sh file as required for clean (garbage-free)
run of scons-utils tests.
I'm attaching the patch. Does anyone have any objections or
suggestions? The code was based on one used in Portage.
--
Best regards,
Michał Górny
10-09-2010, 09:33 PM
Mike Frysinger
eclass/tests/tests-common.sh: debug-print family of functions
On Saturday, October 09, 2010 11:16:38 Michał Górny wrote:
> +debug-print() {
> + while [[ ${1} ]]; do
use explicit -n here, although this could give incorrect behavior. better to
use [[ $# -gt 0 ]].
this whole func is overkill. just use a single printf:
[[ $# -eq 0 ]] && return 0
if [[ ${ECLASS_DEBUG_OUTPUT} == "on" ]] ; then
printf 'debug: %s
' "$@" >&2
elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]] ; then
printf 'debug: %s
' "$@" >> "${ECLASS_DEBUG_OUTPUT}"
fi
eclass/tests/tests-common.sh: debug-print family of functions
On Sat, 9 Oct 2010 17:33:41 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> On Saturday, October 09, 2010 11:16:38 Michał Górny wrote:
> > +debug-print() {
> > + while [[ ${1} ]]; do
>
> use explicit -n here, although this could give incorrect behavior.
> better to use [[ $# -gt 0 ]].
True.
> > + if [[ ${ECLASS_DEBUG_OUTPUT} = on ]]; then
>
> if you're going to use [[]], then also use ==
Pointless. == implies pattern matching.
> > + echo "debug: ${1}" >&2
> > + elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
> > + echo "debug: ${1}" >>
> > "${ECLASS_DEBUG_OUTPUT}"
> > + fi
>
> this whole func is overkill. just use a single printf:
I agree but I assumed Portage behavior has some reason for it. Maybe
it's some kind of pseudo-multiline output?
eclass/tests/tests-common.sh: debug-print family of functions
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 10/10/2010 03:36 AM, Michał Górny wrote:
> On Sat, 9 Oct 2010 17:33:41 -0400
> Mike Frysinger <vapier@gentoo.org> wrote:
>> this whole func is overkill. just use a single printf:
>
> I agree but I assumed Portage behavior has some reason for it. Maybe
> it's some kind of pseudo-multiline output?
>
> debug-print 'line1'
> 'line2'
>
> where each line would be prefixed with 'debug:'.
>
That printf expression does the exact same thing, printing each argument
on a separate line, prefixed with 'debug: '.
- --
Jonathan Callen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
eclass/tests/tests-common.sh: debug-print family of functions
On Sun, Oct 10, 2010 at 3:36 AM, Michał Górny wrote:
> On Sat, 9 Oct 2010 17:33:41 -0400 Mike Frysinger wrote:
>> On Saturday, October 09, 2010 11:16:38 Michał Górny wrote:
>> > + Â* Â* Â* Â* Â* if [[ ${ECLASS_DEBUG_OUTPUT} = on ]]; then
>>
>> if you're going to use [[]], then also use ==
>
> Pointless. == implies pattern matching.
not really. the point of using == is to avoid confusion of assignment
which = implies.
-mike
10-17-2010, 09:36 PM
Mike Frysinger
eclass/tests/tests-common.sh: debug-print family of functions
On Thursday, October 14, 2010 09:14:22 Michał Górny wrote:
> Ok, I think I've applied all your suggestions. Sorry for the delay.
> Anything else to change?
personally, i dont like "${@}" over "$@", but maybe that's me