Skip to content

Commit

Permalink
script refactoring
Browse files Browse the repository at this point in the history
- Move scripts to top-level directory
- Allow autocomplete for test directory
- Add -u flag to set to warn on unbound environment variables
  • Loading branch information
brunobowden committed Oct 25, 2015
1 parent 02f5234 commit 7c174cd
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 33 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Temp files
*~
.gradle

# Build
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Don't save away IntelliJ config, except code-style which all commits must follow.
**/.idea/
!.idea/codeStyleSettings.xml
22 changes: 4 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
# matrix:
# allow_failures:
# # Blocked on (github issue url)
# - env: TEST_DIR=com.example-library
# - env: TEST_DIR=libraryBuilds/com.example-library

branches:
only:
Expand All @@ -35,21 +35,7 @@ before_install:
- ./j2objc-gradle/install-osx-jdk7.sh

install:
- export TERM=dumb
- env
- xcrun clang -v
- /usr/libexec/java_home -v 1.7 -F -V
- java -Xmx32m -version && javac -J-Xmx32m -version
- pushd j2objc-gradle
- ./gradlew wrapper
- ./gradlew dependencies
# In this repo, building of the j2objc-gradle plugin is just preperation.
- ./gradlew build
- popd
- pushd libraryBuilds
# Downloads and configures j2objc distribution.
- ./prep.sh

# Note the install prep leaves us in the libraryBuilds directory.
- ./install.sh

script:
- ./run-test.sh $TEST_DIR
- ./run-test.sh libraryBuilds/$TEST_DIR
25 changes: 20 additions & 5 deletions libraryBuilds/prep.sh → install-j2objc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

J2OBJC_VERSION=0.9.8.2.1
mkdir localJ2objcDist
mkdir common
# Must be run from the root directory

# Fail if any command fails
set -ev
# Fail if anything fails
set -euv

pushd libraryBuilds

# Specific version can be configured from command line:
# export J2OBJC_VERSION=X.Y.Z
# Default is version number listed on following line:
J2OBJC_VERSION=${J2OBJC_VERSION:=0.9.8.2.1}

# -p flag avoid failure when directory already exists
mkdir -p localJ2objcDist
mkdir -p common

pushd localJ2objcDist

Expand All @@ -31,6 +40,12 @@ if [ ! -e $DIST_FILE ]; then
curl -L https://github.com/google/j2objc/releases/download/$J2OBJC_VERSION/j2objc-$J2OBJC_VERSION.zip > $DIST_FILE
unzip $DIST_FILE
echo j2objc.home=$PWD/$DIST_DIR > ../common/local.properties
echo "libraryBuild/common/local.properties configured:"
cat ../common/local.properties
fi

# pop localJ2objcDist
popd

# pop libraryBuilds
popd
37 changes: 37 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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.

# Must be run from the root directory

# Fail if anything fails
set -euv

export TERM=dumb
env
xcrun clang -v

/usr/libexec/java_home -v 1.7 -F -V
java -Xmx32m -version && javac -J-Xmx32m -version

# In this repo, building of the j2objc-gradle plugin is just preperation.
pushd j2objc-gradle
./gradlew wrapper
./gradlew dependencies
./gradlew build
popd

# Download and configures j2objc distribution.
./install-j2objc.sh
14 changes: 8 additions & 6 deletions libraryBuilds/run-all.sh → run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Must be run from the root directory

# Fail if anything fails.
set -ev
set -euv

./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 libraryBuilds/com.google.code.gson-gson
./run-test.sh libraryBuilds/org.joda-joda-convert
./run-test.sh libraryBuilds/joda-time-joda-time
./run-test.sh libraryBuilds/org.joda-joda-primitives
./run-test.sh libraryBuilds/org.apache.commons-commons-lang3
17 changes: 13 additions & 4 deletions libraryBuilds/run-test.sh → run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Must be run from the root directory

# Fail if anything fails.
set -ev
set -euv

if [[ "$PWD" =~ libraryBuilds ]]; then
echo "Should be run from project root and not libraryBuilds directory"
exit 1
fi

TEST_DIR=$1
pushd $TEST_DIR
Expand All @@ -27,13 +34,15 @@ echo Preparing test $TEST_DIR
# -L follows symbolic links correctly.
find -L . -name prep.sh | while read PREP_SCRIPT_FILE
do
pushd `dirname $PREP_SCRIPT_FILE`
sh prep.sh
popd
pushd `dirname $PREP_SCRIPT_FILE`
sh prep.sh
popd
done

echo Running test $TEST_DIR
./gradlew wrapper
./gradlew clean
./gradlew build --stacktrace

# $TEST_DIR
popd

0 comments on commit 7c174cd

Please sign in to comment.