You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since this is a relatively recent addition to bats-core, I would be cautious to add a feature that relies on a recent addition. We would need some kind of guard to avoid breaking suites by using the wrong bats version. I also dislike the amount of code duplication that entails. Would prefixing assert_output with output="$stderr" be a bad option?
I think the proposed workaround is very spot on and indeed works nicely and unblocks here.
I think with this alternative, it's not worth cluttering the code and duplicating functionalities as you mentioned.
Closing this. Thanks!
I agree there is a viable workaround. However, normally bats tests tend to look very clean and elegant and the workaround is
rather jarring. Also, --separate-stderr is no longer as recent as it was back when this was first filed.
Code duplication could be avoided by implementing this as a flag, say -r, --stderr added to both assert_output and assert_line.
I agree on bats being generally quite clean and this workaround getting dealing with stderr checks less seamless or "native".
I'm not sure about the impl details, but if we went for extending, I'd find having assert_stderr more discoverable than assert_output --stderr.
I'd Vote for this as well. The existing flag parser in assert_output Just assumes flags it does not know to be the test expectation. This means you will get a somewhat misleading error message in older versions.
Yeah, assert_stderr sounds good, too. I suppose the counterpart for assert_line would be something like assert_stderr_line or assert_line_stderr?
Because it would refer to a check in a specific line vs checking against the full output, I'd say assert_stderr and assert_stderr_line would be the most intuitive pair?
Because it would refer to a check in a specific line vs checking against the full output, I'd say assert_stderr and assert_stderr_line would be the most intuitive pair?
assert_stderr and assert_stderr_line sounds good to me.
Another case against output="$stderr" is that if you use shellcheck, it's going to complain stderr not being defined, so you'd have to either use ${stderr?} or add a shellcheck disable comment.
With assert_stderr, there is no need to jump through such hoops.
Activity
martin-schulze-vireso commentedon Dec 12, 2021
Since this is a relatively recent addition to bats-core, I would be cautious to add a feature that relies on a recent addition. We would need some kind of guard to avoid breaking suites by using the wrong bats version. I also dislike the amount of code duplication that entails. Would prefixing
assert_outputwithoutput="$stderr"be a bad option?jbriales commentedon Dec 27, 2021
I think the proposed workaround is very spot on and indeed works nicely and unblocks here.
I think with this alternative, it's not worth cluttering the code and duplicating functionalities as you mentioned.
Closing this. Thanks!
viathor commentedon Oct 20, 2022
@jbriales @martin-schulze-vireso I'd like to revisit this.
I agree there is a viable workaround. However, normally bats tests tend to look very clean and elegant and the workaround is
rather jarring. Also,
--separate-stderris no longer as recent as it was back when this was first filed.Code duplication could be avoided by implementing this as a flag, say
-r, --stderradded to bothassert_outputandassert_line.WDYT?
jbriales commentedon Oct 20, 2022
I agree on
batsbeing generally quite clean and this workaround getting dealing with stderr checks less seamless or "native".I'm not sure about the impl details, but if we went for extending, I'd find having
assert_stderrmore discoverable thanassert_output --stderr.martin-schulze-vireso commentedon Oct 20, 2022
I'd Vote for this as well. The existing flag parser in assert_output Just assumes flags it does not know to be the test expectation. This means you will get a somewhat misleading error message in older versions.
viathor commentedon Oct 20, 2022
Yeah,
assert_stderrsounds good, too. I suppose the counterpart forassert_linewould be something likeassert_stderr_lineorassert_line_stderr?jbriales commentedon Oct 23, 2022
Because it would refer to a check in a specific line vs checking against the full output, I'd say
assert_stderrandassert_stderr_linewould be the most intuitive pair?martin-schulze-vireso commentedon Oct 23, 2022
assert_stderrandassert_stderr_linesounds good to me.viathor commentedon Oct 23, 2022
Sounds like there is agreement that this should be done (and even how it should be done). Perhaps it could be reopened? :-)
test/system: Ensure that $HOME is used as a fallback working directory
test/system: Ensure that $HOME is used as a fallback working directory
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
test/system: Ensure that error messages go to the standard error stream
hgl commentedon Oct 14, 2023
Another case against
output="$stderr"is that if you use shellcheck, it's going to complainstderrnot being defined, so you'd have to either use${stderr?}or add a shellcheck disable comment.With
assert_stderr, there is no need to jump through such hoops.mh182 commentedon Oct 20, 2024
Is someone working on this?
I also stumbled on this problem. The first thing I did was searching for
assert_stderr. Consistency is a powerful concept.test/system: Ensure that error messages go to the standard error stream
nicola-lunghi commentedon Dec 17, 2024
Same here there was a commit but was closed as the author could not work on it
#52