xref: /aosp_15_r20/external/flatbuffers/tests/KotlinTest.sh (revision 890232f25432b36107d06881e0a25aaa6b473652)
1*890232f2SAndroid Build Coastguard Worker#!/bin/sh
2*890232f2SAndroid Build Coastguard Worker
3*890232f2SAndroid Build Coastguard Worker# Copyright 2014 Google Inc. All rights reserved.
4*890232f2SAndroid Build Coastguard Worker#
5*890232f2SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*890232f2SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*890232f2SAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*890232f2SAndroid Build Coastguard Worker#
9*890232f2SAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
10*890232f2SAndroid Build Coastguard Worker#
11*890232f2SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*890232f2SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*890232f2SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*890232f2SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*890232f2SAndroid Build Coastguard Worker# limitations under the License.
16*890232f2SAndroid Build Coastguard Worker
17*890232f2SAndroid Build Coastguard Workerecho Compile then run the Kotlin test.
18*890232f2SAndroid Build Coastguard Worker
19*890232f2SAndroid Build Coastguard Workertestdir=$(dirname $0)
20*890232f2SAndroid Build Coastguard Workertargetdir="${testdir}/kotlin"
21*890232f2SAndroid Build Coastguard Worker
22*890232f2SAndroid Build Coastguard Workerif [[ -e "${targetdir}" ]]; then
23*890232f2SAndroid Build Coastguard Worker    echo "cleaning target"
24*890232f2SAndroid Build Coastguard Worker    rm -rf "${targetdir}"
25*890232f2SAndroid Build Coastguard Workerfi
26*890232f2SAndroid Build Coastguard Worker
27*890232f2SAndroid Build Coastguard Workermkdir -v "${targetdir}"
28*890232f2SAndroid Build Coastguard Worker
29*890232f2SAndroid Build Coastguard Workerif ! find "${testdir}/../java" -type f -name "*.class" -delete; then
30*890232f2SAndroid Build Coastguard Worker    echo "failed to clean .class files from java directory" >&2
31*890232f2SAndroid Build Coastguard Worker    exit 1
32*890232f2SAndroid Build Coastguard Workerfi
33*890232f2SAndroid Build Coastguard Worker
34*890232f2SAndroid Build Coastguard Workerall_kt_files=`find . -name "*.kt" -print`
35*890232f2SAndroid Build Coastguard Worker
36*890232f2SAndroid Build Coastguard Worker# Compile java FlatBuffer library
37*890232f2SAndroid Build Coastguard Workerjavac ${testdir}/../java/com/google/flatbuffers/*.java -d $targetdir
38*890232f2SAndroid Build Coastguard Worker# Compile Kotlin files
39*890232f2SAndroid Build Coastguard Workerkotlinc $all_kt_files -classpath $targetdir -include-runtime -d $targetdir
40*890232f2SAndroid Build Coastguard Worker# Make jar
41*890232f2SAndroid Build Coastguard Workerjar cvf ${testdir}/kotlin_test.jar -C $targetdir . > /dev/null
42*890232f2SAndroid Build Coastguard Worker# Run test
43*890232f2SAndroid Build Coastguard Workerkotlin -J"-ea" -cp ${testdir}/kotlin_test.jar KotlinTest
44*890232f2SAndroid Build Coastguard Worker# clean up
45*890232f2SAndroid Build Coastguard Workerrm -rf $targetdir
46*890232f2SAndroid Build Coastguard Workerrm ${testdir}/kotlin_test.jar
47