Re: [go-nuts] Integration testing program that internally forks itself

2022-10-28 Thread 'Bryan C. Mills' via golang-nuts
Generally I use environment variables for that sort of test, so that the 
part of the program that constructs the arguments for the program doesn't 
have to know to pass a special additional argument.

(See, for 
example, 
https://cs.opensource.google/go/go/+/master:src/cmd/cover/cover_test.go;l=75-82;drc=dd42a84fb36ade570a7bfaf6fec5df44bbf71500.)

On Friday, October 28, 2022 at 3:36:08 AM UTC-4 pe...@wonderland.org wrote:

> I also use a flag to do this, and I have a local package that then removes 
> this flag (or any of a defined list) before re-execing the binary:
>
> https://github.com/ITRS-Group/cordial/tree/main/pkg/process
>
> https://pkg.go.dev/github.com/itrs-group/cordial/pkg/process#Daemon
>
> It may not be perfect, but it works for my usage.
>
> Peter
>
> On Thursday, 27 October 2022 at 17:47:43 UTC+1 Jan Mercl wrote:
>
>> Any recursion that does not have a terminating condition will try to 
>> recurse infinitely ;-)
>>
>> I'm passing a command line flag in such situations - when testing, but 
>> the best option depends on the particular use. Elsewhere, in a command that 
>> starts a server or talks to the server, I used, for example, an ephemeral 
>> @named socket, which nicely handled both the termination condition and the 
>> communication and is even safe for concurrent processes competing with each 
>> other.
>>
>> On Thu, Oct 27, 2022, 18:05 Vjeran  wrote:
>>
>>> We have a program that forks itself in order to do some work
>>> so calling `./program do` internally finds its path using os.Executable 
>>> and calls `./program do2`
>>>
>>> Now when trying to do integration tests program spawns itself and 
>>> repeats test causing an infinite loop?
>>>
>>> Any ideas how to handle it? 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/6f62afc4-af7a-4548-85c5-6514c2e20a49n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b0f67d9d-1b79-4bdb-9601-4092835f6a4fn%40googlegroups.com.


Re: [go-nuts] Integration testing program that internally forks itself

2022-10-28 Thread Peter Galbavy
I also use a flag to do this, and I have a local package that then removes 
this flag (or any of a defined list) before re-execing the binary:

https://github.com/ITRS-Group/cordial/tree/main/pkg/process

https://pkg.go.dev/github.com/itrs-group/cordial/pkg/process#Daemon

It may not be perfect, but it works for my usage.

Peter

On Thursday, 27 October 2022 at 17:47:43 UTC+1 Jan Mercl wrote:

> Any recursion that does not have a terminating condition will try to 
> recurse infinitely ;-)
>
> I'm passing a command line flag in such situations - when testing, but the 
> best option depends on the particular use. Elsewhere, in a command that 
> starts a server or talks to the server, I used, for example, an ephemeral 
> @named socket, which nicely handled both the termination condition and the 
> communication and is even safe for concurrent processes competing with each 
> other.
>
> On Thu, Oct 27, 2022, 18:05 Vjeran  wrote:
>
>> We have a program that forks itself in order to do some work
>> so calling `./program do` internally finds its path using os.Executable 
>> and calls `./program do2`
>>
>> Now when trying to do integration tests program spawns itself and repeats 
>> test causing an infinite loop?
>>
>> Any ideas how to handle it? 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/6f62afc4-af7a-4548-85c5-6514c2e20a49n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6756e27a-6e32-4374-8551-493f0ad89004n%40googlegroups.com.


Re: [go-nuts] Integration testing program that internally forks itself

2022-10-27 Thread Jan Mercl
Any recursion that does not have a terminating condition will try to
recurse infinitely ;-)

I'm passing a command line flag in such situations - when testing, but the
best option depends on the particular use. Elsewhere, in a command that
starts a server or talks to the server, I used, for example, an ephemeral
@named socket, which nicely handled both the termination condition and the
communication and is even safe for concurrent processes competing with each
other.

On Thu, Oct 27, 2022, 18:05 Vjeran  wrote:

> We have a program that forks itself in order to do some work
> so calling `./program do` internally finds its path using os.Executable
> and calls `./program do2`
>
> Now when trying to do integration tests program spawns itself and repeats
> test causing an infinite loop?
>
> Any ideas how to handle it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/6f62afc4-af7a-4548-85c5-6514c2e20a49n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-W%2BfpjUECDrQhbEEzc%2B-F-Zd6M1h11K5UacwJMHSPaPUw%40mail.gmail.com.


[go-nuts] Integration testing program that internally forks itself

2022-10-27 Thread Vjeran
We have a program that forks itself in order to do some work
so calling `./program do` internally finds its path using os.Executable and 
calls `./program do2`

Now when trying to do integration tests program spawns itself and repeats 
test causing an infinite loop?

Any ideas how to handle it?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6f62afc4-af7a-4548-85c5-6514c2e20a49n%40googlegroups.com.