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

元气小坏坏 提交于 2019-12-07 18:57:56

问题


https://github.com/travis-ci/travis-ci/issues/538 doesn't seem to really help. I have this .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)

The last line of the script triggers the c++ testing.

It's great that it runs the libais gunit C++ tests, but sadly, they get run 2x. Once for each python version. I'd prefer not to add the additional load to travis-ci. Is there a way to do that?


回答1:


Based on Dominic's answer, I looked at http://docs.travis-ci.com/user/ci-environment/ and found TRAVIS_PYTHON_VERSION. So no need to fiddle with any files.

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



回答2:


A quick idea: maybe you could do a check for the existence of a file before deciding to run your C++ tests?

E.g.

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

The file to check for could be for example the report of your C++ unit tests. If it's already there, don't run them a second time.



来源:https://stackoverflow.com/questions/30404594/how-to-test-both-python-and-c-in-one-travis-yml-without-running-the-c-multi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!