如何在没有 运行 C++ 的情况下在一个 .travis.yml 中同时测试 Python 和 C++?

How to test both Python and C++ in one .travis.yml without running the C++ multiple times?

https://github.com/travis-ci/travis-ci/issues/538 似乎并没有真正的帮助。我有这个 .travis.yml for libais:

language: python

python:
  - "2.7"
  - "3.4"

before_install:
  - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
  - sudo apt-get update -qq

install:
  - sudo apt-get install -qq gcc-4.8 g++-4.8
  - CC=g++-4.8 python setup.py install

script:
  - python setup.py test
  - (cd src && CC=gcc-4.8 CXX=g++-4.8 make -f Makefile-custom test)

脚本的最后一行触发了 c++ 测试。

运行 libais gunit C++ 测试很棒,但遗憾的是,它们得到 运行 2 倍。每个 python 版本一次。我不想给 travis-ci 添加额外的负载。有办法吗?

一个快速的想法:也许您可以在决定 运行 您的 C++ 测试之前检查文件是否存在?

例如

- [[ -f $FILE ]] || (cd src && CC=gcc-4.8 CXX=g++-4.8 make -f Makefile-custom test)

要检查的文件可以是例如您的 C++ 单元测试报告。如果它已经存在,请不要 运行 他们第二次。

根据 Dominic 的回答,我查看了 http://docs.travis-ci.com/user/ci-environment/ 并找到了 TRAVIS_PYTHON_VERSION。所以不需要 fiddle 任何文件。

script:
  - python setup.py test
  - if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then (cd src && CC=gcc-4.8 CXX=g++-4.8 make -f Makefile-custom test); fi