Skip to content

Commit 9de4e64

Browse files
committed
Add cpp tests under release docker image.
1. Added C++ tests under the release docker image. 2. Fixed a compile issue with the docker image. 3. Cleaned up tests.sh and removed traivis stuff.
1 parent 78944e1 commit 9de4e64

File tree

5 files changed

+29
-107
lines changed

5 files changed

+29
-107
lines changed

autogen.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ fi
2828

2929
set -ex
3030

31+
# The absence of a m4 directory in googletest causes autoreconf to fail when
32+
# building under the CentOS docker image. It's a warning in regular build on
33+
# Ubuntu/gLinux as well.
34+
mkdir -p third_party/googletest/m4
35+
3136
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
3237
autoreconf -f -i -Wall,no-obsolete
3338

kokoro/linux/cpp_distcheck/build.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
# Change to repo root
66
cd $(dirname $0)/../../..
77

8-
# Prepare worker environment to run tests
9-
source kokoro/linux/prepare_build_linux_rc
10-
118
./tests.sh cpp_distcheck
9+
10+
# Run tests under release docker image.
11+
DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ")
12+
docker pull $DOCKER_IMAGE_NAME
13+
14+
docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \
15+
bash -l /var/local/protobuf/tests.sh cpp || FAILED="true"
16+
17+
if [ "$FAILED" = "true" ]; then
18+
exit 1
19+
fi

kokoro/linux/pull_request_in_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
WORKSPACE_BASE=`pwd`
77
MY_DIR="$(dirname "$0")"
8-
TEST_SCRIPT=$MY_DIR/../../tests.sh
8+
TEST_SCRIPT=./tests.sh
99
BUILD_DIR=/tmp/protobuf
1010

1111
set -e # exit immediately on error

src/google/protobuf/map_entry.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ class MapEntry
9595
typedef void InternalArenaConstructable_;
9696
typedef void DestructorSkippable_;
9797

98-
using typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
99-
kValueFieldType,
100-
default_enum_value>::KeyTypeHandler;
101-
using typename MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType,
102-
kValueFieldType,
103-
default_enum_value>::ValueTypeHandler;
98+
typedef typename MapEntryImpl<
99+
Derived, Message, Key, Value, kKeyFieldType, kValueFieldType,
100+
default_enum_value>::KeyTypeHandler KeyTypeHandler;
101+
typedef typename MapEntryImpl<
102+
Derived, Message, Key, Value, kKeyFieldType, kValueFieldType,
103+
default_enum_value>::ValueTypeHandler ValueTypeHandler;
104104
size_t SpaceUsedLong() const override {
105105
size_t size = sizeof(Derived);
106106
size += KeyTypeHandler::SpaceUsedInMapEntryLong(this->key_);

tests.sh

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#!/bin/bash
22
#
3-
# Build and runs tests for the protobuf project. The tests as written here are
4-
# used by both Jenkins and Travis, though some specialized logic is required to
5-
# handle the differences between them.
6-
7-
on_travis() {
8-
if [ "$TRAVIS" == "true" ]; then
9-
"$@"
10-
fi
11-
}
3+
# Build and runs tests for the protobuf project. We use this script to run
4+
# tests on kokoro (Ubuntu and MacOS). It can run locally as well but you
5+
# will need to make sure the required compilers/tools are available.
126

137
# For when some other test needs the C++ main build, including protoc and
148
# libprotobuf.
@@ -18,15 +12,6 @@ internal_build_cpp() {
1812
return
1913
fi
2014

21-
if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then
22-
# Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
23-
# decent C++ 11 support in order to compile conformance tests.
24-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
25-
sudo apt-get update -qq
26-
sudo apt-get install -qq g++-4.8
27-
export CXX="g++-4.8" CC="gcc-4.8"
28-
fi
29-
3015
# Initialize any submodules.
3116
git submodule update --init --recursive
3217

@@ -43,8 +28,6 @@ build_cpp() {
4328

4429
# The benchmark code depends on cmake, so test if it is installed before
4530
# trying to do the build.
46-
# NOTE: The travis macOS images say they have cmake, but the xcode8.1 image
47-
# appears to be missing it: https://github.com/travis-ci/travis-ci/issues/6996
4831
if [[ $(type cmake 2>/dev/null) ]]; then
4932
# Verify benchmarking code can build successfully.
5033
cd benchmarks && make cpp-benchmark && cd ..
@@ -121,10 +104,6 @@ build_golang() {
121104
# Add protoc to the path so that the examples build finds it.
122105
export PATH="`pwd`/src:$PATH"
123106

124-
# Install Go and the Go protobuf compiler plugin.
125-
on_travis sudo apt-get update -qq
126-
on_travis sudo apt-get install -qq golang
127-
128107
export GOPATH="$HOME/gocode"
129108
mkdir -p "$GOPATH/src/github.com/google"
130109
rm -f "$GOPATH/src/github.com/google/protobuf"
@@ -139,27 +118,17 @@ use_java() {
139118
version=$1
140119
case "$version" in
141120
jdk7)
142-
on_travis sudo apt-get install openjdk-7-jdk
143121
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
144122
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
145123
;;
146124
oracle7)
147-
if [ "$TRAVIS" == "true" ]; then
148-
sudo apt-get install python-software-properties # for apt-add-repository
149-
echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
150-
sudo debconf-set-selections
151-
yes | sudo apt-add-repository ppa:webupd8team/java
152-
yes | sudo apt-get install oracle-java7-installer
153-
fi;
154125
export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
155126
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
156127
;;
157128
esac
158129

159-
if [ "$TRAVIS" != "true" ]; then
160-
MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
161-
MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
162-
fi;
130+
MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
131+
MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
163132

164133
which java
165134
java -version
@@ -190,12 +159,6 @@ build_java_with_conformance_tests() {
190159
cd conformance && make test_java && cd ..
191160
}
192161

193-
build_javanano() {
194-
# Java build needs `protoc`.
195-
internal_build_cpp
196-
cd javanano && $MVN test && cd ..
197-
}
198-
199162
build_java_jdk7() {
200163
use_java jdk7
201164
build_java_with_conformance_tests
@@ -213,38 +176,6 @@ build_java_compatibility() {
213176
./test.sh 3.0.0-beta-4
214177
}
215178

216-
build_javanano_jdk7() {
217-
use_java jdk7
218-
build_javanano
219-
}
220-
build_javanano_oracle7() {
221-
use_java oracle7
222-
build_javanano
223-
}
224-
225-
internal_install_python_deps() {
226-
if [ "$TRAVIS" != "true" ]; then
227-
return;
228-
fi
229-
# Install tox (OS X doesn't have pip).
230-
if [ $(uname -s) == "Darwin" ]; then
231-
brew upgrade python
232-
python3 -m pip install tox
233-
else
234-
sudo pip install tox
235-
fi
236-
# Only install Python2.6/3.x on Linux.
237-
if [ $(uname -s) == "Linux" ]; then
238-
sudo apt-get install -y python-software-properties # for apt-add-repository
239-
sudo apt-add-repository -y ppa:fkrull/deadsnakes
240-
sudo apt-get update -qq
241-
sudo apt-get install -y python3.3 python3.3-dev
242-
sudo apt-get install -y python3.4 python3.4-dev
243-
sudo apt-get install -y python3.5 python3.5-dev
244-
sudo apt-get install -y python3.6 python3.6-dev
245-
fi
246-
}
247-
248179
build_objectivec_ios() {
249180
# Reused the build script that takes care of configuring and ensuring things
250181
# are up to date. The OS X test runs the objc conformance test, so skip it
@@ -279,9 +210,7 @@ build_objectivec_cocoapods_integration() {
279210

280211
build_python() {
281212
internal_build_cpp
282-
internal_install_python_deps
283213
cd python
284-
# Only test Python 2.6/3.x on Linux
285214
if [ $(uname -s) == "Linux" ]; then
286215
envlist=py\{27,33,34,35,36\}-python
287216
else
@@ -293,11 +222,9 @@ build_python() {
293222

294223
build_python_cpp() {
295224
internal_build_cpp
296-
internal_install_python_deps
297225
export LD_LIBRARY_PATH=../src/.libs # for Linux
298226
export DYLD_LIBRARY_PATH=../src/.libs # for OS X
299227
cd python
300-
# Only test Python 3.x on Linux
301228
if [ $(uname -s) == "Linux" ]; then
302229
envlist=py\{27,33,34,35,36\}-cpp
303230
else
@@ -337,21 +264,12 @@ build_ruby25() {
337264
internal_build_cpp # For conformance tests.
338265
cd ruby && bash travis-test.sh ruby-2.5.0 && cd ..
339266
}
340-
build_jruby() {
341-
internal_build_cpp # For conformance tests.
342-
# TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be
343-
# fixed.
344-
cd ruby && bash travis-test.sh jruby-1.7 && cd ..
345-
}
346267
build_ruby_all() {
347268
build_ruby21
348269
build_ruby22
349270
build_ruby23
350271
build_ruby24
351272
build_ruby25
352-
# TODO(teboring): Disable jruby test temperarily for it randomly fails.
353-
# https://grpc-testing.appspot.com/job/protobuf_pull_request/735/consoleFull.
354-
# build_jruby
355273
}
356274

357275
build_javascript() {
@@ -632,14 +550,6 @@ build_php_all() {
632550
build_php_compatibility
633551
}
634552

635-
# Note: travis currently does not support testing more than one language so the
636-
# .travis.yml cheats and claims to only be cpp. If they add multiple language
637-
# support, this should probably get updated to install steps and/or
638-
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
639-
640-
# .travis.yml uses matrix.exclude to block the cases where app-get can't be
641-
# use to install things.
642-
643553
# -------- main --------
644554

645555
if [ "$#" -ne 1 ]; then
@@ -650,8 +560,6 @@ Usage: $0 { cpp |
650560
java_jdk7 |
651561
java_oracle7 |
652562
java_compatibility |
653-
javanano_jdk7 |
654-
javanano_oracle7 |
655563
objectivec_ios |
656564
objectivec_ios_debug |
657565
objectivec_ios_release |
@@ -680,4 +588,5 @@ fi
680588

681589
set -e # exit immediately on error
682590
set -x # display all commands
591+
cd $(dirname $0)
683592
eval "build_$1"

0 commit comments

Comments
 (0)