blob: 78c16ad1ca2bc48c3ffc2176afd56f38c4a8cf1f [file] [log] [blame]
Jie Luoea511492017-01-23 15:11:00 -08001#!/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 compatibiilty of the
16# latest version against other versions.
17case "$1" in
18 ""|2.5.0)
19 OLD_VERSION=2.5.0
20 OLD_VERSION_PROTOC=https://github.com/xfxyjwf/protobuf-compiler-release/raw/master/v2.5.0/linux/protoc
21 ;;
22 2.6.1)
23 OLD_VERSION=2.6.1
24 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
25 ;;
26 3.0.0-beta-1)
27 OLD_VERSION=3.0.0-beta-1
28 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
29 ;;
30 3.0.0-beta-2)
31 OLD_VERSION=3.0.0-beta-2
32 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
33 ;;
34 3.0.0-beta-3)
35 OLD_VERSION=3.0.0-beta-3
36 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
37 ;;
38 3.0.0-beta-4)
39 OLD_VERSION=3.0.0-beta-4
40 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
41 ;;
42 *)
43 echo "[ERROR]: Unknown version number: $1"
44 exit 1
45 ;;
46esac
47
48# Extract the latest protobuf version number.
49VERSION_NUMBER=`grep "^__version__ = '.*'" ../../google/protobuf/__init__.py | sed "s|__version__ = '\(.*\)'|\1|"`
50
51echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
52
53# Check protoc
54[ -f ../../../src/protoc ] || {
55 echo "[ERROR]: Please build protoc first."
56 exit 1
57}
58
59# Test source compatibility. In these tests we recompile everything against
60# the new runtime (including old version generated code).
61rm google -f -r
62mkdir -p google/protobuf/internal
63# Build and copy the new runtime
64cd ../../
65python setup.py build
66cp google/protobuf/*.py compatibility_tests/v2.5.0/google/protobuf/
67cp google/protobuf/internal/*.py compatibility_tests/v2.5.0/google/protobuf/internal/
68cd compatibility_tests/v2.5.0
69cp tests/google/protobuf/internal/test_util.py google/protobuf/internal/
70cp google/protobuf/__init__.py google/
71
72# Download old version protoc compiler (for linux)
73wget $OLD_VERSION_PROTOC -O old_protoc
74chmod +x old_protoc
75
76# Test A.1:
77# proto set 1: use old version
78# proto set 2 which may import protos in set 1: use old version
79cp old_protoc protoc_1
80cp old_protoc protoc_2
81python setup.py build
82python setup.py test
83
84# Test A.2:
85# proto set 1: use new version
86# proto set 2 which may import protos in set 1: use old version
87cp ../../../src/protoc protoc_1
88cp old_protoc protoc_2
89python setup.py build
90python setup.py test
91
92# Test A.3:
93# proto set 1: use old version
94# proto set 2 which may import protos in set 1: use new version
Jie Luo42e1e2a2017-01-30 15:23:35 -080095cp old_protoc protoc_1
96cp ../../../src/protoc protoc_2
97python setup.py build
98python setup.py test
Jie Luoea511492017-01-23 15:11:00 -080099
100rm google -r -f
101rm build -r -f
102rm protoc_1
103rm protoc_2
104rm old_protoc