test.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. function run_test() {
  3. # Generate test proto files.
  4. ./protoc_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. ./protoc_1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
  10. --csharp_opt=base_namespace=UnitTest.Issues \
  11. protos/csharp/protos/unittest_issues.proto
  12. ./protoc_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 netcoreapp1.0 -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 compatibiilty of the
  33. # latest version against other versions.
  34. case "$1" in
  35. ""|3.0.0)
  36. OLD_VERSION=3.0.0
  37. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
  38. ;;
  39. 3.0.2)
  40. OLD_VERSION=3.0.2
  41. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
  42. ;;
  43. 3.1.0)
  44. OLD_VERSION=3.1.0
  45. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
  46. ;;
  47. *)
  48. echo "[ERROR]: Unknown version number: $1"
  49. exit 1
  50. ;;
  51. esac
  52. echo "Running compatibility tests with $OLD_VERSION"
  53. # Check protoc
  54. [ -f ../../../src/protoc ] || {
  55. echo "[ERROR]: Please build protoc first."
  56. exit 1
  57. }
  58. # Download old version protoc compiler (for linux).
  59. wget $OLD_VERSION_PROTOC -O old_protoc
  60. chmod +x old_protoc
  61. # Test source compatibility. In these tests we recompile everything against
  62. # the new runtime (including old version generated code).
  63. # Copy the new runtime and keys.
  64. cp ../../src/Google.Protobuf src/Google.Protobuf -r
  65. cp ../../keys . -r
  66. # Test A.1:
  67. # proto set 1: use old version
  68. # proto set 2 which may import protos in set 1: use old version
  69. cp old_protoc protoc_1
  70. cp old_protoc protoc_2
  71. run_test
  72. # Test A.2:
  73. # proto set 1: use new version
  74. # proto set 2 which may import protos in set 1: use old version
  75. cp ../../../src/protoc protoc_1
  76. cp old_protoc protoc_2
  77. run_test
  78. # Test A.3:
  79. # proto set 1: use old version
  80. # proto set 2 which may import protos in set 1: use new version
  81. cp old_protoc protoc_1
  82. cp ../../../src/protoc protoc_2
  83. run_test
  84. rm protoc_1
  85. rm protoc_2
  86. rm old_protoc
  87. rm keys -r
  88. rm src/Google.Protobuf -r