-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·46 lines (38 loc) · 1.55 KB
/
run-tests.sh
File metadata and controls
executable file
·46 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
function clearCache() {
[ -n "$KOTLIN_SCRIPT_CACHE" ] || KOTLIN_SCRIPT_CACHE="$HOME/.kotlin-script-cache"
if [ -d "$KOTLIN_SCRIPT_CACHE" ]; then
rm -r "$KOTLIN_SCRIPT_CACHE"
fi
}
function assertEquals() {
echo "Running $1..."
actual=`echo "$2" | tr -d '\r' | tr -d '\n'`
expected="$3"
if [ "$actual" != "$expected" ]; then
echo " Actual: $actual"
echo "Expected: $expected"
exit 1
fi
}
function tests() {
start=$(date +"%s")
assertEquals "script with implicit main" "`$DIR/examples/implicitmain 1 2 3`" "Hello from Kotlin! args.size=3"
assertEquals "script with explicit main" "`$DIR/examples/explicitmain`" "Hello from Kotlin!"
assertEquals "script with class path" "`cd "$DIR/examples" && $DIR/examples/withclasspath`" "0 [main] INFO mymodule - Hello from Kotlin via log4j! mySysProp=somevalue"
assertEquals "script with spaces" "`"$DIR/examples/with spaces"`" "Hello from Kotlin! args.size=0"
assertEquals "standard kotlin source file" "`kotlins "$DIR/examples/standardsource.kt" 1 2 3`" "Hello from Kotlin! args.size=3"
assertEquals "standard kotlin module file" "`kotlins "$DIR/examples/standardmodule.xml" 1 2 3`" "Hello from Kotlin! args.size=3"
end=$(date +"%s")
diff=$(($end-$start))
echo "$diff seconds"
}
clearCache
echo "Run with empty cache"
tests
echo
echo "Run with cache"
tests