-
Notifications
You must be signed in to change notification settings - Fork 500
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
Interpret null Describe TestName to mean value can't be eval'd #1701
Merged
rjmholt
merged 2 commits into
master
from
rkeithhill/fix-pses-827-pester-testname-expandable-str
Jan 18, 2019
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,12 @@ export class PesterTestsFeature implements IFeature { | |
this.command = vscode.commands.registerCommand( | ||
"PowerShell.RunPesterTestsFromFile", | ||
() => { | ||
this.launchTests(vscode.window.activeTextEditor.document.uri, false); | ||
this.launchTests(vscode.window.activeTextEditor.document.uri, false, undefined); | ||
}); | ||
this.command = vscode.commands.registerCommand( | ||
"PowerShell.DebugPesterTestsFromFile", | ||
() => { | ||
this.launchTests(vscode.window.activeTextEditor.document.uri, true); | ||
this.launchTests(vscode.window.activeTextEditor.document.uri, true, undefined); | ||
}); | ||
// This command is provided for usage by PowerShellEditorServices (PSES) only | ||
this.command = vscode.commands.registerCommand( | ||
|
@@ -41,7 +41,21 @@ export class PesterTestsFeature implements IFeature { | |
this.languageClient = languageClient; | ||
} | ||
|
||
private launchTests(uriString, runInDebugger, describeBlockName?) { | ||
private async launchTests(uriString, runInDebugger, describeBlockName?) { | ||
// PSES passes null for the describeBlockName to signal that it can't evaluate the TestName. | ||
if (describeBlockName === null) { | ||
const answer = await vscode.window.showErrorMessage( | ||
"This Describe block's TestName parameter cannot be evaluated. " + | ||
`Would you like to ${runInDebugger ? "debug" : "run"} all the tests in this file?`, | ||
"Yes", "No"); | ||
|
||
if (answer === "Yes") { | ||
describeBlockName = undefined; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I would make this: if (answer === "No") {
return;
}
describeBlockName = undefined; but I recognise it's a style preference as much as anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that is cleaner. :-) I'll make the change. |
||
return; | ||
} | ||
} | ||
|
||
const uri = vscode.Uri.parse(uriString); | ||
const currentDocument = vscode.window.activeTextEditor.document; | ||
const settings = Settings.load(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
true, undefined
andfalse, undefined
are starting to look a bit hairy to my mind (i.e. in C# I'd look to use named parameters). Is there a way we could be more explicit about these parameters, like using TypeScript optional parameters or similar? More a question than a veiled suggestion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the same thought crossed my mind as I was coding it up. It can obviously be made to work but feels brittle. I think we could handle this better - perhaps have a fourth parameter to the
launch
function which indicates the desire is to debug/run the whole file. Let me take a crack at this tonight.