compatibility test between last released and current for java python php (#6441)


* compatibility tests between last released and the current version


diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh
index 7c6df4f..4ee88fc 100755
--- a/csharp/compatibility_tests/v3.0.0/test.sh
+++ b/csharp/compatibility_tests/v3.0.0/test.sh
@@ -34,35 +34,13 @@
 # these tests).
 TEST_VERSION=3.0.0
 
-LAST_RELEASED=3.9.0
-
 # The old version of protobuf that we are testing compatibility against. This
 # is usually the same as TEST_VERSION (i.e., we use the tests extracted from
 # that version to test compatibility of the newest runtime against it), but it
 # is also possible to use this same test set to test the compatibiilty of the
 # latest version against other versions.
-case "$1" in
-  ""|3.0.0)
-    OLD_VERSION=3.0.0
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
-    ;;
-  3.0.2)
-    OLD_VERSION=3.0.2
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
-    ;;
-  3.1.0)
-    OLD_VERSION=3.1.0
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
-    ;;
-  $LAST_RELEASED)
-    OLD_VERSION=$LAST_RELEASED
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
-    ;;
-  *)
-    echo "[ERROR]: Unknown version number: $1"
-    exit 1
-    ;;
-esac
+OLD_VERSION=$1
+OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
 
 echo "Running compatibility tests with $OLD_VERSION"
 
diff --git a/java/compatibility_tests/v2.5.0/test.sh b/java/compatibility_tests/v2.5.0/test.sh
index 8604378..f67dc76 100755
--- a/java/compatibility_tests/v2.5.0/test.sh
+++ b/java/compatibility_tests/v2.5.0/test.sh
@@ -17,41 +17,13 @@
 # that version to test compatibility of the newest runtime against it), but it
 # is also possible to use this same test set to test the compatibiilty of the
 # latest version against other versions.
-case "$1" in
-  ""|2.5.0)
-    OLD_VERSION=2.5.0
-    OLD_VERSION_PROTOC=https://github.com/xfxyjwf/protobuf-compiler-release/raw/master/v2.5.0/linux/protoc
-    ;;
-  2.6.1)
-    OLD_VERSION=2.6.1
-    OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
-    ;;
-  3.0.0-beta-1)
-    OLD_VERSION=3.0.0-beta-1
-    OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
-    ;;
-  3.0.0-beta-2)
-    OLD_VERSION=3.0.0-beta-2
-    OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
-    ;;
-  3.0.0-beta-3)
-    OLD_VERSION=3.0.0-beta-3
-    OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
-    ;;
-  3.0.0-beta-4)
-    OLD_VERSION=3.0.0-beta-4
-    OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
-    ;;
-  *)
-    echo "[ERROR]: Unknown version number: $1"
-    exit 1
-    ;;
-esac
+OLD_VERSION=$1
+OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
 
 # Extract the latest protobuf version number.
 VERSION_NUMBER=`grep "^  <version>.*</version>" ../../pom.xml | sed "s|  <version>\(.*\)</version>|\1|"`
 
-echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
+echo "Running compatibility tests between current $VERSION_NUMBER and released $OLD_VERSION"
 
 # Check protoc
 [ -f ../../../src/protoc ] || {
diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh
index f4af524..8e1a750 100755
--- a/php/tests/compatibility_test.sh
+++ b/php/tests/compatibility_test.sh
@@ -21,6 +21,8 @@
 
   $PROTOC1 --php_out=generated proto/test_include.proto
   $PROTOC2 --php_out=generated                 \
+    -I../../src -I.                            \
+    proto/empty/echo.proto                     \
     proto/test.proto                           \
     proto/test_no_namespace.proto              \
     proto/test_prefix.proto                    \
@@ -34,6 +36,7 @@
     proto/test_reserved_message_upper.proto    \
     proto/test_service.proto                   \
     proto/test_service_namespace.proto         \
+    proto/test_wrapper_type_setters.proto      \
     proto/test_descriptors.proto
 
   pushd ../../src
@@ -67,22 +70,13 @@
 # Change to the script's directory.
 cd $(dirname $0)
 
-# The old version of protobuf that we are testing compatibility against.
-case "$1" in
-  ""|3.5.0)
-    OLD_VERSION=3.5.0
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
-    ;;
-  *)
-    echo "[ERROR]: Unknown version number: $1"
-    exit 1
-    ;;
-esac
+OLD_VERSION=$1
+OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
 
 # Extract the latest protobuf version number.
 VERSION_NUMBER=`grep "PHP_PROTOBUF_VERSION" ../ext/google/protobuf/protobuf.h | sed "s|#define PHP_PROTOBUF_VERSION \"\(.*\)\"|\1|"`
 
-echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
+echo "Running compatibility tests between current $VERSION_NUMBER and released $OLD_VERSION"
 
 # Check protoc
 [ -f ../../src/protoc ] || {
diff --git a/python/compatibility_tests/v2.5.0/test.sh b/python/compatibility_tests/v2.5.0/test.sh
index 78c16ad..fb3e545 100755
--- a/python/compatibility_tests/v2.5.0/test.sh
+++ b/python/compatibility_tests/v2.5.0/test.sh
@@ -14,41 +14,13 @@
 # that version to test compatibility of the newest runtime against it), but it
 # is also possible to use this same test set to test the compatibiilty of the
 # latest version against other versions.
-case "$1" in
-  ""|2.5.0)
-    OLD_VERSION=2.5.0
-    OLD_VERSION_PROTOC=https://github.com/xfxyjwf/protobuf-compiler-release/raw/master/v2.5.0/linux/protoc
-    ;;
-  2.6.1)
-    OLD_VERSION=2.6.1
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
-    ;;
-  3.0.0-beta-1)
-    OLD_VERSION=3.0.0-beta-1
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
-    ;;
-  3.0.0-beta-2)
-    OLD_VERSION=3.0.0-beta-2
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
-    ;;
-  3.0.0-beta-3)
-    OLD_VERSION=3.0.0-beta-3
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
-    ;;
-  3.0.0-beta-4)
-    OLD_VERSION=3.0.0-beta-4
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
-    ;;
-  *)
-    echo "[ERROR]: Unknown version number: $1"
-    exit 1
-    ;;
-esac
+OLD_VERSION=$1
+OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
 
 # Extract the latest protobuf version number.
 VERSION_NUMBER=`grep "^__version__ = '.*'" ../../google/protobuf/__init__.py | sed "s|__version__ = '\(.*\)'|\1|"`
 
-echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
+echo "Running compatibility tests between current $VERSION_NUMBER and released $OLD_VERSION"
 
 # Check protoc
 [ -f ../../../src/protoc ] || {
diff --git a/tests.sh b/tests.sh
index 27db444..c0255be 100755
--- a/tests.sh
+++ b/tests.sh
@@ -6,6 +6,8 @@
 
 # For when some other test needs the C++ main build, including protoc and
 # libprotobuf.
+LAST_RELEASED=3.9.0
+
 internal_build_cpp() {
   if [ -f src/protoc ]; then
     # Already built.
@@ -148,7 +150,6 @@
   # Run csharp compatibility test between 3.0.0 and the current version.
   csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
 
-  LAST_RELEASED=3.9.0
   # Run csharp compatibility test between last released and the current version.
   csharp/compatibility_tests/v3.0.0/test.sh $LAST_RELEASED
 }
@@ -233,6 +234,9 @@
   # 3.0.0-beta-4 and the current version.
   cd java/compatibility_tests/v2.5.0
   ./test.sh 3.0.0-beta-4
+
+  # Test the last released and current version.
+  ./test.sh $LAST_RELEASED
 }
 build_java_linkage_monitor() {
   # Linkage Monitor checks compatibility with other Google libraries
@@ -406,6 +410,9 @@
   ./test.sh 2.5.0
   # Test between 3.0.0-beta-1 and the current version.
   ./test.sh 3.0.0-beta-1
+
+  # Test between last released and current version.
+  ./test.sh $LAST_RELEASED
 }
 
 build_ruby23() {
@@ -662,7 +669,7 @@
 
 build_php_compatibility() {
   internal_build_cpp
-  php/tests/compatibility_test.sh
+  php/tests/compatibility_test.sh $LAST_RELEASED
 }
 
 build_php7.1() {
diff --git a/update_compatibility_version.py b/update_compatibility_version.py
index 7e11151..574a415 100644
--- a/update_compatibility_version.py
+++ b/update_compatibility_version.py
@@ -49,20 +49,9 @@
   f.close()
 
 
-def UpdateCsharp():
-  RewriteTextFile('csharp/compatibility_tests/v3.0.0/test.sh',
-    lambda line : re.sub(
-      r'LAST_RELEASED=.*$',
-      'LAST_RELEASED=%s' % NEW_VERSION,
-      line))
+RewriteTextFile('tests.sh',
+  lambda line : re.sub(
+    r'LAST_RELEASED=.*$',
+    'LAST_RELEASED=%s' % NEW_VERSION,
+    line))
 
-def UpdateTests():
-  RewriteTextFile('tests.sh',
-    lambda line : re.sub(
-      r'LAST_RELEASED=.*$',
-      'LAST_RELEASED=%s' % NEW_VERSION,
-      line))
-
-
-UpdateCsharp()
-UpdateTests()