Skip to content

Commit 3ff04de

Browse files
committed
collect test result files
1 parent 16f82a0 commit 3ff04de

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

eng/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ steps:
2424
command: test
2525
arguments: -c $(BuildConfiguration) --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[coverlet.collector]*%2c[coverlet.core]*%2c[coverlet.msbuild.tasks]*" /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*"
2626
testRunTitle: $(Agent.JobName)
27+
28+
- template: publish-coverlet-results.yml

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)