From 5fe1c431fa1c8eb0bb2f4d2e5d54a05032c398c8 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Mon, 26 Sep 2016 18:12:11 -0700 Subject: [PATCH] Make Get-PesterTag allow only one scope tag (CI, Feature, Priority) --- build.psm1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.psm1 b/build.psm1 index 958730aea..e8e969c52 100644 --- a/build.psm1 +++ b/build.psm1 @@ -537,7 +537,7 @@ function Get-PesterTag { foreach( $describe in $des) { $elements = $describe.CommandElements $lineno = $elements[0].Extent.StartLineNumber - $foundTag = $false + $foundPriorityTags = @() for ( $i = 0; $i -lt $elements.Count; $i++) { if ( $elements[$i].extent.text -match "^-t" ) { $vAst = $elements[$i+1] @@ -550,7 +550,7 @@ function Get-PesterTag { # These are valid tags also, but they are not the priority tags } elseif (@('CI', 'FEATURE', 'SCENARIO') -contains $_) { - $foundTag = $true + $foundPriorityTags += $_ } else { $warnings += "${fullname} includes improper tag '$_', line '$lineno'" @@ -560,8 +560,11 @@ function Get-PesterTag { } } } - if ( ! $foundTag ) { - $warnings += "${fullname} does not include -Tag in Describe, line '$lineno'" + if ( $foundPriorityTags.Count -eq 0 ) { + $warnings += "${fullname}:$lineno does not include -Tag in Describe" + } + elseif ( $foundPriorityTags.Count -gt 1 ) { + $warnings += "${fullname}:$lineno includes more then one scope -Tag: $foundPriorityTags" } } }