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