Skip to content

Commit 69ce3d7

Browse files
antkmsftbenbp
andauthored
Show-FailureLogs to include vcpkg build failure logs (#5776)
* Show-FailureLogs to include vcpkg build failure logs * Add comment * Add proper array syntax * Use proper syntax to create an array even if there's only a single element Co-authored-by: Ben Broderick Phillips <ben@benbp.net> --------- Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
1 parent 22f5135 commit 69ce3d7

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

eng/scripts/Show-FailureLogs.ps1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# sensitive information.
77

88
$logFiles = Get-ChildItem -Recurse -Filter *.log
9-
$filteredLogs = $logFiles.Where({ $_.Name -in ('vcpkg-bootstrap.log', 'vcpkg-manifest-install.log') })
9+
$vcpkgLogFileNames = @('vcpkg-bootstrap.log', 'vcpkg-manifest-install.log')
10+
$filteredLogs = $logFiles.Where({ $_.Name -in $vcpkgLogFileNames })
1011

1112
$filteredLogs.FullName | Write-Host
1213

@@ -15,14 +16,33 @@ if (!$filteredLogs) {
1516
exit 0
1617
}
1718

18-
foreach ($logFile in $filteredLogs)
19+
$filteredLogs = @($filteredLogs.FullName)
20+
21+
for ($i = 0; $i -lt $filteredLogs.Length; $i += 1)
1922
{
23+
$logFile = $filteredLogs[$i]
24+
2025
Write-Host "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
2126
Write-Host "=============================================================================================================================="
2227
Write-Host "Log file: $logFile"
2328
Write-Host "=============================================================================================================================="
2429
try {
2530
Get-Content $logFile | Write-Host
31+
32+
# vcpkg logs do reference build log paths after "See logs for more information:". Sometimes there are multiple files to see.
33+
# And should there be a C++ build error, for example - that is where the error message would be.
34+
# So, we parse known logs (contained in vcpkgLogFileNames), and see if more logs are mentioned there. If there are extra logs,
35+
# we add them to the end of the list that we're iterating over, so that the format is the same, and this code gets reused
36+
# (i.e. formatting, Log file name header, try-catch, and so on).
37+
if ($i -lt $vcpkgLogFileNames.Length)
38+
{
39+
$rawContents = Get-Content $logFile -Raw
40+
$regexMatches = Select-String "See logs for more information\:\s*(\r|\n|\r\n|\n\r)(\s+(?<logFilePath>\S*)\s*(\r|\n|\r\n|\n\r))+" -input $rawContents -AllMatches
41+
foreach ($additionalLogFile in $regexMatches.matches.groups.Where({ $_.Name -eq "logFilePath" }))
42+
{
43+
$filteredLogs += $additionalLogFile.Value
44+
}
45+
}
2646
} catch {
2747
Write-Host "Could not locate file found using Get-ChildItem $logFile"
2848
}

0 commit comments

Comments
 (0)