| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | pkg=yaegi |
| 5 | |
| 6 | if [ "${AUTOPKGTEST_TMP}" = "" ] ; then |
| 7 | AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX) |
| 8 | trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM |
| 9 | fi |
| 10 | |
| 11 | cd "${AUTOPKGTEST_TMP}" |
| 12 | |
| 13 | echo "Test 1: Check that REPL works" |
| 14 | yaegi<<HERE > test1 |
| 15 | import "fmt" |
| 16 | fmt.Println("Debian Autopkgtest") |
| 17 | fmt.Println(1 + 2) |
| 18 | fmt.Println(reflect.TypeOf(time.Date)) |
| 19 | HERE |
| 20 | |
| 21 | cat test1 |
| 22 | |
| 23 | result=$(md5sum test1 | awk '{print $1}') |
| 24 | if [ x"$result" != x"1a21e16a6eb2167ba79b50053af1e1e8" ]; then |
| 25 | echo "FAIL: output file not as expected" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | # Clean up |
| 30 | rm -f test1 |
| 31 | echo "============= PASS ==============" |
| 32 | |
| 33 | echo "Test 2: Check that yaegi script runs as expeted" |
| 34 | cat<<HERE > test2.sh |
| 35 | #!/usr/bin/env yaegi |
| 36 | package main |
| 37 | |
| 38 | import "fmt" |
| 39 | |
| 40 | func main() { |
| 41 | fmt.Println("test") |
| 42 | } |
| 43 | HERE |
| 44 | |
| 45 | chmod +x test2.sh |
| 46 | ./test2.sh |
| 47 | if [ "$(./test2.sh)" != "test" ]; then |
| 48 | echo "FAIL: unexpected output" |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | # Clean up |
| 53 | rm -f test2.sh |
| 54 | echo "============= PASS ==============" |
| 55 | |
| 56 | echo "Test 3: Confirm that yaegi is able to run a go file" |
| 57 | cat<<HERE > test3.go |
| 58 | package main |
| 59 | |
| 60 | import "fmt" |
| 61 | |
| 62 | func main() { |
| 63 | fmt.Println("testing yaegi run") |
| 64 | } |
| 65 | HERE |
| 66 | |
| 67 | yaegi run test3.go |
| 68 | |
| 69 | # Clean up |
| 70 | rm -f test3.go |
| 71 | echo "============= PASS ==============" |