Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Pipelines: Investigate uploading test logs as artifacts #2557

Closed
StephanTLavavej opened this issue Feb 9, 2022 · 1 comment · Fixed by #2575
Closed

Azure Pipelines: Investigate uploading test logs as artifacts #2557

StephanTLavavej opened this issue Feb 9, 2022 · 1 comment · Fixed by #2575
Labels
fixed Something works now, yay! infrastructure Related to repository automation test Related to test code

Comments

@StephanTLavavej
Copy link
Member

StephanTLavavej commented Feb 9, 2022

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'

@StephanTLavavej StephanTLavavej added infrastructure Related to repository automation test Related to test code labels Feb 9, 2022
@cbezault
Copy link
Contributor

I think there should already be a way to get at the xml file behind the log output but otherwise what you've described will definitely work. Just add another publish block and you'll be good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! infrastructure Related to repository automation test Related to test code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants