-
-
Save bielawb/204131bead3630e6dec585956be7d3fe to your computer and use it in GitHub Desktop.
Wyszukiwanie bloku It za pomocą AST
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
$parsedTestFile = [System.Management.Automation.Language.Parser]::ParseFile($file.FullPath, [ref]$null, [ref]$null) | |
$myItBlock = $parsedTestFile.FindAll( | |
{ | |
param ( | |
$Ast | |
) | |
$Ast.CommandElements -and | |
$Ast.CommandElements[0].Value -eq 'It' -and | |
$Ast.Extent.StartLineNumber -le $lineNumber -and | |
$Ast.Extent.EndLineNumber -ge $lineNumber | |
}, | |
$true | |
) | |
if ($myItBlock) { | |
$config.Filter.Line = '{0}:{1}' -f $file.FullPath, $myItBlock[0].Extent.StartLineNumber | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment