test.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 build -c release src/Google.Protobuf src/Google.Protobuf.Test
  18. dotnet test -c release -f netcoreapp1.0 src/Google.Protobuf.Test
  19. }
  20. set -ex
  21. # Change to the script's directory.
  22. cd $(dirname $0)
  23. # Version of the tests (i.e., the version of protobuf from where we extracted
  24. # these tests).
  25. TEST_VERSION=3.0.0
  26. # The old version of protobuf that we are testing compatibility against. This
  27. # is usually the same as TEST_VERSION (i.e., we use the tests extracted from
  28. # that version to test compatibility of the newest runtime against it), but it
  29. # is also possible to use this same test set to test the compatibiilty of the
  30. # latest version against other versions.
  31. case "$1" in
  32. ""|3.0.0)
  33. OLD_VERSION=3.0.0
  34. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
  35. ;;
  36. 3.0.2)
  37. OLD_VERSION=3.0.2
  38. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
  39. ;;
  40. 3.1.0)
  41. OLD_VERSION=3.1.0
  42. OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
  43. ;;
  44. *)
  45. echo "[ERROR]: Unknown version number: $1"
  46. exit 1
  47. ;;
  48. esac
  49. echo "Running compatibility tests with $OLD_VERSION"
  50. # Check protoc
  51. [ -f ../../../src/protoc ] || {
  52. echo "[ERROR]: Please build protoc first."
  53. exit 1
  54. }
  55. # Download old version protoc compiler (for linux).
  56. wget $OLD_VERSION_PROTOC -O old_protoc
  57. chmod +x old_protoc
  58. # Test source compatibility. In these tests we recompile everything against
  59. # the new runtime (including old version generated code).
  60. # Copy the new runtime and keys.
  61. cp ../../src/Google.Protobuf src/Google.Protobuf -r
  62. cp ../../keys . -r
  63. dotnet restore
  64. # Test A.1:
  65. # proto set 1: use old version
  66. # proto set 2 which may import protos in set 1: use old version
  67. cp old_protoc protoc_1
  68. cp old_protoc protoc_2
  69. run_test
  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. cp ../../../src/protoc protoc_1
  74. cp old_protoc protoc_2
  75. run_test
  76. # Test A.3:
  77. # proto set 1: use old version
  78. # proto set 2 which may import protos in set 1: use new version
  79. cp old_protoc protoc_1
  80. cp ../../../src/protoc protoc_2
  81. run_test
  82. rm protoc_1
  83. rm protoc_2
  84. rm old_protoc
  85. rm keys -r
  86. rm src/Google.Protobuf -r