如何在AppVeyor中设置构建配置相关的变量

时间:2017-09-08 11:40:44

标签: visual-studio continuous-integration appveyor

对于Visual Studio的Debug构建配置,我想从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%

1 个答案:

答案 0 :(得分:1)

请检查Exclude configuration from the matrix。这样的事情对你有用:

configuration:
- Debug
- Release

environment:
  matrix:  
    - EXCLUDETESTS: solver
    - EXCLUDETESTS:

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