| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env bash | |
| 2 # Copyright 2014 The Go Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style | |
| 4 # license that can be found in the LICENSE file. | |
| 5 | |
| 6 set -e | |
| 7 | |
| 8 function die() { | |
| 9 echo "FAIL: $1" | |
| 10 exit 1 | |
| 11 } | |
| 12 | |
| 13 if [ ! -f test.bash ]; then | |
| 14 die 'test.bash must be run from $GOPATH/src/golang.org/x/mobile/bind/java' | |
| 15 fi | |
| 16 | |
| 17 function cleanup() { | |
| 18 rm -rf "$ANDROID_APP" | |
| 19 } | |
| 20 | |
| 21 if [ -z "$TMPDIR" ]; then | |
| 22 TMPDIR="/tmp" | |
| 23 fi | |
| 24 | |
| 25 if [ -z "$ANDROID_APP" ]; then | |
| 26 ANDROID_APP=`mktemp -d ${TMPDIR}/android-java.XXXXX` || die 'failed to c
reate a temporary directory' | |
| 27 echo "Temporary directory for test: $ANDROID_APP" | |
| 28 trap cleanup EXIT | |
| 29 fi | |
| 30 | |
| 31 # Create an android project for test. | |
| 32 # TODO(hyangah): use android update lib-project if the $ANDROID_APP directory | |
| 33 # already exists. | |
| 34 android create lib-project -n BindJavaTest \ | |
| 35 -t "android-19" -p $ANDROID_APP -k go.testpkg -g -v 0.12.+ | |
| 36 | |
| 37 # Add the necessary Java source files (Seq.java and app/Go.java)) in to the | |
| 38 # project directory. (go package) | |
| 39 mkdir -p $ANDROID_APP/src/main/java/go | |
| 40 ln -sf $PWD/Seq.java $ANDROID_APP/src/main/java/go | |
| 41 ln -sf $PWD/../../app/*.java $ANDROID_APP/src/main/java/go | |
| 42 | |
| 43 # Add the testpkg java file (output of gobind -lang=java) necessary for SeqTest.
java. | |
| 44 mkdir -p $ANDROID_APP/src/main/java/go/testpkg | |
| 45 ln -sf $PWD/testpkg/Testpkg.java $ANDROID_APP/src/main/java/go/testpkg | |
| 46 | |
| 47 # Add the compiled jni shared library under src/main/jniLibs/armeabi directory. | |
| 48 mkdir -p $ANDROID_APP/src/main/jniLibs/armeabi | |
| 49 CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 \ | |
| 50 go build -ldflags="-shared" \ | |
| 51 -o $ANDROID_APP/src/main/jniLibs/armeabi/libgojni.so \ | |
| 52 javatest.go | |
| 53 | |
| 54 # Add the test file under androidTest directory. | |
| 55 mkdir -p $ANDROID_APP/src/androidTest/java/go | |
| 56 ln -sf $PWD/SeqTest.java $ANDROID_APP/src/androidTest/java/go | |
| 57 | |
| 58 # Build the test apk. ($ANDROID_APP/build/outputs/apk). | |
| 59 cd $ANDROID_APP | |
| 60 | |
| 61 # If there is no connected device, this will fail after creating the test apk. | |
| 62 # The apk is located in $ANDROID_APP/build/outputs/apk directory. | |
| 63 ./gradlew connectedAndroidTest && echo "PASS" && exit 0 | |
| 64 | |
| 65 # TODO(hyangah): copy the gradle's test output directory in case of test failure
? | |
| 66 | |
| 67 # TODO(hyangah): gradlew build | |
| 68 # Currently build fails due to a lint error. Disable lint check or | |
| 69 # specify the minSdkVersion in gradle.build to avoid the lint error. | |
| OLD | NEW |