test.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. set -e
  3. SRC_DIR=$(pwd)
  4. # NOTE: we must do all testing on the installed python package, not
  5. # on the build tree. Otherwise the testing is invalid and may not
  6. # indicate the code actually works
  7. # check format
  8. sep="##############################################"
  9. echo $sep
  10. echo "FORMAT TEST"
  11. echo $sep
  12. cd "$SRC_DIR"
  13. # ./scripts/format_xml.sh -c
  14. echo PASS
  15. generate_mavlink() {
  16. echo $sep
  17. echo "GENERATING MAVLINK " \
  18. "protocol:${wire_protocol} language:${lang}"
  19. echo "DEFINITION : " "$msg_def"
  20. echo $sep
  21. outdir="/tmp/mavlink_${wire_protocol}_${lang}"
  22. pymavlink/tools/mavgen.py --lang="${lang}" \
  23. --wire-protocol "${wire_protocol}" \
  24. --strict-units \
  25. --output="${outdir}" "${msg_def}"
  26. echo PASS
  27. }
  28. cd "$SRC_DIR"
  29. for msg_def in message_definitions/v1.0/*.xml
  30. do
  31. [ -e "$msg_def" ] || continue
  32. wire_protocol="1.0"
  33. for lang in Python C CS WLua Java
  34. do
  35. generate_mavlink
  36. done
  37. wire_protocol="2.0"
  38. for lang in Python C C++11 CS WLua Java
  39. do
  40. generate_mavlink
  41. done
  42. done
  43. # Avoid `spurious errors` caused by ~/.npm permission issues
  44. # ref: https://github.com/travis-ci/travis-ci/issues/2244
  45. # ref: https://github.com/npm/npm/issues/4815
  46. # Does it already exist? Who owns? What permissions?
  47. ls -lah ~/.npm || mkdir ~/.npm
  48. # Make sure we own it
  49. # $USER references the current user in Travis env
  50. chown -R "$USER" ~/.npm
  51. if [ -f /usr/bin/nodejs ]
  52. then
  53. mkdir -p ~/bin
  54. ln -sf /usr/bin/nodejs ~/bin/node
  55. . ~/.bashrc
  56. fi
  57. cd "$SRC_DIR/pymavlink/generator/javascript" && npm test