From 21fa0bad0e6adfff3ae563da3aa4955904c2ed7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Wed, 15 May 2024 22:08:18 +0000 Subject: [PATCH 1/3] Cleand Up Build Output --- Build/CommonFunctionsAndMethods.psm1 | 36 +++++++++++++------------- Build/LocalBuild.ps1 | 21 ++++++++------- Build/tSQLt_Build/ConcatenateFiles.ps1 | 24 ++++++++--------- Build/tSQLt_BuildCLR.ps1 | 2 +- Build/tSQLt_BuildDacpac.ps1 | 4 +-- 5 files changed, 44 insertions(+), 43 deletions(-) diff --git a/Build/CommonFunctionsAndMethods.psm1 b/Build/CommonFunctionsAndMethods.psm1 index 92b1eb98e..c389f6403 100644 --- a/Build/CommonFunctionsAndMethods.psm1 +++ b/Build/CommonFunctionsAndMethods.psm1 @@ -1,6 +1,6 @@ $__=$__ #quiesce warnings $CommonFunctionsAndMethodsDir = $PSScriptRoot -Write-Host "Loading CommonFunctionsAndMethods.psm1 from: $PSCommandPath" +Write-Verbose "Loading CommonFunctionsAndMethods.psm1 from: $PSCommandPath" . (Join-Path $CommonFunctionsAndMethodsDir 'SQLServerConnection.ps1'); $MergeHashTables = {param([HashTable]$base,[HashTable]$new);$new.GetEnumerator()|%{$base.remove($_.Key);$base += @{$_.Key=$_.Value}};$base;}; @@ -40,10 +40,10 @@ Function Invoke-SqlFile $parameters['Verbose'] = $true } - $dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") $results = (Invoke-SqlCmd @parameters) - $dddafter = Get-Date;Write-Warning("------->>After<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") - Write-Warning("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") + $dddafter = Get-Date;Write-Verbose("------->>After<<-------(CommonFunctionsAndMethods.p1:Invoke-SqlFile:Invoke-SqlCommand[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + Write-Verbose("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") return $results } @@ -100,9 +100,9 @@ Function Invoke-SQLFileOrQuery AdditionalParameters = $AdditionalParameters PrintSqlOutput = $PrintSqlOutput } -$dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") +$dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") $QueryOutput = Invoke-SqlFile @parameters -$dddafter = Get-Date;Write-Warning("------->>After<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") +$dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") $dddafter-$dddbefore return $QueryOutput } @@ -186,8 +186,8 @@ Function Remove-ResourceGroup{ [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $ResourceGroupName, [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $BuildId); - Write-Output "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; - Write-Output ("[{0}]Start processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)); + Write-Verbose "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; + Write-Verbose ("[{0}]Start processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)); $MyAzResourceGroup = (Get-AzResourceGroup -name "$ResourceGroupName"); if(("RemovalBy" -in $MyAzResourceGroup.tags.keys) -and (![string]::isnullorempty($MyAzResourceGroup.tags.RemovalBy))) { @@ -195,37 +195,37 @@ Function Remove-ResourceGroup{ } if($null -ne $MyAzResourceGroup) { $Tags = @{}; - Write-Output ("Add Tag to {0}" -f $ResourceGroupName); + Write-Verbose ("Add Tag to {0}" -f $ResourceGroupName); $Tags = $MyAzResourceGroup.Tags; $Tags.remove("RemovalBy"); $Tags += @{"RemovalBy"="$BuildId"}; $MyAzResourceGroup | Set-AzResourceGroup -Tags $Tags; Start-Sleep 10; - Write-Output ("Confirming Tags are still in place for {0}" -f $ResourceGroupName); + Write-Verbose ("Confirming Tags are still in place for {0}" -f $ResourceGroupName); $MyAzResourceGroup = $MyAzResourceGroup | Get-AZResourceGroup | Where-Object {$_.Tags.RemovalBy -eq "$BuildId"}; $MyAzResourceGroup.Tags | Format-Table; if($null -ne $MyAzResourceGroup) { - Write-Output "Removing Locks" + Write-Verbose "Removing Locks" $retrievedResourceGroupName = $MyAzResourceGroup.ResourceGroupName; Get-AzResource -ResourceGroupName $retrievedResourceGroupName | ForEach-Object { Get-AzResourceLock -ResourceType $_.ResourceType -ResourceName $_.Name -ResourceGroupName $_.ResourceGroupName | ForEach-Object{ - Write-Output ("{0} -> {1}" -f $_.ResourceType, $_.ResourceName); + Write-Verbose ("{0} -> {1}" -f $_.ResourceType, $_.ResourceName); $_ | Remove-AzResourceLock -Force } } - Write-Output ("Removing RG {0}" -f $retrievedResourceGroupName); + Write-Verbose ("Removing RG {0}" -f $retrievedResourceGroupName); $MyAzResourceGroup | Remove-AzResourceGroup -Force; } else { - Write-Output ("Tags changed by another process. Resource Group {0} is no longer eligible to be deleted." -f $ResourceGroupName); + Write-Verbose ("Tags changed by another process. Resource Group {0} is no longer eligible to be deleted." -f $ResourceGroupName); } } else { - Write-Output ("Processing skipped for Resource Group: {0} Build Id: {1}" -f $ResourceGroupName, $BuildId); + Write-Verbose ("Processing skipped for Resource Group: {0} Build Id: {1}" -f $ResourceGroupName, $BuildId); } - Write-Output ("[{0}]Done processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)) - Write-Output "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; + Write-Verbose ("[{0}]Done processing delete for {1}" -f ((get-date).toString("O")), ($ResourceGroupName)) + Write-Verbose "▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-▀-▄-_-▄-"; } Function Get-SnipContent { @@ -267,7 +267,7 @@ Function Replace-InFile { $isRegex = $true $rv = $rv[0] } - Write-Host("Replacing >$_< with >$rv<..."); + Write-Verbose("Replacing >$_< with >$rv<..."); if($isRegex){ $fileContent = $fileContent -replace $_, $rv }else{ diff --git a/Build/LocalBuild.ps1 b/Build/LocalBuild.ps1 index 1075f0aad..e8bd67647 100644 --- a/Build/LocalBuild.ps1 +++ b/Build/LocalBuild.ps1 @@ -1,3 +1,4 @@ +[CmdletBinding()] param( [Parameter(Mandatory=$false)][ValidateNotNullOrEmpty()][string] $ServerName = 'localhost,1433', [Parameter(Mandatory=$true, ParameterSetName = 'UserPass')][ValidateNotNullOrEmpty()][string] $UserName = "sa" , @@ -12,12 +13,12 @@ param( $PSDefaultParameterValues = $PSDefaultParameterValues.clone() $PSDefaultParameterValues += @{'*:ErrorAction' = 'Stop'} -Write-Host "Starting execution of LocalBuild.ps1" +Write-Verbose "Starting execution of LocalBuild.ps1" $__=$__ #quiesce warnings $invocationDir = $PSScriptRoot Push-Location -Path $invocationDir $cfam = (Join-Path $invocationDir "CommonFunctionsAndMethods.psm1" | Resolve-Path) -Write-Host "Attempting to load module from: $cfam" +Write-Verbose "Attempting to load module from: $cfam" Import-Module "$cfam" -Force -Verbose . (Join-Path $invocationDir 'SQLServerConnection.ps1'); @@ -36,20 +37,20 @@ $invocationDir = $PSScriptRoot Push-Location -Path $invocationDir try{ - if($TrustedConnection){ - Write-Warning('GH:TC') - $SqlServerConnection = [SqlServerConnection]::new($ServerName,"LocalBuild"); - }else{ - Write-Warning('GH:UP') - $SqlServerConnection = [SqlServerConnection]::new($ServerName,$UserName,$Password,"LocalBuild"); - } - Log-Output(''); Log-Output("+--------------------------------------------------------------------+"); Log-Output("| ***** Executing Local tSQLt Build ***** |"); Log-Output("+--------------------------------------------------------------------+"); Log-Output(''); + if($TrustedConnection){ + Log-Output('Selecting Trusted Connection') + $SqlServerConnection = [SqlServerConnection]::new($ServerName,"LocalBuild"); + }else{ + Log-Output('Selecting UserName/Password Connection') + $SqlServerConnection = [SqlServerConnection]::new($ServerName,$UserName,$Password,"LocalBuild"); + } + Log-Output('+ - - - - - - - - - - - - - - - - - +') Log-Output(': Cleaning Environment :') diff --git a/Build/tSQLt_Build/ConcatenateFiles.ps1 b/Build/tSQLt_Build/ConcatenateFiles.ps1 index ac7fdf527..1375262b6 100644 --- a/Build/tSQLt_Build/ConcatenateFiles.ps1 +++ b/Build/tSQLt_Build/ConcatenateFiles.ps1 @@ -58,7 +58,7 @@ function Concatenate-Files { $output = @() foreach ($file in $fileIterator) { - Write-Host("-->$file") + Write-Verbose("-->$file") $fileContent = Get-FileContent -filePath $file -bracket $bracket -includeFromStart $includeFromStart -separator $separator $output += $fileContent } @@ -66,9 +66,9 @@ function Concatenate-Files { return $output } -Write-Host("OutputFile: $OutputFile") -Write-Host("SeparatorTemplate: >$SeparatorTemplate<") -Write-Host("Input: $InputPath") +Write-Verbose("OutputFile: $OutputFile") +Write-Verbose("SeparatorTemplate: >$SeparatorTemplate<") +Write-Verbose("Input: $InputPath") if([string]::IsNullOrWhiteSpace($SeparatorTemplate)){ if($null -eq $SeparatorContent){ @@ -78,9 +78,9 @@ if([string]::IsNullOrWhiteSpace($SeparatorTemplate)){ else{ $SeparatorContent = Get-Content $SeparatorTemplate -ErrorAction Stop } -Write-Host(">--Separator Template-->") -$SeparatorContent|%{Write-Host(">:$_")} -Write-Host("<--Separator Template--<") +Write-Verbose(">--Separator Template-->") +$SeparatorContent|%{Write-Verbose(">:$_")} +Write-Verbose("<--Separator Template--<") if($Bracket -eq ''){ $IncludeFromStart = $true; } @@ -88,20 +88,20 @@ if($Bracket -eq ''){ try{ if($null -eq $InputPath){ - Write-Host("scriptPath: ") + Write-Verbose("scriptPath: ") $fileIterator = @() } elseif($InputPath -is [System.Collections.IEnumerable]){ - Write-Host("scriptPath: /") + Write-Verbose("scriptPath: /") $fileIterator = $InputPath } elseif (Test-Path $InputPath -PathType Container) { - Write-Host("scriptPath: $InputPath") + Write-Verbose("scriptPath: $InputPath") $fileIterator = Get-ChildItem $InputPath -Filter $IncludePattern } else { $scriptPath = (Split-Path $InputPath) - Write-Host("scriptPath: $scriptPath") + Write-Verbose("scriptPath: $scriptPath") $fileList = Get-Content $InputPath -ErrorAction Stop $fileIterator = $fileList | ForEach-Object { Join-Path $scriptPath $_ | Resolve-Path} } @@ -111,7 +111,7 @@ try{ $sv = $_["s"] $rv=$_["r"]; $isRegex = $_.ContainsKey("isRegex") -and $_["isRegex"]; - Write-Host("Replacing >$sv< with >$rv< [regex:$isRegex]..."); + Write-Verbose("Replacing >$sv< with >$rv< [regex:$isRegex]..."); if($isRegex){ $concatenatedContent = $concatenatedContent -replace $sv, $rv }else{ diff --git a/Build/tSQLt_BuildCLR.ps1 b/Build/tSQLt_BuildCLR.ps1 index c7afc2333..7acc1733a 100644 --- a/Build/tSQLt_BuildCLR.ps1 +++ b/Build/tSQLt_BuildCLR.ps1 @@ -4,7 +4,7 @@ param( [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][securestring] $pfxPassword ) Push-Location -Path $PSScriptRoot -Write-Warning((Get-Location).Path) +Write-Verbose((Get-Location).Path) try{ $OutputPath = "./output/tSQLtCLR/"; $TempPath = "./temp/tSQLtCLR/"; diff --git a/Build/tSQLt_BuildDacpac.ps1 b/Build/tSQLt_BuildDacpac.ps1 index 823138ec3..b23e6daa1 100644 --- a/Build/tSQLt_BuildDacpac.ps1 +++ b/Build/tSQLt_BuildDacpac.ps1 @@ -12,7 +12,7 @@ $__=$__ #quiesce warnings $invocationDir = $PSScriptRoot Push-Location -Path $invocationDir $cfam = (Join-Path $invocationDir "CommonFunctionsAndMethods.psm1" | Resolve-Path) -Write-Host "Attempting to load module from: $cfam" +Write-Verbose "Attempting to load module from: $cfam" Import-Module "$cfam" -Force Get-Module -Name CommonFunctionsAndMethods # Verify if module is loaded @@ -41,7 +41,7 @@ try{ Invoke-SqlFile -SqlServerConnection $SqlServerConnection -FileNames "CreateBuildDb.sql" -Database "tempdb" -AdditionalParameters @{NewDbName=$DacPacDatabaseName} -PrintSqlOutput $true; Log-Output('-- Executing tSQLt.class.sql') Invoke-SqlFile -SqlServerConnection $SqlServerConnection -FileNames "tSQLt.class.sql" -Database "$DacPacDatabaseName"; - Write-Host('Building DACPAC') + Log-Output('Building DACPAC') $FriendlySQLServerVersion = Get-FriendlySQLServerVersion -SqlServerConnection $SqlServerConnection; $tSQLtDacpacFileName = "tSQLt."+$FriendlySQLServerVersion+".dacpac"; $tSQLtApplicationName = "tSQLt."+$FriendlySQLServerVersion; From 2c6018827019bf7deb9606c9d71c417072313366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Thu, 16 May 2024 00:07:34 +0000 Subject: [PATCH 2/3] Cleaned up Validate --- Build/CommonFunctionsAndMethods.psm1 | 4 ++-- Build/LocalValidate.ps1 | 9 +++++---- Build/tSQLt_Validate.ps1 | 18 +++++++++++++----- Build/tSQLt_ValidateRunAll.ps1 | 18 +++++++++--------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Build/CommonFunctionsAndMethods.psm1 b/Build/CommonFunctionsAndMethods.psm1 index c389f6403..63f51d5ee 100644 --- a/Build/CommonFunctionsAndMethods.psm1 +++ b/Build/CommonFunctionsAndMethods.psm1 @@ -103,8 +103,8 @@ Function Invoke-SQLFileOrQuery $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") $QueryOutput = Invoke-SqlFile @parameters $dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-SQLFileOrQuery:Invoke-SqlFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") -$dddafter-$dddbefore - return $QueryOutput +Write-Verbose("Runtime in Milliseconds: $(($dddafter-$dddbefore).TotalMilliseconds)") + return $QueryOutput } catch{ throw diff --git a/Build/LocalValidate.ps1 b/Build/LocalValidate.ps1 index b317aea39..dd14882a0 100644 --- a/Build/LocalValidate.ps1 +++ b/Build/LocalValidate.ps1 @@ -1,3 +1,4 @@ +[CmdletBinding()] param( [Parameter(Mandatory=$false)][ValidateNotNullOrEmpty()][string] $ServerName = 'localhost,1433', [Parameter(Mandatory=$true, ParameterSetName = 'UserPass')][ValidateNotNullOrEmpty()][string] $UserName = "sa" , @@ -9,12 +10,12 @@ param( $PSDefaultParameterValues = $PSDefaultParameterValues.clone() $PSDefaultParameterValues += @{'*:ErrorAction' = 'Stop'} -Write-Host "Starting execution of LocalBuild.ps1" +Write-Verbose "Starting execution of LocalBuild.ps1" $__=$__ #quiesce warnings $invocationDir = $PSScriptRoot Push-Location -Path $invocationDir $cfam = (Join-Path $invocationDir "CommonFunctionsAndMethods.psm1" | Resolve-Path) -Write-Host "Attempting to load module from: $cfam" +Write-Verbose "Attempting to load module from: $cfam" Import-Module "$cfam" -Force -Verbose . (Join-Path $invocationDir 'SQLServerConnection.ps1'); @@ -22,10 +23,10 @@ Import-Module "$cfam" -Force -Verbose try{ if($TrustedConnection){ - Write-Warning('GH:TC') + Log-Output('Selecting Trusted Connection') $SqlServerConnection = [SqlServerConnection]::new($ServerName,"LocalBuild"); }else{ - Write-Warning('GH:UP') + Log-Output('Selecting UserName/Password Connection') $SqlServerConnection = [SqlServerConnection]::new($ServerName,$UserName,$Password,"LocalBuild"); } diff --git a/Build/tSQLt_Validate.ps1 b/Build/tSQLt_Validate.ps1 index 28203f6d0..9e2bedd28 100644 --- a/Build/tSQLt_Validate.ps1 +++ b/Build/tSQLt_Validate.ps1 @@ -9,7 +9,7 @@ Param( ); - +$validateStartTime = Get-Date; $__=$__ #quiesce warnings $invocationDir = $PSScriptRoot @@ -206,15 +206,23 @@ try{ $matchingFiles = ($ActualTestResultFiles|Where-Object{$ExpectedTestResultFiles -Contains $_}) Write-Warning("Matching Files:") $matchingFiles - Write-Warning("Missing Files:") - $missingFiles - Write-Warning("Unexpected Files:") - $superfluousFiles + if($missingFiles.length -gt 0){ + Write-Warning("There are files missing:"); + $missingFiles + } + if($superfluousFiles.length -gt 0){ + Write-Warning("There are unexpected files:") + $superfluousFiles + } if($missingFiles.Length + $superfluousFiles.Length -gt 0){ Write-Error("Missing or Unexpected Test Result Files!") } } finally{ Pop-Location + $validateEndTime = Get-Date; + Log-Output("------------------------------------") + Log-Output("Total Duration: $($validateEndTime-$validateStartTime)") + Log-Output("------------------------------------") } diff --git a/Build/tSQLt_ValidateRunAll.ps1 b/Build/tSQLt_ValidateRunAll.ps1 index 10e54f9a2..963cc6553 100644 --- a/Build/tSQLt_ValidateRunAll.ps1 +++ b/Build/tSQLt_ValidateRunAll.ps1 @@ -67,16 +67,16 @@ Function Invoke-Tests DatabaseName = $DatabaseName PrintSqlOutput = $true } - $dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") $parameters; Invoke-SQLFileOrQuery @parameters; - $dddafter = Get-Date;Write-Warning("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") - $dddafter-$dddbefore + $dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + Write-Verbose("Duration: $($dddafter-$dddbefore)") - $dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Copy-SQLXmlToFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Copy-SQLXmlToFile[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") Copy-SQLXmlToFile $SqlServerConnection $DatabaseName "EXEC [tSQLt].[XmlResultFormatter]" $OutputFile - $dddafter = Get-Date;Write-Warning("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Copy-SQLXmlToFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") - $dddafter-$dddbefore + $dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Copy-SQLXmlToFile[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + Write-Verbose("Duration: $($dddafter-$dddbefore)") $parameters = @{ SqlServerConnection = $SqlServerConnection @@ -84,11 +84,11 @@ Function Invoke-Tests DatabaseName = $DatabaseName Query = "EXEC tSQLt_testutil.LogMultiRunResult '$TestSetName';" } - $dddbefore = Get-Date;Write-Warning("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + $dddbefore = Get-Date;Write-Verbose("------->>BEFORE<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddbefore|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") # $parameters; Invoke-SQLFileOrQuery @parameters; - $dddafter = Get-Date;Write-Warning("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") - $dddafter-$dddbefore + $dddafter = Get-Date;Write-Verbose("------->>After<<-------(tSQLt_Validate.ps1:Invoke-Tests:Invoke-SQLFileOrQuery[$($dddafter|Get-Date -Format "yyyy:MM:dd;HH:mm:ss.fff")])") + Write-Verbose("Duration: $($dddafter-$dddbefore)") } Function Invoke-TestsFromFile From a256930f975f6ee73a52418a303acc59840cb906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmbt1=E2=80=9D?= Date: Thu, 16 May 2024 01:06:00 +0000 Subject: [PATCH 3/3] cleaned up final output --- Build/tSQLt_Validate.ps1 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Build/tSQLt_Validate.ps1 b/Build/tSQLt_Validate.ps1 index 9e2bedd28..22ff1d02b 100644 --- a/Build/tSQLt_Validate.ps1 +++ b/Build/tSQLt_Validate.ps1 @@ -204,16 +204,24 @@ try{ $missingFiles = ($ExpectedTestResultFiles|Where-Object{$ActualTestResultFiles -NotContains $_}) $superfluousFiles = ($ActualTestResultFiles|Where-Object{$ExpectedTestResultFiles -NotContains $_}) $matchingFiles = ($ActualTestResultFiles|Where-Object{$ExpectedTestResultFiles -Contains $_}) - Write-Warning("Matching Files:") - $matchingFiles + Log-Output("+------------------------------------------------"); + Log-Output("| Expected Test Result Files:"); + $matchingFiles|%{Log-Output("| - $_");} + Log-Output("+------------------------------------------------"); if($missingFiles.length -gt 0){ - Write-Warning("There are files missing:"); - $missingFiles + Log-Output("| Missing Test Result Files:"); + $missingFiles|%{Log-Output("| - $_");} + }else{ + Log-Output("| No Missing Test Result Files"); } + Log-Output("+------------------------------------------------"); if($superfluousFiles.length -gt 0){ - Write-Warning("There are unexpected files:") - $superfluousFiles + Log-Output("| Unexpected Test Result Files:") + $superfluousFiles|%{Log-Output("| - $_");} + }else{ + Log-Output("| No Unexpected Test Result Files"); } + Log-Output("+------------------------------------------------"); if($missingFiles.Length + $superfluousFiles.Length -gt 0){ Write-Error("Missing or Unexpected Test Result Files!") }