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
{{ message }}
Repository navigation
Need for test funcs that will check for multiple strings #6091
In bash, its really easy to lose a nested quote and accidentally do things you didn't intend to do, soI like being able to check for accidents by counting the args going into the test functions. If allow a variable number of arguments through, we'll lose that ability.
In all seriousness, though, there has been one use-case where more than a couple of things were being expected. In all of the test-cmd refactors I think there was one case where we were checking for two separate outputs and I was able to tighten the regex to contain both. I wonder if using a Go template to format the output or changing the regex to include all your cases would be better than implementing these new methods. @liggitt mentioned wanting to do checks for multiple things without regard to order, which would not be possible with those workarounds most likely. I wonder how often we need to do that, though?
I agree with @deads2k here, this kind of logic will only introduce us to errors, whereas current multiple checks cost us only a few additional gets, which I don't mind. I've though about it for a bit while reviewing the images part, but in the end realized it's not worth the effort.
It is not intended for people to capture the output of os::cmd functions. I still think Go templates would be the better solution to this problem - they leave little room for errors, you ensure you're reading the fields you expect to be testing, etc.
Activity
deads2k commentedon Nov 25, 2015
In bash, its really easy to lose a nested quote and accidentally do things you didn't intend to do, soI like being able to check for accidents by counting the args going into the test functions. If allow a variable number of arguments through, we'll lose that ability.
How many times have we wanted this?
0xmichalis commentedon Nov 25, 2015
We have you as a reviewer, we are not afraid of such details.
stevekuznetsov commentedon Nov 25, 2015
@Kargakis with the smackdown
stevekuznetsov commentedon Nov 25, 2015
In all seriousness, though, there has been one use-case where more than a couple of things were being expected. In all of the
test-cmdrefactors I think there was one case where we were checking for two separate outputs and I was able to tighten the regex to contain both. I wonder if using a Go template to format the output or changing the regex to include all your cases would be better than implementing these new methods. @liggitt mentioned wanting to do checks for multiple things without regard to order, which would not be possible with those workarounds most likely. I wonder how often we need to do that, though?soltysh commentedon Nov 26, 2015
I agree with @deads2k here, this kind of logic will only introduce us to errors, whereas current multiple checks cost us only a few additional gets, which I don't mind. I've though about it for a bit while reviewing the images part, but in the end realized it's not worth the effort.
liggitt commentedon Nov 26, 2015
What about commands with side effects that we can't run multiple times?
soltysh commentedon Nov 26, 2015
Do we have such cases? You can always execute the command and test the output manually, I guess.
stevekuznetsov commentedon Nov 26, 2015
It is not intended for people to capture the output of
os::cmdfunctions. I still think Go templates would be the better solution to this problem - they leave little room for errors, you ensure you're reading the fields you expect to be testing, etc.stevekuznetsov commentedon Dec 1, 2015
@liggitt What's your final say here. There is one place I know that this will be useful in. Do we create a specific test function for this case?
liggitt commentedon Dec 1, 2015
I'm fine closing it until the need arises
soltysh commentedon Dec 1, 2015
👍