FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 10-09-2010, 03:16 PM
Michał Górny
 
Default 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
 
Old 10-09-2010, 09:33 PM
Mike Frysinger
 
Default 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 ]].

> + if [[ ${ECLASS_DEBUG_OUTPUT} = on ]]; then

if you're going to use [[]], then also use ==

> + 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:
[[ $# -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

> +debug-print-function() {
> + local f="${1}: entering function"
> + shift
> + debug-print "${f}, parameters: ${*}"
> +}

debug-print ${1}: entering function, parameters: ${*:2}"
-mike
 
Old 10-10-2010, 07:36 AM
Michał Górny
 
Default 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?

debug-print 'line1'
'line2'

where each line would be prefixed with 'debug:'.

> > +debug-print-function() {
> > + local f="${1}: entering function"
> > + shift
> > + debug-print "${f}, parameters: ${*}"
> > +}
>
> debug-print ${1}: entering function, parameters: ${*:2}"

Ok.

--
Best regards,
Michał Górny
 
Old 10-10-2010, 03:54 PM
Jonathan Callen
 
Default 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/

iQIcBAEBCAAGBQJMseHIAAoJELHSF2kinlg4ZjYQAIw1htkb1J uMK6jQru3JngHX
S/k0zrCqpDgj0OOuJYta6E6yjJEi7iPkLK2oswp6Ip/T+baNFFw2G25CPyJJ9QQZ
bcUn/ROiXKypuu5elz6QvkZvJauIMxiWQMfSfnL9Il9VNcGK19ZYVgm 0IsMK4dEZ
xAiaL9NdS+FDaUpQe7zT9qCyD3QfKkE08NIsCgQdqSctd2SWmL QZQs4C9DMfBb3x
24kBW1+NtHMb48alJ1JfKixzBefeUJZnQJwXMNZMHw05uP8y8a HE5Pd4Y9A+1fuo
xEasllgYOdpcG32YK99UlDekvWl0GgwZ2E9kP1gv8Hjsu7LDyD PvQfW2zTs4CRKf
a4I+FYdkw3fUMFWDiOuUUTM6a+i60jjDgaQm78lE5kfUudgyw7 oeVhj2OAk14+GF
pUn1zMLjnwuxlY1QIgrcJ+heU3GOlhJtnSI/4ozVImQvID3gLTjxgZZtSoarp+wu
EUXLLuA3Ny0ksdhu2CQrBLpw3pgIOdUu6Re6iImWVvAZYk1C1R vmZXRfSshC3vkx
RuWVEG194EY7WyZEOsh//7za8Kn5RfNFhEzU+hLIOny+9aGuaCDMABHDUFs//+J9
+iSNCdxdMFUenlUIrAscWTojnbap1sM24u5Q5XsO5OB5cXLSQM T9GOMpVfejBPfq
5gXeK46wvZ3J+ut2ke6s
=Ju7m
-----END PGP SIGNATURE-----
 
Old 10-10-2010, 04:18 PM
Michał Górny
 
Default eclass/tests/tests-common.sh: debug-print family of functions

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 10 Oct 2010 11:54:49 -0400
Jonathan Callen <abcd@gentoo.org> wrote:

> That printf expression does the exact same thing, printing each
> argument on a separate line, prefixed with 'debug: '.

Ah, I wasn't aware of that printf behavior. My mistake then.

- --
Best regards,
Michał Górny
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iEYEARECAAYFAkyx51cACgkQnGSe5QXeB7vZmgCeNzNm70plsj d7ksaSo5Jn+Bd0
hYMAniRkZSqFtRgAC5leYDECC69RdY5T
=jjbj
-----END PGP SIGNATURE-----
 
Old 10-10-2010, 06:10 PM
Mike Frysinger
 
Default 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
 
Old 10-17-2010, 09:36 PM
Mike Frysinger
 
Default 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

feel free to commit either way
-mike
 

Thread Tools




All times are GMT. The time now is 07:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org