Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Differentiate between stdout and stderr #8

Open
esc opened this issue Feb 15, 2016 · 2 comments
Open

Differentiate between stdout and stderr #8

esc opened this issue Feb 15, 2016 · 2 comments

Comments

@esc
Copy link

esc commented Feb 15, 2016

Is is possible to differentiate between stdout and stderr? For example to check that an error message was printed to stderr instead of stdout?

cc @snordhausen

@aiiie
Copy link
Owner

aiiie commented Feb 24, 2016

You could redirect the two streams to separate files and cat them/check the output separately. Would that work for what you're trying to do?

E.g:

  $ command 2> stderr.log > stdout.log
  $ cat stderr.log
  Error message!
  $ cat stdout.log
  Regular output!

I'm trying to think of how this could be supported directly in the test syntax, but I'm not sure if it's possible. Right now when Cram invokes the shell, it redirects stderr to stdout. This makes it possible for the two output streams to be properly mixed together and checked in the tests. If Cram didn't do that redirection, I'm not sure it'd be possible to interleave the two output streams properly after the fact.

@esc
Copy link
Author

esc commented Feb 24, 2016

Maybe an alternative syntax could be used, with a special symbol, e.g. |:

  $ command
  Regular output!
  |Error message!

I am guessing here, but the separation and redirection could work, although it is somewhat cumbersome.

nigels-com pushed a commit to nigels-com/cram that referenced this issue Sep 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants