Skip to content

Azure Pipelines: Investigate uploading test logs as artifacts #2557

@StephanTLavavej

Description

@StephanTLavavej

When tests fail, the error messages displayed in Azure Pipelines can be truncated if the command lines and/or error messages are very long (>4000 characters). Apparently, this is a limitation that can't be lifted or directly worked around. However, we should be able to upload the test logs as artifacts. run-tests.yml might be the file to modify:

# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
parameters:
- name: buildOutputLocationVar
type: string
default: buildOutputLocation
- name: targetPlatform
type: string
- name: hostArch
type: string
- name: targetArch
type: string
- name: displayName
type: string
default: 'Run Tests'
- name: publishArtifact
type: boolean
default: false
steps:
- task: CmdLine@2
displayName: ${{ parameters.displayName }}
timeoutInMinutes: 120
condition: succeeded()
inputs:
workingDirectory: $(${{ parameters.buildOutputLocationVar }})
script: |
call "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat" ^
-host_arch=${{ parameters.hostArch }} -arch=${{ parameters.targetArch }} -no_logo
ctest -V
env: { TMP: $(tmpDir), TEMP: $(tmpDir) }
- task: PublishTestResults@2
displayName: 'Publish Tests'
timeoutInMinutes: 10
condition: succeededOrFailed()
inputs:
searchFolder: $(${{ parameters.buildOutputLocationVar }})
testResultsFormat: JUnit
testResultsFiles: '**/test-results.xml'
testRunTitle: 'test-${{ parameters.targetPlatform }}-$(System.JobPositionInPhase)'
- publish: $(${{ parameters.buildOutPutLocationVar }})/out
artifact: '${{ parameters.targetPlatform }}-$(System.JobPositionInPhase)-libs-$(System.JobId)'
condition: ${{ parameters.publishArtifact }}
displayName: 'Publish Libs and Headers Artifact'
- publish: $(${{ parameters.buildOutPutLocationVar }})/tests
artifact: '${{ parameters.targetPlatform }}-$(System.JobPositionInPhase)-tests-$(System.JobId)'
condition: ${{ parameters.publishArtifact }}
displayName: 'Publish Tests Artifact'

I think these are the log files:

xmlOutputFlag: '--xunit-xml-output=$(${{ parameters.buildOutputLocationVar }})/test-results.xml'

xmlOutputFlag: '--xunit-xml-output=$(${{ parameters.buildOutputLocationVar }})/test-results.xml'

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!infrastructureRelated to repository automationtestRelated to test code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions