Skip to content

Commit

Permalink
Use go test -bench where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Edoardo Vacchi <[email protected]>
  • Loading branch information
evacchi committed Dec 19, 2023
1 parent 2638a0a commit ea9b0a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 63 deletions.
61 changes: 4 additions & 57 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
- name: Run built test binaries
if: ${{ matrix.compiler != 'optimizing' }}
run: ./wazerocli run -mount=:/ ./internal/integration_test/stdlibs/testdata/zig/test.wasm
run: go test -bench='/zig' -benchtime=1x

build_tinygo_test_binary:
name: Build TinyGo test binary
Expand Down Expand Up @@ -262,11 +262,7 @@ jobs:
- name: Run test binaries
if: ${{ matrix.compiler != 'optimizing' }}
run: |
cd ./internal/integration_test/stdlibs/testdata/tinygo
for bin in *.test; do
echo $bin
~/wazerocli run -mount=:/ -mount=:/tmp $bin -- -test.v
done
go test -bench='/tinygo' -benchtime=1x
wasi-testsuite:
name: wasi-testsuite
Expand Down Expand Up @@ -433,56 +429,7 @@ jobs:
popd
done
- if: ${{ matrix.compiler != 'optimizing' && runner.os != 'Windows' }}
- if: ${{ matrix.compiler != 'optimizing' }}
name: Run test binaries
run: |
echo "Running $(find ./internal/integration_test/stdlibs/testdata/go -name *.test | wc -l) test binaries"
# Go tests often look for files relative to the source. Change to the corresponding directory.
for bin in $PWD/internal/integration_test/stdlibs/testdata/go/*.test; do
dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
pushd $(go env GOROOT)/$dir
~/wazerocli run -mount=/:/ -env PWD=$PWD $bin -- -test.short -test.v
popd
done
- if: ${{ runner.os == 'Windows' }}
name: Run test binaries (Windows)
# Ack failures on Windows. https://github.com/tetratelabs/wazero/issues/1410
continue-on-error: true
run: |
GOOS=$(go env GOOS)
echo "Running $(find $PWD/internal/integration_test/stdlibs/testdata/go -name *.test | wc -l) test binaries"
MOUNT=c:\\:/
SCRIPT="$HOME/tests.cmd"
# Trim `/c` from the in-Wasm GOROOT.
REAL_GOROOT=$(go env GOROOT)
GOROOT=$(cygpath -u $REAL_GOROOT | cut -c 3-)
# Append early exit on cmd.
POSTFIX="if %errorlevel% neq 0 exit /b %errorlevel%"
RUNNER="cmd //c %USERPROFILE%\tests.cmd"
EXTRAPARAMS="-mount=%TEMP%:/tmp"
# Go tests often look for files relative to the source. Change to the corresponding directory.
for bin in $PWD/internal/integration_test/stdlibs/testdata/go/*.test; do
dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
pushd $REAL_GOROOT/$dir
# Trim `/c` from the in-Wasm pwd.
IN_WASM_PWD=$(pwd | cut -c 3-)
# Convert to a Windows path.
bin=`cygpath -w $bin`
# Create a script with all the tests (do not run yet).
echo ${MOUNT} ${IN_WASM_PWD} $GOROOT/$dir
COMMAND="~/wazerocli run -mount=${MOUNT} ${EXTRAPARAMS} -hostlogging=filesystem -env PWD=${IN_WASM_PWD} -env GOROOT=${GOROOT} -env GOOS=wasip1 $bin -- -test.short -test.v"
echo $COMMAND >> $SCRIPT
# Uncomment the following line for early exit on error on Windows.
# Otherwise the tests will report are successful evne on failure.
# echo $POSTFIX >> $SCRIPT
popd
done
# Run all the tests in their own shell.
$RUNNER
go test -bench='/wasip1' -benchtime=1x
12 changes: 6 additions & 6 deletions internal/integration_test/stdlibs/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import (
)

func BenchmarkStdlibs(b *testing.B) {
if runtime.GOARCH != "arm64" {
b.Skip("The optimizing compiler is currently only supported on arm64.")
}
configs := []struct {
type testConfig struct {
name string
config wazero.RuntimeConfig
}{
}
configs := []testConfig{
{name: "baseline", config: wazero.NewRuntimeConfigCompiler()},
{name: "optimizing", config: opt.NewRuntimeConfigOptimizingCompiler()},
}
if runtime.GOARCH == "arm64" {
configs = append(configs, testConfig{name: "optimizing", config: opt.NewRuntimeConfigOptimizingCompiler()})
}

cwd, _ := os.Getwd()
Expand Down

0 comments on commit ea9b0a2

Please sign in to comment.