Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
Add unit-tests for Joda convert.
Browse files Browse the repository at this point in the history
Also adds a common script to get test repos from github.

Issue j2objc-contrib#30
  • Loading branch information
advayDev1 committed Oct 2, 2015
1 parent 8144a8e commit 77f2fbd
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 22 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ os: osx
# Add a TEST_DIR=[directory] row for each library (or group of libraries) to test
# Each will be run as an independent, hermetic test (in parallel when resources permit)
# on Traivs.
# TEST_TASKS specifies the Gradle tasks to run.
env:
- TEST_DIR=com.google.code.gson-gson
- TEST_DIR=org.joda-joda-convert
- TEST_DIR=joda-time-joda-time
- TEST_DIR=org.joda-joda-primitives
- TEST_DIR=org.apache.commons-commons-lang3
- TEST_DIR=com.google.code.gson-gson TEST_TASKS=build
- TEST_DIR=org.joda-joda-convert TEST_TASKS=build
- TEST_DIR=joda-time-joda-time TEST_TASKS=build
- TEST_DIR=org.joda-joda-primitives TEST_TASKS=build
- TEST_DIR=org.apache.commons-commons-lang3 TEST_TASKS=build

# Uncomment to add a library that should fail to build, along with documentation on why.
# matrix:
Expand Down Expand Up @@ -44,4 +45,4 @@ install:

# Note the install prep leaves us in the libraryBuilds directory.
script:
- ./run-test.sh $TEST_DIR
- ./run-test.sh $TEST_DIR $TEST_TASKS
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 @@ -19,9 +19,6 @@ dependencies {
}

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

// Almost always there are no tests provided in an external source jar.
testMinExpectedTests 0
finalConfigure()
Expand Down
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
cp -R test-repo/$TEST_DIR_IN_REPO src/test
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ dependencies {
}

j2objcConfig {
// package-info.java in multiple packages.
filenameCollisionCheck false

// Blocked on https://github.com/j2objc-contrib/j2objc-gradle/issues/465
// to support test-sources.jar.
testMinExpectedTests 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
dependencies {
j2objcTranslation 'org.joda:joda-convert:1.8:sources'
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.11'
}

j2objcConfig {
testPattern {
// Do not include subdirectories. Their files prefixed with Test
// are support classes, not tests.
include 'src/test/java/org/joda/convert/*Test.java'
}
autoConfigureDeps true

// No tests in the sources.jar.
testMinExpectedTests 0
finalConfigure()
}
17 changes: 17 additions & 0 deletions libraryBuilds/org.joda-joda-convert/org.joda-joda-convert/prep.sh
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 v1.8 https://github.com/JodaOrg/joda-convert src/test
10 changes: 5 additions & 5 deletions libraryBuilds/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# Fail if anything fails.
set -ev

./run-test.sh com.google.code.gson-gson
./run-test.sh org.joda-joda-convert
./run-test.sh joda-time-joda-time
./run-test.sh org.joda-joda-primitives
./run-test.sh org.apache.commons-commons-lang3
./run-test.sh com.google.code.gson-gson build
./run-test.sh org.joda-joda-convert build
./run-test.sh joda-time-joda-time build
./run-test.sh org.joda-joda-primitives build
./run-test.sh org.apache.commons-commons-lang3 build
20 changes: 18 additions & 2 deletions libraryBuilds/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@
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
# 2nd through last arguments are the gradle tasks to test.
for task in "${@:2}"; do
./gradlew $task
done
./gradlew assemble
popd

0 comments on commit 77f2fbd

Please sign in to comment.