如何在 AppVeyor 中设置构建配置依赖变量

How to set build configuration-dependent variable in AppVeyor

对于 Visual Studio 的调试构建配置,我想从 CTest 中排除某些测试。我的想法是做类似

的事情
matrix:
  - configuration: Release
    environment:
      EXCLUDETESTS: ""
  - configuration: Debug
    environment:
      EXCLUDETESTS: "solver"

为每个配置创建一个名为 EXCLUDETESTS 的相应字符串环境变量。 但这给了我 Error parsing appveyor.yml: "matrix" section must be a mapping. (Line: 15, Column: 3),尽管根据 http://yaml-online-parser.appspot.com/

语法应该没问题

完整的 appveyor.yml 文件读取

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%

请检查Exclude configuration from the matrix。像这样的东西应该适合你:

configuration:
- Debug
- Release

environment:
  matrix:  
    - EXCLUDETESTS: solver
    - EXCLUDETESTS:

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