parameters:
- name: buildPlatform
- name: buildConfiguration
- name: buildArguments

steps:
- checkout: self
  lfs: true

- task: Bash@3
  displayName: 'Create Build Directory'
  inputs:
    targetType: 'inline'
    script: 'mkdir build'

- task: CMake@1
  displayName: 'CMake Configure'
  inputs:
    workingDirectory: build
    cmakeArgs: '.. -A ${{ parameters.buildPlatform }} ${{ parameters.buildArguments }}'

- task: CMake@1
  displayName: 'CMake Build'
  inputs:
    workingDirectory: build
    cmakeArgs: '--build . --config ${{ parameters.buildConfiguration }}'

- bash: 'ctest -T test --no-compress-output'
  workingDirectory: build
  failOnStderr: true
  displayName: 'Run Tests'

- task: PublishTestResults@2
  condition: true
  inputs:
    testResultsFormat: 'CTest'
    testRunTitle: 'Windows CTest ${{ parameters.buildPlatform }} ${{ parameters.buildConfiguration }} ${{ parameters.buildArguments}}'
    testResultsFiles: '**/Test.xml'