I am trying to parse a Pester script and extract values ββfrom a parameter -Tag. Does anyone know how to do this using [System.Management.Automation.PSParser]? I thought I would have to scroll through the tokens returned from [System.Management.Automation.PSParser]::Tokenize(), but this seems pretty kludgy and given that the values ββfor -Tagcan be provided in many different formats, and not very practical.
At the end of the day, I hope to return a collection with the name of the block Describeand a list of tags (if any) for this block.
Name Tags
---- ----
Section1 {tag1, tag2}
Section2 {foo, bar}
Section3 {asdf}
Section4 {}
Here is an example of the Pester tests I am working with.
describe 'Section1' -Tag @('tag1', 'tag2') {
it 'blah1' {
$true | should be $true
}
}
describe 'Section2' -Tag 'foo', 'bar' {
it 'blah2' {
$true | should be $true
}
}
describe 'Section3' -Tag 'asdf'{
it 'blah3' {
$true | should be $true
}
}
describe 'Section4' {
it 'blah4' {
$true | should be $true
}
}
Anyone have any ideas on how to solve this? Is the [System.Management.Automation.PSParser]right way or is there a better way?
Greetings