How to set build configuration-dependent variable in AppVeyor

743 Views Asked by At

For the Debug build configuration of Visual Studio, I want to exclude certain tests from CTest. My idea was to do something like

matrix:
  - configuration: Release
    environment:
      EXCLUDETESTS: ""
  - configuration: Debug
    environment:
      EXCLUDETESTS: "solver"

i.e. creating a corresponding string environment variable called EXCLUDETESTS per configuration. But this gives me Error parsing appveyor.yml: "matrix" section must be a mapping. (Line: 15, Column: 3), though the syntax should be fine according to http://yaml-online-parser.appspot.com/

The complete appveyor.yml file reads

version: "{build}"

os:
  - Visual Studio 2017
  - Visual Studio 2015

# x64 is a CMake-compatible solution platform name.
# This allows us to pass %PLATFORM% to CMake -A.
platform:
  - x64

# Build Configurations, i.e. Debug, Release, etc.
# EXCLUDETESTS determines which tests will not be run
matrix:
  - configuration: Release
    environment:
      EXCLUDETESTS: ""
  - configuration: Debug
    environment:
      EXCLUDETESTS: "solver"

environment:
  - PYTHON: "C:\\Python36-x64"

# Cmake will autodetect the compiler, but we set the arch
before_build:
  - set PATH=%PYTHON%;%PATH%
  - set CXXFLAGS=%additional_flags%
  - cmake -H. -BBuild -A%PLATFORM% -DUI_CXX_USE_QT=OFF

# Build with MSBuild
build:
  project: Build\spirit.sln # path to Visual Studio solution or project
  parallel: true            # enable MSBuild parallel builds
  verbosity: normal         # MSBuild verbosity level {quiet|minimal|normal|detailed}

install:
  - "%PYTHON%/Scripts/pip.exe install numpy"

test_script:
  - cd Build
  - ctest --output-on-failure -C %CONFIGURATION% -E %EXCLUDETESTS%
1

There are 1 best solutions below

0
On BEST ANSWER

Please check Exclude configuration from the matrix. Something like this should work for you:

configuration:
- Debug
- Release

environment:
  matrix:  
    - EXCLUDETESTS: solver
    - EXCLUDETESTS:

matrix:
  exclude:
    - configuration: Release
      EXCLUDETESTS: solver
    - configuration: Debug
      EXCLUDETESTS: