Skip to content

Commit ae05b55

Browse files
committed
collect test result files
1 parent 16f82a0 commit ae05b55

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

cleanup-coverage-result.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
del /s /Q coverage.cobertura.xml
2+
del /s /Q coverage.json
3+
for /d /r . %%d in (TestResults bin obj) do @if exist "%%d" rd /s/q "%%d"
4+
dotnet build
5+
dotnet pack -c debug
6+
rem dotnet test
7+

eng/publish-coverlet-results.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
steps:
2+
- task: Powershell@2
3+
displayName: Prepare coverage files to Upload
4+
inputs:
5+
targetType: inline
6+
pwsh: true
7+
script: |
8+
New-Item -ItemType Directory "$(Build.SourcesDirectory)/artifacts/TestLogs/"
9+
function Copy-FileKeepPath {
10+
param (
11+
$filter,$FileToCopy,$des,$startIndex
12+
)
13+
Get-ChildItem -Path $FileToCopy -Filter $filter -Recurse -File | ForEach-Object {
14+
$fileName = $_.FullName
15+
#Remove the first part to ignore from the path.
16+
$newdes=Join-Path -Path $des -ChildPath $fileName.Substring($startIndex)
17+
$folder=Split-Path -Path $newdes -Parent
18+
$err=0
19+
20+
#check if folder exists"
21+
$void=Get-Item $folder -ErrorVariable err -ErrorAction SilentlyContinue
22+
if($err.Count -ne 0){
23+
#create when it doesn't
24+
$void=New-Item -Path $folder -ItemType Directory -Force -Verbose
25+
}
26+
27+
$void=Copy-Item -Path $fileName -destination $newdes -Recurse -Container -Force -Verbose
28+
}
29+
}
30+
$logfiles = "coverage.opencover.xml", "coverage.cobertura.xml", "coverage.json", "log.txt", "log.datacollector.*.txt", "log.host.*.txt"
31+
foreach ($logfile in $logfiles ) {
32+
Copy-FileKeepPath -FileToCopy "$(Build.SourcesDirectory)/test/coverlet.integration.tests/bin/*" -des "$(Build.SourcesDirectory)/artifacts/TestLogs/" -filter $logfile -startIndex "$(Build.SourcesDirectory)/test/coverlet.integration.tests/bin/".Length
33+
}
34+
35+
continueOnError: true
36+
condition: always()
37+
38+
- task: PublishPipelineArtifact@1
39+
displayName: Publish coverage logs
40+
continueOnError: true
41+
condition: always()
42+
inputs:
43+
path: artifacts/TestLogs
44+
artifactName: TestLogs_$(Agent.Os)_$(BuildConfiguration)

0 commit comments

Comments
 (0)