| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | function run_testscip-shell shell shell-project 0.0.0 run_test().() { |
| 4 | # Generate test proto files. |
| 5 | $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 | $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 | $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 net6.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj |
| 26 | } |
| 27 | |
| 28 | set -ex |
| 29 | |
| 30 | PROTOC=$(realpathscip-shell system . . realpath. ${2:-../../../bazel-bin/protoc}) |
| 31 | |
| 32 | # Change to the script's directory. |
| 33 | cd $(dirnamescip-shell system . . dirname. $0) |
| 34 | |
| 35 | # Version of the tests (i.e., the version of protobuf from where we extracted |
| 36 | # these tests). |
| 37 | TEST_VERSION=3.0.0 |
| 38 | |
| 39 | # The old version of protobuf that we are testing compatibility against. This |
| 40 | # is usually the same as TEST_VERSION (i.e., we use the tests extracted from |
| 41 | # that version to test compatibility of the newest runtime against it), but it |
| 42 | # is also possible to use this same test set to test the compatibility of the |
| 43 | # latest version against other versions. |
| 44 | OLD_VERSION=$1 |
| 45 | OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe |
| 46 | |
| 47 | echoscip-shell system . . echo. "Running compatibility tests with $OLD_VERSION" |
| 48 | |
| 49 | # Check protoc |
| 50 | [scip-shell system . . `[`. -f $PROTOC ] || { |
| 51 | echoscip-shell system . . echo. "[ERROR]: Please build protoc first." |
| 52 | exit 1 |
| 53 | } |
| 54 | |
| 55 | # Download old version protoc compiler (for linux). |
| 56 | wget $OLD_VERSION_PROTOC -O old_protoc |
| 57 | chmodscip-shell system . . chmod. +x old_protoc |
| 58 | |
| 59 | # Test source compatibility. In these tests we recompile everything against |
| 60 | # the new runtime (including old version generated code). |
| 61 | # Copy the new runtime and keys. |
| 62 | cpscip-shell system . . cp. ../../src/Google.Protobuf src/Google.Protobuf -r |
| 63 | cpscip-shell system . . cp. ../../keys . -r |
| 64 | |
| 65 | # Test A.1: |
| 66 | # proto set 1: use old version |
| 67 | # proto set 2 which may import protos in set 1: use old version |
| 68 | run_testscip-shell shell shell-project 0.0.0 run_test(). "./old_protoc" "./old_protoc" |
| 69 | |
| 70 | # Test A.2: |
| 71 | # proto set 1: use new version |
| 72 | # proto set 2 which may import protos in set 1: use old version |
| 73 | run_testscip-shell shell shell-project 0.0.0 run_test(). "$PROTOC" "./old_protoc" |
| 74 | |
| 75 | # Test A.3: |
| 76 | # proto set 1: use old version |
| 77 | # proto set 2 which may import protos in set 1: use new version |
| 78 | run_testscip-shell shell shell-project 0.0.0 run_test(). "./old_protoc" "$PROTOC" |
| 79 | |
| 80 | rmscip-shell system . . rm. old_protoc |
| 81 | rmscip-shell system . . rm. keys -r |
| 82 | rmscip-shell system . . rm. src/Google.Protobuf -r |