首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么Travis在运行单元测试时没有找到rospy?

为什么Travis在运行单元测试时没有找到rospy?
EN

Stack Overflow用户
提问于 2020-11-14 17:25:32
回答 1查看 42关注 0票数 1

我们有单元测试,需要ro间谍(其中一个测试使用几何_msgs/Twist)。

当我们在本地运行单元测试时,一切都很好。

代码语言:javascript
复制
pytest
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/cedric/Programming/robotics-prototype, inifile: pytest.ini
collected 10 items                                                             

tests/unit/branch_name_test.py ......                                    [ 60%]
tests/unit/drive_controls_test.py ..                                     [ 80%]
tests/unit/import_test.py ..                                             [100%]

========================== 10 passed in 2.73 seconds ===========================

当我们在特拉维斯上运行的时候,它就失败了。这是因为它找不到间谍。我们的Travis安装安装了ROS,成功地运行了catkin_make,但是在单元测试中失败了。

回购是公开的,所以如果您对完整的travis日志感兴趣,请单击这里

代码语言:javascript
复制
os: linux
dist: bionic
language: python
cache:
  - apt
env:
  global:
    - REPO_ROOT=$(pwd)
    - ARDUINO_IDE_VERSION="1.8.12"
    - ARDUINO_PATH="$HOME/arduino-$ARDUINO_IDE_VERSION" # Required for CMake script
    - TEENSYDUINO_VERSION="152"
    - ROS_PYTHON_VERSION="3.6"
    - ROS_VERSION="melodic"
    - OS_VERSION="bionic"

install:
  # Taken from this tutorial https://github.com/newdigate/teensy-blink
  - mkdir -p robot/rover/build
  - mkdir -p ~/Arduino/libraries
  - wget --quiet https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz
  - tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz -C /home/$USER/
  - curl -fsSL https://www.pjrc.com/teensy/td_$TEENSYDUINO_VERSION/TeensyduinoInstall.linux64 -o TeensyduinoInstall.linux64
  - chmod +x TeensyduinoInstall.linux64
  - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
  - sleep 3
  - export DISPLAY=:1.0
  - ./TeensyduinoInstall.linux64 --dir=$ARDUINO_PATH
  
  # Install pip dependencies and setup robot python package
  - pip install -r requirements.txt -r requirements-dev.txt
  - pip install -e .
    
  # Install ros-base and necessary packages 
  - sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $OS_VERSION main\" > /etc/apt/sources.list.d/ros-latest.list"
  - sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  - sudo apt update -q
  - sudo apt install -y ros-$ROS_VERSION-ros-base ros-$ROS_VERSION-cv-camera ros-$ROS_VERSION-web-video-server 
  - sudo apt install -y python-rosdep python-wstool 
    
  # Install ros package dependencies
  - cd $REPO_ROOT/robot/rospackages
  - sudo rosdep init
  - rosdep update 
  - rosdep install -y -r --from-paths src --ignore-src --rosdistro $ROS_VERSION

script:
  # Set up 'robot' python module and test python installation
  - cd $REPO_ROOT
  - python setup.py develop
  - pytest --continue-on-collection-errors

  # Set up and initialize catkin workspace for ros packages
  - cd $REPO_ROOT/robot/rospackages
  - source /opt/ros/$ROS_VERSION/setup.bash
  - catkin_make

  # Allow to compile arduino code in external IDEs or something
  - cd $REPO_ROOT/robot/rover/build
  - cmake ..
  - make
    
notifications:
  email:
    recipients:
      - (hidden for the purpose of the question)
    on_success: change
    on_failure: change

python:
  - "3.6"

git:
  submodules: true
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-14 23:25:29

在寻找ROS环境之前,您似乎正在调用该测试。你需要改变这一点:

代码语言:javascript
复制
script:
  # Set up and initialize catkin workspace for ros packages
  - cd $REPO_ROOT/robot/rospackages
  - source /opt/ros/$ROS_VERSION/setup.bash
  - catkin_make

  # Set up 'robot' python module and test python installation
  - cd $REPO_ROOT
  - python setup.py develop
  - pytest --continue-on-collection-errors
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64836600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档