Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions CanaryValidator/Canary.Utilities.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (Test-Path -Path "$PSScriptRoot\..\WTTLog.ps1")

$CurrentUseCase = @{}
[System.Collections.Stack] $UseCaseStack = New-Object System.Collections.Stack
filter timestamp {"$(Get-Date -Format HH:mm:ss.ffff): $_"}
filter timestamp {"$(Get-Date -Format "yyyy-MM-dd HH:mm:ss.ffff") $_"}


function Log-Info
Expand Down Expand Up @@ -51,14 +51,11 @@ function Log-JSONReport
[string] $Message
)
if ($Message)
{
if ($Message.Contains(": ["))
{
$time = $Message.Substring(0, $Message.IndexOf(": ["))
}
{
if ($Message.Contains("[START]"))
{
$name = $Message.Substring($Message.LastIndexOf(":") + 1).Trim().Replace("######", "").Trim()
$time = $Message.Substring(0, $Message.IndexOf("[")).Trim()
$name = $Message.Substring($Message.LastIndexOf(":") + 1).Trim()
if ($UseCaseStack.Count)
{
$nestedUseCase = @{
Expand All @@ -81,14 +78,19 @@ function Log-JSONReport
}
elseif ($Message.Contains("[END]"))
{
$time = $Message.Substring(0, $Message.IndexOf("[")).Trim()
$result = ""
if ($UseCaseStack.Peek().UseCase -and ($UseCaseStack.Peek().UseCase | Where-Object {$_.Result -eq "FAIL"}))
{
$result = "FAIL"
}
else
elseif ($Message.Contains("[RESULT = PASS]"))
{
$result = "PASS"
}
elseif ($Message.Contains("[RESULT = FAIL]"))
{
$result = $Message.Substring($Message.LastIndexOf("=") + 1).Trim().Replace("] ######", "").Trim()
$result = "FAIL"
}
$UseCaseStack.Peek().Add("Result", $result)
$UseCaseStack.Peek().Add("EndTime", $time)
Expand Down Expand Up @@ -256,7 +258,7 @@ function Invoke-Usecase
Log-Info ("Skipping Usecase: $Name")
return
}
Log-Info ("###### [START] Usecase: $Name ######`n")
Log-Info ("[START] Usecase: $Name`n")
if ($Global:wttLogFileName)
{
StartTest "CanaryGate:$Name"
Expand All @@ -278,7 +280,7 @@ function Invoke-Usecase
{
EndTest "CanaryGate:$Name" $true
}
Log-Info ("###### [END] Usecase: $Name ###### [RESULT = PASS] ######`n")
Log-Info ("[END] [RESULT = PASS] Usecase: $Name`n")
return $result | Out-Null
}
catch [System.Exception]
Expand All @@ -287,7 +289,7 @@ function Invoke-Usecase
Log-Info ("###### <FAULTING SCRIPTBLOCK> ######")
Log-Info ("$UsecaseBlock")
Log-Info ("###### </FAULTING SCRIPTBLOCK> ######")
Log-Error ("###### [END] Usecase: $Name ###### [RESULT = FAIL] ######`n")
Log-Error ("[END] [RESULT = FAIL] Usecase: $Name`n")
if ($Global:wttLogFileName)
{
EndTest "CanaryGate:$Name" $false
Expand Down