Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created July 11, 2022 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/204131bead3630e6dec585956be7d3fe to your computer and use it in GitHub Desktop.
Save bielawb/204131bead3630e6dec585956be7d3fe to your computer and use it in GitHub Desktop.
Wyszukiwanie bloku It za pomocą AST
$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