blob: 54d28dfc2608de484b196c89641f3b9345bdf7f4 [file] [log] [blame]
Austin Schuh40c16522018-10-28 20:27:54 -07001#!/bin/bash
2
3function run_test() {
4 # Generate test proto files.
5 ./protoc_1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \
6 --csharp_opt=base_namespace=Google.Protobuf \
7 protos/src/google/protobuf/unittest_import_proto3.proto \
8 protos/src/google/protobuf/unittest_import_public_proto3.proto \
9 protos/src/google/protobuf/unittest_well_known_types.proto
10
11 ./protoc_1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
12 --csharp_opt=base_namespace=UnitTest.Issues \
13 protos/csharp/protos/unittest_issues.proto
14
15 ./protoc_2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \
16 --csharp_opt=base_namespace=Google.Protobuf \
17 protos/src/google/protobuf/unittest_proto3.proto \
18 protos/src/google/protobuf/map_unittest_proto3.proto
19
20 # Build and test.
21 dotnet restore src/Google.Protobuf/Google.Protobuf.csproj
22 dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
23 dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
24 dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
25 dotnet run -c Release -f netcoreapp1.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
26}
27
28set -ex
29
30# Change to the script's directory.
31cd $(dirname $0)
32
33# Version of the tests (i.e., the version of protobuf from where we extracted
34# these tests).
35TEST_VERSION=3.0.0
36
37# The old version of protobuf that we are testing compatibility against. This
38# is usually the same as TEST_VERSION (i.e., we use the tests extracted from
39# that version to test compatibility of the newest runtime against it), but it
40# is also possible to use this same test set to test the compatibiilty of the
41# latest version against other versions.
42case "$1" in
43 ""|3.0.0)
44 OLD_VERSION=3.0.0
45 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
46 ;;
47 3.0.2)
48 OLD_VERSION=3.0.2
49 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
50 ;;
51 3.1.0)
52 OLD_VERSION=3.1.0
53 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
54 ;;
55 *)
56 echo "[ERROR]: Unknown version number: $1"
57 exit 1
58 ;;
59esac
60
61echo "Running compatibility tests with $OLD_VERSION"
62
63# Check protoc
64[ -f ../../../src/protoc ] || {
65 echo "[ERROR]: Please build protoc first."
66 exit 1
67}
68
69# Download old version protoc compiler (for linux).
70wget $OLD_VERSION_PROTOC -O old_protoc
71chmod +x old_protoc
72
73# Test source compatibility. In these tests we recompile everything against
74# the new runtime (including old version generated code).
75# Copy the new runtime and keys.
76cp ../../src/Google.Protobuf src/Google.Protobuf -r
77cp ../../keys . -r
78
79# Test A.1:
80# proto set 1: use old version
81# proto set 2 which may import protos in set 1: use old version
82cp old_protoc protoc_1
83cp old_protoc protoc_2
84run_test
85
86# Test A.2:
87# proto set 1: use new version
88# proto set 2 which may import protos in set 1: use old version
89cp ../../../src/protoc protoc_1
90cp old_protoc protoc_2
91run_test
92
93# Test A.3:
94# proto set 1: use old version
95# proto set 2 which may import protos in set 1: use new version
96cp old_protoc protoc_1
97cp ../../../src/protoc protoc_2
98run_test
99
100rm protoc_1
101rm protoc_2
102rm old_protoc
103rm keys -r
104rm src/Google.Protobuf -r