aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/tgtestjson.sh
blob: 169da5852cb38a8346c44f9df84a34cf67c72c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

# Run tests and convert output to json with go tool test2json.
# This is a workaround for the lack of -json output in tinygo test.
# Some variables must be set in the environment beforehand.
# TODO: let's just add -json support to tinygo test.

TINYGO="${TINYGO:-tinygo}"
PACKAGES="${PACKAGES:-"./tests"}"
TARGET="${TARGET:-wasip2}"
TESTOPTS="${TESTOPTS:-"-x -work"}"

# go clean -testcache
for pkg in $PACKAGES; do
    # Example invocation with test2json in BigGo:
    # go test -test.v=test2json ./$pkg 2>&1 | go tool test2json -p $pkg

    # Uncomment to see resolved commands in output
    # >&2 echo "${TINYGO} test -v -target $TARGET $TESTOPTS $pkg 2>&1 | go tool test2json -p $pkg"
    "${TINYGO}" test -v -target $TARGET $TESTOPTS $pkg 2>&1 | go tool test2json -p $pkg

done