test.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. set -ex
  3. # Change to the script's directory.
  4. cd $(dirname $0)
  5. # Version of the tests (i.e., the version of protobuf from where we extracted
  6. # these tests).
  7. TEST_VERSION=2.5.0
  8. # The old version of protobuf that we are testing compatibility against. This
  9. # is usually the same as TEST_VERSION (i.e., we use the tests extracted from
  10. # that version to test compatibility of the newest runtime against it), but it
  11. # is also possible to use this same test set to test the compatibility of the
  12. # latest version against other versions.
  13. OLD_VERSION=$1
  14. OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
  15. # Extract the latest protobuf version number.
  16. VERSION_NUMBER=`grep "^__version__ = '.*'" ../../google/protobuf/__init__.py | sed "s|__version__ = '\(.*\)'|\1|"`
  17. echo "Running compatibility tests between current $VERSION_NUMBER and released $OLD_VERSION"
  18. # Check protoc
  19. [ -f ../../../src/protoc ] || {
  20. echo "[ERROR]: Please build protoc first."
  21. exit 1
  22. }
  23. # Test source compatibility. In these tests we recompile everything against
  24. # the new runtime (including old version generated code).
  25. rm google -f -r
  26. mkdir -p google/protobuf/internal
  27. # Build and copy the new runtime
  28. cd ../../
  29. python setup.py build
  30. cp google/protobuf/*.py compatibility_tests/v2.5.0/google/protobuf/
  31. cp google/protobuf/internal/*.py compatibility_tests/v2.5.0/google/protobuf/internal/
  32. cd compatibility_tests/v2.5.0
  33. cp tests/google/protobuf/internal/test_util.py google/protobuf/internal/
  34. cp google/protobuf/__init__.py google/
  35. # Download old version protoc compiler (for linux)
  36. wget $OLD_VERSION_PROTOC -O old_protoc
  37. chmod +x old_protoc
  38. # Test A.1:
  39. # proto set 1: use old version
  40. # proto set 2 which may import protos in set 1: use old version
  41. cp old_protoc protoc_1
  42. cp old_protoc protoc_2
  43. python setup.py build
  44. python setup.py test
  45. # Test A.2:
  46. # proto set 1: use new version
  47. # proto set 2 which may import protos in set 1: use old version
  48. cp ../../../src/protoc protoc_1
  49. cp old_protoc protoc_2
  50. python setup.py build
  51. python setup.py test
  52. # Test A.3:
  53. # proto set 1: use old version
  54. # proto set 2 which may import protos in set 1: use new version
  55. cp old_protoc protoc_1
  56. cp ../../../src/protoc protoc_2
  57. python setup.py build
  58. python setup.py test
  59. rm google -r -f
  60. rm build -r -f
  61. rm protoc_1
  62. rm protoc_2
  63. rm old_protoc