Profile

Cover photo
John Cinnamond
79 followers|19,917 views
AboutPostsPhotosYouTube

Stream

John Cinnamond

Discussion  - 
 
Is there any way to test stderr, similar to the way Examples work for stdout? E.g., I want to do something like:

func ExampleParse_NoData() {
    parse([]string{})
    // Output:
    // parser.test: no data given
}

where the output is sent to stderr
3
Jip J. Dekker's profile photoJohn Cinnamond's profile photo
2 comments
 
Thanks for replying Jip. It doesn't solve the problem I had but it did point me in the right direction.

The call to parse has some code like:

if len(data) == 0 {
    fmt.Fprintf(os.Stderr, "%s: no data given\n", os.Args[0])
    return
}

It is the output to Stderr inside the func that I want to test. It doesn't return anything useful that I could assign and send to a Writer.

However, your example got me thinking that the solution is to simply to redirect Stderr to Stdout. I eventually realised that the solution is as simple as:

func ExampleProcess_NoArgs() {
    stderr := os.Stderr
    os.Stderr = os.Stdout
    defer func() {
        os.Stderr = stderr
    }()

    parse([]string{}) 

    // Output:
    // parser.test: no data given
}
Add a comment...

John Cinnamond

Shared publicly  - 
 
Blogging (en français) avec un video et des photos. Je suis totalement un homme de 21eme siècle.
 ·  Translate
1
William Roe's profile photo
 
whatever
Add a comment...

John Cinnamond

Shared publicly  - 
 
I got up early this morning and went for a run through the streets of Paris as the city was waking up. It was exceedingly cool.

http://runkeeper.com/user/jcinnamond/activity/48376159
John Cinnamond's Running Activity 4.71 km
1
William Roe's profile photo
 
I watched the film l'Appartement the other day so I have a pretty good idea what people get up to in Paris.
Add a comment...

John Cinnamond

Shared publicly  - 
 
Paris is a city for sharing.
1
Sheila Suarez de Flores's profile photo
 
C'est vrai!
Add a comment...

John Cinnamond

Shared publicly  - 
 
I am looking for a hole but I can't find it. Has anyone seen my hole?
1
James Bowe's profile photoMark Wheadon's profile photo
2 comments
 
There are plenty in the roads round here if you need one -- I could post one to you -- presumably wouldn't weigh much.
Add a comment...

John Cinnamond

Shared publicly  - 
 
J'ai commencé un blog pour pratiquant mon français.

http://john-a-paris.blogspot.com/
 ·  Translate
Je suis Parisien maintenant. Salut. C'est dimanche et je me suis levé en retard, j'ai fait du jogging autour le centre de Paris et puis j'ai acheté un baguette et j'ai fait du café. Ai...
1
John Cinnamond's profile photoSheila Suarez de Flores's profile photo
3 comments
 
J'essaye le mac et je n'ete pas impressed. Or something like that.
Add a comment...
In his circles
95 people
Have him in circles
79 people
Leah Tardivel's profile photo
Ilya Dovban's profile photo
Emily Watson's profile photo
Richard Mann's profile photo
Piotr Usewicz's profile photo
Misha Gorodnitzky's profile photo
Nick Fisher's profile photo
Chris Keene's profile photo
Steve Edwards's profile photo

John Cinnamond

Shared publicly  - 
 
Another week, another hour spent unpicking the mess caused by someone merging master into hotfix. How difficult is this? (Obviously too difficult as people keep doing it)
1
John Cinnamond's profile photoWilliam Roe's profile photo
2 comments
 
git FTW
Add a comment...

John Cinnamond

Shared publicly  - 
 
Office successfully rearranged.
1
William Roe's profile photoJJ Anderson's profile photo
2 comments
 
so managed to SCRAPE it all together then.... lol
Add a comment...

John Cinnamond

Shared publicly  - 
 
So I've been woken up at around 5:30am each morning by seagulls. This is kinda weird because I'm in the middle of Paris and I've never seen the seagulls, I've only heard them. Soanyways, Claire has joined me in Paris and I complained to her about the seagulls waking me up. Claire didn't hear them and she is the world's lightest sleeper. So now I'm thinking that I've been woken up every morning in the middle of Paris by seagulls that I've never seen and nobody else has ever heard.

Maybe I've been working too hard.
1
Austin Flores's profile photoJohn Cinnamond's profile photoWilliam Roe's profile photo
5 comments
 
You should do a magic act - the amazing seagulls that nobody can see or hear but you can.
Add a comment...

John Cinnamond

Shared publicly  - 
 
I'm totally eating bread and cheese. A proper fresh baguette that was still warm when I bought it and bleu d'Auvergne. C'est très om nom nom.
1
Add a comment...

John Cinnamond

Shared publicly  - 
 
I really missed having my camera when I was out walking today. I'll have to pick it up next weekend and bring it back with me. That way I can look like a proper tourist.
1
William Roe's profile photo
 
iPhone? Surely that's good enough for great tourist shots
Add a comment...

John Cinnamond

Shared publicly  - 
 
2:58 - I just did this. Bells are annoying.

The Young Ones S2E4 - Time
1
Sheila Suarez de Flores's profile photo
2 comments
 
Lol yea... sundays the bells go crazy.
Add a comment...
People
In his circles
95 people
Have him in circles
79 people
Leah Tardivel's profile photo
Ilya Dovban's profile photo
Emily Watson's profile photo
Richard Mann's profile photo
Piotr Usewicz's profile photo
Misha Gorodnitzky's profile photo
Nick Fisher's profile photo
Chris Keene's profile photo
Steve Edwards's profile photo
Links
Contributor to
Basic Information
Gender
Male