Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Tamás Gulácsi
2019. július 10., szerda 6:43:39 UTC+2 időpontban Farid Zakaria a 
következőt írta:
>
> That's not bad and good to know. 
> Thanks for sharing !
>
> Fundamentally I want to include the tests in the main though executable 
> and then run testing.T myself in the normal main
> (Through a CLI command)
>
> I'm willing to accept it can't be done because ts not idiomatic but 
> thought I'd inquire. 
>
> On Tue, Jul 9, 2019, 9:40 PM Dan Kortschak  > wrote:
>
>> You can ask go test to leave the test executable for you to use later.
>> This is done with the -c flag. It will leave a -test binary
>> that takes all the flags that go test takes. This is at least similar
>> to what you are asking for.
>>
>> On Tue, 2019-07-09 at 18:35 -0700, farid@gmail.com  
>> wrote:
>> > We've written some diagnostic tests that we execute during the test
>> > phase 
>> > (go test) however I was wondering if there's an established
>> > pattern for how to include tests in the final binary and execute
>> > them 
>> > afterwards.
>> > 
>> > The analogous version in Java would be that you could create a "test
>> > JAR" 
>> > which contains the test classes and execute an XUnit framework
>> > (JUnit) 
>> > programmatically yourself run the tests.
>> > 
>>
>>
go test -c
and append yourpacakge.test onto yourpackage binary as a zip file with 
github.com/GeertJohan/go.rice/rice .

-- 
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/61ca5f8c-bef1-4db6-b929-5b904ad0a8ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Sean Liao
I think testing.MainStart() does what you want though do nore the caveats

https://golang.org/pkg/testing/#MainStart

-- 
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/db5e1fec-8210-4000-bcc8-73576f586716%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Marko Ristin-Kaufmann
Hi Farid,
If I understood your question correctly, you can play with build flags.
Alternatively, you can add a "-diagnostics" flag.


Consider also design-by-contract with contracts tested at run time (e.g.,
we use our own implementation https://github.com/Parquery/gocontracts; see
also other implementations in the readme).

Le mer. 10 juil. 2019 à 03:35,  a écrit :

> We've written some diagnostic tests that we execute during the test phase
> (go test) however I was wondering if there's an established
> pattern for how to include tests in the final binary and execute them
> afterwards.
>
> The analogous version in Java would be that you could create a "test JAR"
> which contains the test classes and execute an XUnit framework (JUnit)
> programmatically yourself run the tests.
>
> --
> 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/1441787d-eb2b-479e-821c-934694fbe6b7%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGu4bVCbqzAuSCDeDQazgPOB52XcOYuDww7%3DkzQxQ1HtnHKBWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Include tests in binary and run them

2019-07-09 Thread Farid Zakaria
That's not bad and good to know.
Thanks for sharing !

Fundamentally I want to include the tests in the main though executable and
then run testing.T myself in the normal main
(Through a CLI command)

I'm willing to accept it can't be done because ts not idiomatic but thought
I'd inquire.

On Tue, Jul 9, 2019, 9:40 PM Dan Kortschak  wrote:

> You can ask go test to leave the test executable for you to use later.
> This is done with the -c flag. It will leave a -test binary
> that takes all the flags that go test takes. This is at least similar
> to what you are asking for.
>
> On Tue, 2019-07-09 at 18:35 -0700, farid.m.zaka...@gmail.com wrote:
> > We've written some diagnostic tests that we execute during the test
> > phase
> > (go test) however I was wondering if there's an established
> > pattern for how to include tests in the final binary and execute
> > them
> > afterwards.
> >
> > The analogous version in Java would be that you could create a "test
> > JAR"
> > which contains the test classes and execute an XUnit framework
> > (JUnit)
> > programmatically yourself run the tests.
> >
>
>

-- 
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/CACCo2j%3Dy69J3E%3DiOtOfJMc5VBLfjfniu_K%3D35G8XWDJLaZ23YQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Include tests in binary and run them

2019-07-09 Thread Dan Kortschak
You can ask go test to leave the test executable for you to use later.
This is done with the -c flag. It will leave a -test binary
that takes all the flags that go test takes. This is at least similar
to what you are asking for.

On Tue, 2019-07-09 at 18:35 -0700, farid.m.zaka...@gmail.com wrote:
> We've written some diagnostic tests that we execute during the test
> phase 
> (go test) however I was wondering if there's an established
> pattern for how to include tests in the final binary and execute
> them 
> afterwards.
> 
> The analogous version in Java would be that you could create a "test
> JAR" 
> which contains the test classes and execute an XUnit framework
> (JUnit) 
> programmatically yourself run the tests.
> 

-- 
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/0bb35a0e19ead56033096c24bc00240012779718.camel%40kortschak.io.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Include tests in binary and run them

2019-07-09 Thread farid . m . zakaria
We've written some diagnostic tests that we execute during the test phase 
(go test) however I was wondering if there's an established
pattern for how to include tests in the final binary and execute them 
afterwards.

The analogous version in Java would be that you could create a "test JAR" 
which contains the test classes and execute an XUnit framework (JUnit) 
programmatically yourself run the tests.

-- 
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/1441787d-eb2b-479e-821c-934694fbe6b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.