Skip to content

Commit

Permalink
Add unit-tests for gson.
Browse files Browse the repository at this point in the history
Also adds a common script to get test repos from github.
  • Loading branch information
advayDev1 committed Sep 28, 2015
1 parent 91b6093 commit 193c141
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libraryBuilds/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ gradlew.bat
# Generated by prep.sh
common/local.properties
localJ2objcDist/

# Generated by prep-tests.sh
test
test-repo/
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@

dependencies {
j2objcTranslation 'com.google.code.gson:gson:2.3.1:sources'

// If prep.sh is run, corresponding tests will be in src/test/java.
testCompile 'junit:junit:4.12'
}

test {
// https://github.com/j2objc-contrib/j2objc-common-libs-e2e-test/issues/35
exclude 'com/google/gson/functional/ThrowableFunctionalTest**'
}

j2objcConfig {
testPattern {
// https://github.com/j2objc-contrib/j2objc-common-libs-e2e-test/issues/35
exclude 'com/google/gson/functional/ThrowableFunctionalTest**'
}

// package-info.java exists in multiple packages.
filenameCollisionCheck false

// Almost always there are no tests provided in an external source jar.
testMinExpectedTests 0
finalConfigure()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

../../common/prep-tests.sh gson-2.3.1 https://github.com/google/gson.git src/test
28 changes: 28 additions & 0 deletions libraryBuilds/common/prep-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -v
rm -rf test-repo
rm -rf src/test
rm -rf src

set -ev
TAG=$1
REPO=$2
TEST_DIR_IN_REPO=$3
git clone --depth 1 --branch $TAG $REPO test-repo
mkdir src
ln -s ../test-repo/$TEST_DIR_IN_REPO src/test
14 changes: 13 additions & 1 deletion libraryBuilds/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@
set -ev

TEST_DIR=$1
echo Running test $TEST_DIR
pushd $TEST_DIR

echo Preparing test $TEST_DIR

# Execute the prep.sh files within this project, if any.
# These are often used to retrieve test sources for the libraries.
find . -name prep.sh | while read PREP_SCRIPT_FILE
do
pushd `dirname $PREP_SCRIPT_FILE`
sh prep.sh
popd
done

echo Running test $TEST_DIR
./gradlew wrapper
./gradlew clean
./gradlew build
Expand Down

0 comments on commit 193c141

Please sign in to comment.