Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If loving linux is wrong, I dont wanna be right. -- Topic for #LinuxGER


devel / comp.lang.tcl / does tcltest have smth like exec's -ignorestderr?

SubjectAuthor
* does tcltest have smth like exec's -ignorestderr?Petro Kazmirchuk
+* does tcltest have smth like exec's -ignorestderr?Ralf Fassel
|`- does tcltest have smth like exec's -ignorestderr?Petro Kazmirchuk
`* does tcltest have smth like exec's -ignorestderr?Emiliano Gavilán
 `* does tcltest have smth like exec's -ignorestderr?Ralf Fassel
  `- does tcltest have smth like exec's -ignorestderr?Emiliano Gavilan

1
does tcltest have smth like exec's -ignorestderr?

<f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10232&group=comp.lang.tcl#10232

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:4698:0:b0:39c:1435:423e with SMTP id g24-20020ac84698000000b0039c1435423emr8835693qto.490.1669202648097;
Wed, 23 Nov 2022 03:24:08 -0800 (PST)
X-Received: by 2002:a37:a816:0:b0:6ee:b301:e302 with SMTP id
r22-20020a37a816000000b006eeb301e302mr24056045qke.643.1669202647934; Wed, 23
Nov 2022 03:24:07 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 23 Nov 2022 03:24:07 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=193.163.1.59; posting-account=yD4T_QoAAAAzNGigQobo9AtcgLgheZii
NNTP-Posting-Host: 193.163.1.59
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>
Subject: does tcltest have smth like exec's -ignorestderr?
From: petro.ka...@gmail.com (Petro Kazmirchuk)
Injection-Date: Wed, 23 Nov 2022 11:24:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2289
 by: Petro Kazmirchuk - Wed, 23 Nov 2022 11:24 UTC

I have a number of tests that spawn a child process - it is a binary outside my control. I'm using processman::spawn, but it could easily be just 'exec'.
This process prints something to stderr.
While I was using -singleproc 1, this wasn't a problem. However, later I realized that in this mode, global variables created by one .test script will be inherited by other .test scripts. So, I decided to switch to -singleproc 0 (that is the default anyway). And suddenly I end up with test reports like this:

Test file error: <stderr output from my child process>
....
Tests ended at Wed Nov 23 11:30:44 CET 2022
all.tcl: Total 9 Passed 9 Skipped 0 Failed 0
Sourced 1 Test Files.
Test files exiting with errors:
pubsub.test
also $? is 1.
So, tcltest believes that some tests failed just because they happen to print something to stderr!
I looked in the source code, and it doesn't look like I can configure this behaviour, because in essence it is:
if {!$singleProcess} {
catch { open shell } error

So, apparently 'open' throws an error and then catch's handler counts the test as failed.

could somebody point me to how I can avoid this?
thanks in advance

Re: does tcltest have smth like exec's -ignorestderr?

<ygah6ypvrhm.fsf@akutech.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10233&group=comp.lang.tcl#10233

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: does tcltest have smth like exec's -ignorestderr?
Date: Wed, 23 Nov 2022 12:29:25 +0100
Lines: 17
Message-ID: <ygah6ypvrhm.fsf@akutech.de>
References: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net A0qVxEcjxKd6yyD/7TakOQaf06tvUggM5lgYUplLvAB566E1U=
Cancel-Lock: sha1:SYBPWyZ/fZH9z4IkD3ihAfNIjYY= sha1:X+MtJsfVnFdDBR79MILfkvk/cWA=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Wed, 23 Nov 2022 11:29 UTC

* Petro Kazmirchuk <petro.kazmirchuk@gmail.com>
| So, tcltest believes that some tests failed just because they happen to print something to stderr!
| I looked in the source code, and it doesn't look like I can configure this behaviour, because in essence it is:
| if {!$singleProcess} {
| catch { open shell } error
>
| So, apparently 'open' throws an error and then catch's handler counts the test as failed.

I expect rather the 'close' call for the pipe to fail if there is output
on stderr.

| could somebody point me to how I can avoid this?

Redirect stderr to some file, and inspect that file if the process
really fails (i.e. errorCode = childStatus)? Clumsy, I know...

R'

Re: does tcltest have smth like exec's -ignorestderr?

<5e5d6998-32a8-4215-90ad-94c0692342ccn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10234&group=comp.lang.tcl#10234

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:459f:b0:6fa:f76d:bbc1 with SMTP id bp31-20020a05620a459f00b006faf76dbbc1mr7869682qkb.11.1669211341404;
Wed, 23 Nov 2022 05:49:01 -0800 (PST)
X-Received: by 2002:ac8:5c03:0:b0:3a5:3979:23f0 with SMTP id
i3-20020ac85c03000000b003a5397923f0mr26252344qti.216.1669211341197; Wed, 23
Nov 2022 05:49:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 23 Nov 2022 05:49:00 -0800 (PST)
In-Reply-To: <ygah6ypvrhm.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=193.163.1.59; posting-account=yD4T_QoAAAAzNGigQobo9AtcgLgheZii
NNTP-Posting-Host: 193.163.1.59
References: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com> <ygah6ypvrhm.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5e5d6998-32a8-4215-90ad-94c0692342ccn@googlegroups.com>
Subject: Re: does tcltest have smth like exec's -ignorestderr?
From: petro.ka...@gmail.com (Petro Kazmirchuk)
Injection-Date: Wed, 23 Nov 2022 13:49:01 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1331
 by: Petro Kazmirchuk - Wed, 23 Nov 2022 13:49 UTC

sorry, ofc you're right, it's 'close' that throws the error
well, I don't *really* need to see stderr (it would be nice to have though), so I'll just redirect it to /dev/null

Re: does tcltest have smth like exec's -ignorestderr?

<20221124200423.d9235b0545355b0fde3db2ee@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10238&group=comp.lang.tcl#10238

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: emiliano...@gmail.com (Emiliano Gavilán)
Newsgroups: comp.lang.tcl
Subject: Re: does tcltest have smth like exec's -ignorestderr?
Date: Thu, 24 Nov 2022 20:04:23 -0300
Organization: IMAE - FCEIA - UNR
Lines: 50
Message-ID: <20221124200423.d9235b0545355b0fde3db2ee@gmail.com>
References: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Injection-Info: reader01.eternal-september.org; posting-host="605dbd058a9d86aac2e7ab159985702d";
logging-data="794449"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/S7Fq6GYwnjejCjUKs5j8yG9aDnIGv8zo="
Cancel-Lock: sha1:bzxOBv32xTANufrk39PWGr06Ryo=
X-Newsreader: Sylpheed 3.5.1 (GTK+ 2.24.32; i686-pc-linux-gnu)
 by: Emiliano Gavilán - Thu, 24 Nov 2022 23:04 UTC

On Wed, 23 Nov 2022 03:24:07 -0800 (PST)
Petro Kazmirchuk <petro.kazmirchuk@gmail.com> wrote:

> I have a number of tests that spawn a child process - it is a binary outside my control. I'm using processman::spawn, but it could easily be just 'exec'.
> This process prints something to stderr.
> While I was using -singleproc 1, this wasn't a problem. However, later I realized that in this mode, global variables created by one .test script will be inherited by other .test scripts. So, I decided to switch to -singleproc 0 (that is the default anyway). And suddenly I end up with test reports like this:
>
> Test file error: <stderr output from my child process>
> ...
> Tests ended at Wed Nov 23 11:30:44 CET 2022
> all.tcl: Total 9 Passed 9 Skipped 0 Failed 0
> Sourced 1 Test Files.
> Test files exiting with errors:
> pubsub.test
> also $? is 1.
> So, tcltest believes that some tests failed just because they happen to print something to stderr!
> I looked in the source code, and it doesn't look like I can configure this behaviour, because in essence it is:
> if {!$singleProcess} {
> catch { open shell } error
>
> So, apparently 'open' throws an error and then catch's handler counts the test as failed.
>
> could somebody point me to how I can avoid this?
> thanks in advance

You can get stdout and stderr from the child process using [chan pipe].
The magic incantation is

lassign [chan pipe] ir iw
lassign [chan pipe] er ew
exec {*}[list $progname $param1 $param2 ...] >@ $iw 2>@ $ew
chan close $iw
chan close $ew

Now you can use either [chan read] or [chan gets] to get the child process
data from $ir and $er handlers.

Regards

--
Emiliano Gavilán

Re: does tcltest have smth like exec's -ignorestderr?

<yga4junuy0x.fsf@akutech.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10240&group=comp.lang.tcl#10240

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!lilly.ping.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: does tcltest have smth like exec's -ignorestderr?
Date: Fri, 25 Nov 2022 11:30:22 +0100
Lines: 22
Message-ID: <yga4junuy0x.fsf@akutech.de>
References: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>
<20221124200423.d9235b0545355b0fde3db2ee@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net bRBf7fvPCfDdC4DE/4szjgWvz1jkbXsr7bdy6YN2gZCbotv10=
Cancel-Lock: sha1:3A3xLMtp6NIiHtweBaiI87gm/W4= sha1:AKjIloVqwDc23nY+sy1IMk0A1Us=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Fri, 25 Nov 2022 10:30 UTC

* Emiliano Gavilán <emilianogavilan@gmail.com>
| You can get stdout and stderr from the child process using [chan pipe].
| The magic incantation is
>
| lassign [chan pipe] ir iw
| lassign [chan pipe] er ew
| exec {*}[list $progname $param1 $param2 ...] >@ $iw 2>@ $ew
| chan close $iw
| chan close $ew
>
| Now you can use either [chan read] or [chan gets] to get the child process
| data from $ir and $er handlers.

Cool trick, thanks for pointing that out!

However, if large amount of data is produced (notably more than the OS
pipes buffer) there is a chance of deadlock here, since TCL waits for
the 'exec' to finish, while the exec'd process might be blocked waiting
for the pipe to be read, no? (I think this could be avoided by using
[open |$cmd 2>@...] with only the pipe for stderr.)

R'

Re: does tcltest have smth like exec's -ignorestderr?

<20221128105146.579dfb4313571b5c035fc860@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10257&group=comp.lang.tcl#10257

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: emiliano...@gmail.com (Emiliano Gavilan)
Newsgroups: comp.lang.tcl
Subject: Re: does tcltest have smth like exec's -ignorestderr?
Date: Mon, 28 Nov 2022 10:51:46 -0300
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <20221128105146.579dfb4313571b5c035fc860@gmail.com>
References: <f52ce432-1811-437f-b19a-6501bb256788n@googlegroups.com>
<20221124200423.d9235b0545355b0fde3db2ee@gmail.com>
<yga4junuy0x.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Injection-Info: reader01.eternal-september.org; posting-host="08ab0fbb417426b9aa9100bdd554ff15";
logging-data="2091435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/h0hNbB4Z5ictnjtwLT4vY+FWizDVh+iY="
Cancel-Lock: sha1:ZlbCyXkcvvlGQ9g4LYZzNU7uAfc=
In-Reply-To: <yga4junuy0x.fsf@akutech.de>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Emiliano Gavilan - Mon, 28 Nov 2022 13:51 UTC

On Fri, 25 Nov 2022 11:30:22 +0100
Ralf Fassel <ralfixx@gmx.de> wrote:

> * Emiliano Gavilán
> | You can get stdout and stderr from the child process using [chan pipe].
> | The magic incantation is
> >
> | lassign [chan pipe] ir iw
> | lassign [chan pipe] er ew
> | exec {*}[list $progname $param1 $param2 ...] >@ $iw 2>@ $ew
> | chan close $iw
> | chan close $ew
> >
> | Now you can use either [chan read] or [chan gets] to get the child process
> | data from $ir and $er handlers.
>
> Cool trick, thanks for pointing that out!
>
> However, if large amount of data is produced (notably more than the OS
> pipes buffer) there is a chance of deadlock here, since TCL waits for
> the 'exec' to finish, while the exec'd process might be blocked waiting
> for the pipe to be read, no? (I think this could be avoided by using
> [open |$cmd 2>@...] with only the pipe for stderr.)

You can launch the child process in the background adding a trailing "&"
to the [exec] line.

- exec {*}[list $progname $param1 $param2 ...] >@ $iw 2>@ $ew
+ exec {*}[list $progname $param1 $param2 ...] >@ $iw 2>@ $ew &

This also allows for [chan event] to be used for both $ir and $er.

You can find more details on using [chan pipe] in the tip itself

https://core.tcl-lang.org/tips/doc/trunk/tip/304.md

and in the wiki

https://wiki.tcl-lang.org/page/chan+pipe

Regards

--
Emiliano Gavilan

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor