Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yellow test if Empty Try/Catch #73

Open
konstantinvlasenko opened this issue May 6, 2015 · 14 comments
Open

Yellow test if Empty Try/Catch #73

konstantinvlasenko opened this issue May 6, 2015 · 14 comments

Comments

@konstantinvlasenko
Copy link
Owner

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

Hmm,
I tried to use $Lastexitcode and $?. Unfortunately, It does not recognize errors like Get-Service invalidservice. AFAIK, it is very hard or impossible to redirect error stream only to PS variable without temporal file. Maybe you have other ideas?

@konstantinvlasenko
Copy link
Owner Author

@2xmax I didn't get how Get-Service invalidservice relates to this issue? I, believe, in you example the exception were handled internally by underlying code of Get-Service. And what you seen in the console output is just the result of Write-Host. I think nothing can be done here. But again, it is not about the issue we are trying to discuss :)

@konstantinvlasenko
Copy link
Owner Author

I think the main issue is that we have removed this ELSE https://github.com/konstantinvlasenko/PowerSlim/pull/71/files#diff-3a586a9b299992da7ba63a2496a138f2L312 for non-terminating error.
We should just return the error as the result of the script execution. But not as SLIM exception. What do you think?

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

The main problem with previous version was concerned with skipping such statements:
|eval|$somevar=Get-XXXFeature|
where Get-XXXFeature write some very important info in std error (that is actually visible in powershell console). My idea was to highlight such test yellow.

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

(if I understood you right, powerslim will not show the error if we just return it as result of script execution)

@konstantinvlasenko
Copy link
Owner Author

It will if you will use |check| or |show|

@konstantinvlasenko
Copy link
Owner Author

Maybe we should introduce a global setting?! $NonTerminatingIsException = $true In this case we'll use your new approach. What do you think?

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

It will if you will use |check| or |show|

I remember several times I received such test reports:
|eval|...something..may not broke..| # but it broken for unpredictable moment, and the result of this was very interesting
|check|eval|Get-XXXFeature|...|
it comes out I created |PS| scenario that executed |show|eval|@script|, then I modified slim.ps1 and got rid of |PS| scenario.

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

BTW, not only me used this |PS| scenario:)

@konstantinvlasenko
Copy link
Owner Author

So what we are going to do?
I don't want to Test-Path before calling Remove-Item.

@konstantinvlasenko
Copy link
Owner Author

I think the $NonTerminatingIsException = $true should be enough for your case. You can always set it to TRUE. But by default it should be FALSE.

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

NonTerminatingIsException flag is ok for me. I agree with you, It can be painful if there are already a lot if rmdir and remove-items in suite.

@konstantinvlasenko
Copy link
Owner Author

remove-items is just one example :) It can be Remove-SPWeb or DELETE method for any REST API for non-existing object. Basically we are talking about any cleanup operation. I don't want to check the existence of something before removing it.
Can you make this change?

@2xmax
Copy link
Contributor

2xmax commented May 7, 2015

ok, will do

2xmax added a commit to 2xmax/PowerSlim that referenced this issue May 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants