test.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. function run_test() {
  3. # Generate test proto files.
  4. $1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \
  5. --csharp_opt=base_namespace=Google.Protobuf \
  6. protos/src/google/protobuf/unittest_import_proto3.proto \
  7. protos/src/google/protobuf/unittest_import_public_proto3.proto \
  8. protos/src/google/protobuf/unittest_well_known_types.proto
  9. $1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
  10. --csharp_opt=base_namespace=UnitTest.Issues \
  11. protos/csharp/protos/unittest_issues.proto
  12. $2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \
  13. --csharp_opt=base_namespace=Google.Protobuf \
  14. protos/src/google/protobuf/unittest_proto3.proto \
  15. protos/src/google/protobuf/map_unittest_proto3.proto
  16. # Build and test.
  17. dotnet restore src/Google.Protobuf/Google.Protobuf.csproj
  18. dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  19. dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
  20. dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  21. dotnet run -c Release -f netcoreapp2.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  22. }
  23. set -ex
  24. # Change to the script's directory.
  25. cd $(dirname $0)
  26. # Version of the tests (i.e., the version of protobuf from where we extracted
  27. # these tests).
  28. TEST_VERSION=3.0.0
  29. # The old version of protobuf that we are testing compatibility against. This
  30. # is usually the same as TEST_VERSION (i.e., we use the tests extracted from
  31. # that version to test compatibility of the newest runtime against it), but it
  32. # is also possible to use this same test set to test the compatibility of the
  33. # latest version against other versions.
  34. OLD_VERSION=$1
  35. OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
  36. echo "Running compatibility tests with $OLD_VERSION"
  37. # Check protoc
  38. [ -f ../../../src/protoc ] || {
  39. echo "[ERROR]: Please build protoc first."
  40. exit 1
  41. }
  42. # Download old version protoc compiler (for linux).
  43. wget $OLD_VERSION_PROTOC -O old_protoc
  44. chmod +x old_protoc
  45. # Test source compatibility. In these tests we recompile everything against
  46. # the new runtime (including old version generated code).
  47. # Copy the new runtime and keys.
  48. cp ../../src/Google.Protobuf src/Google.Protobuf -r
  49. cp ../../keys . -r
  50. # Test A.1:
  51. # proto set 1: use old version
  52. # proto set 2 which may import protos in set 1: use old version
  53. run_test "./old_protoc" "./old_protoc"
  54. # Test A.2:
  55. # proto set 1: use new version
  56. # proto set 2 which may import protos in set 1: use old version
  57. run_test "../../../src/protoc" "./old_protoc"
  58. # Test A.3:
  59. # proto set 1: use old version
  60. # proto set 2 which may import protos in set 1: use new version
  61. run_test "./old_protoc" "../../../src/protoc"
  62. rm old_protoc
  63. rm keys -r
  64. rm src/Google.Protobuf -r