* [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
@ 2010-10-09 15:16 Michał Górny
2010-10-09 21:33 ` Mike Frysinger
0 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2010-10-09 15:16 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 331 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: tests-add-debug-print.diff --]
[-- Type: text/x-patch, Size: 878 bytes --]
? tests-add-debug-print.diff
Index: tests-common.sh
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/tests/tests-common.sh,v
retrieving revision 1.1
diff -u -r1.1 tests-common.sh
--- tests-common.sh 2 Jan 2008 01:01:18 -0000 1.1
+++ tests-common.sh 9 Oct 2010 15:15:15 -0000
@@ -8,3 +8,26 @@
source ../${e}.eclass
done
}
+
+debug-print() {
+ while [[ ${1} ]]; do
+ # extra user-configurable targets
+ if [[ ${ECLASS_DEBUG_OUTPUT} = on ]]; then
+ echo "debug: ${1}" >&2
+ elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
+ echo "debug: ${1}" >> "${ECLASS_DEBUG_OUTPUT}"
+ fi
+
+ shift
+ done
+}
+
+debug-print-function() {
+ local f="${1}: entering function"
+ shift
+ debug-print "${f}, parameters: ${*}"
+}
+
+debug-print-section() {
+ debug-print "now in section ${*}"
+}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
2010-10-09 15:16 [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions Michał Górny
@ 2010-10-09 21:33 ` Mike Frysinger
2010-10-10 7:36 ` Michał Górny
2010-10-14 13:14 ` Michał Górny
0 siblings, 2 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-10-09 21:33 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
[-- Attachment #1: Type: Text/Plain, Size: 923 bytes --]
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\n' "$@" >&2
elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]] ; then
printf 'debug: %s\n' "$@" >> "${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
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
2010-10-09 21:33 ` Mike Frysinger
@ 2010-10-10 7:36 ` Michał Górny
2010-10-10 15:54 ` [gentoo-dev] " Jonathan Callen
2010-10-10 18:10 ` [gentoo-dev] " Mike Frysinger
2010-10-14 13:14 ` Michał Górny
1 sibling, 2 replies; 8+ messages in thread
From: Michał Górny @ 2010-10-10 7:36 UTC (permalink / raw
To: Mike Frysinger; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-dev] Re: eclass/tests/tests-common.sh: debug-print family of functions
2010-10-10 7:36 ` Michał Górny
@ 2010-10-10 15:54 ` Jonathan Callen
2010-10-10 16:18 ` Michał Górny
2010-10-10 18:10 ` [gentoo-dev] " Mike Frysinger
1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Callen @ 2010-10-10 15:54 UTC (permalink / raw
To: gentoo-dev
-----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/
iQIcBAEBCAAGBQJMseHIAAoJELHSF2kinlg4ZjYQAIw1htkb1JuMK6jQru3JngHX
S/k0zrCqpDgj0OOuJYta6E6yjJEi7iPkLK2oswp6Ip/T+baNFFw2G25CPyJJ9QQZ
bcUn/ROiXKypuu5elz6QvkZvJauIMxiWQMfSfnL9Il9VNcGK19ZYVgm0IsMK4dEZ
xAiaL9NdS+FDaUpQe7zT9qCyD3QfKkE08NIsCgQdqSctd2SWmLQZQs4C9DMfBb3x
24kBW1+NtHMb48alJ1JfKixzBefeUJZnQJwXMNZMHw05uP8y8aHE5Pd4Y9A+1fuo
xEasllgYOdpcG32YK99UlDekvWl0GgwZ2E9kP1gv8Hjsu7LDyDPvQfW2zTs4CRKf
a4I+FYdkw3fUMFWDiOuUUTM6a+i60jjDgaQm78lE5kfUudgyw7oeVhj2OAk14+GF
pUn1zMLjnwuxlY1QIgrcJ+heU3GOlhJtnSI/4ozVImQvID3gLTjxgZZtSoarp+wu
EUXLLuA3Ny0ksdhu2CQrBLpw3pgIOdUu6Re6iImWVvAZYk1C1RvmZXRfSshC3vkx
RuWVEG194EY7WyZEOsh//7za8Kn5RfNFhEzU+hLIOny+9aGuaCDMABHDUFs//+J9
+iSNCdxdMFUenlUIrAscWTojnbap1sM24u5Q5XsO5OB5cXLSQMT9GOMpVfejBPfq
5gXeK46wvZ3J+ut2ke6s
=Ju7m
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: eclass/tests/tests-common.sh: debug-print family of functions
2010-10-10 15:54 ` [gentoo-dev] " Jonathan Callen
@ 2010-10-10 16:18 ` Michał Górny
0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2010-10-10 16:18 UTC (permalink / raw
To: gentoo-dev; +Cc: abcd
-----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)
iEYEARECAAYFAkyx51cACgkQnGSe5QXeB7vZmgCeNzNm70plsjd7ksaSo5Jn+Bd0
hYMAniRkZSqFtRgAC5leYDECC69RdY5T
=jjbj
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
2010-10-10 7:36 ` Michał Górny
2010-10-10 15:54 ` [gentoo-dev] " Jonathan Callen
@ 2010-10-10 18:10 ` Mike Frysinger
1 sibling, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-10-10 18:10 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-dev
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
2010-10-09 21:33 ` Mike Frysinger
2010-10-10 7:36 ` Michał Górny
@ 2010-10-14 13:14 ` Michał Górny
2010-10-17 21:36 ` Mike Frysinger
1 sibling, 1 reply; 8+ messages in thread
From: Michał Górny @ 2010-10-14 13:14 UTC (permalink / raw
To: gentoo-dev; +Cc: vapier
[-- Attachment #1.1: Type: text/plain, Size: 133 bytes --]
Ok, I think I've applied all your suggestions. Sorry for the delay.
Anything else to change?
--
Best regards,
Michał Górny
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: tests-common.sh.diff --]
[-- Type: text/x-patch, Size: 795 bytes --]
? tests-common.sh.diff
Index: tests-common.sh
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/tests/tests-common.sh,v
retrieving revision 1.1
diff -u -r1.1 tests-common.sh
--- tests-common.sh 2 Jan 2008 01:01:18 -0000 1.1
+++ tests-common.sh 14 Oct 2010 13:13:44 -0000
@@ -8,3 +8,21 @@
source ../${e}.eclass
done
}
+
+debug-print() {
+ [[ ${#} -eq 0 ]] && return
+
+ if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then
+ printf 'debug: %s\n' "${@}" >&2
+ elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
+ printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}"
+ fi
+}
+
+debug-print-function() {
+ debug-print "${1}, parameters: ${*:2}"
+}
+
+debug-print-section() {
+ debug-print "now in section ${*}"
+}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
2010-10-14 13:14 ` Michał Górny
@ 2010-10-17 21:36 ` Mike Frysinger
0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-10-17 21:36 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 267 bytes --]
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
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-17 21:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-09 15:16 [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions Michał Górny
2010-10-09 21:33 ` Mike Frysinger
2010-10-10 7:36 ` Michał Górny
2010-10-10 15:54 ` [gentoo-dev] " Jonathan Callen
2010-10-10 16:18 ` Michał Górny
2010-10-10 18:10 ` [gentoo-dev] " Mike Frysinger
2010-10-14 13:14 ` Michał Górny
2010-10-17 21:36 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox