@echo on

rem Some of the windows build hosts can be a bit slow.  Allow the tests to run longer on windows under cgo.
set "GO_TEST_TIMEOUT_SCALE=4"

rem Put TMP on the same drive as the conda prefix (the D drive),
rem to avoid a known issue in the go test suite:
rem https://github.com/golang/go/issues/24846#issuecomment-381380628
set TMP=%PREFIX%\tmp
mkdir "%TMP%"


rem Batch equivalent to backticks
rem   https://stackoverflow.com/questions/2768608/batch-equivalent-of-bash-backticks#2768660
rem for /f "usebackq tokens=*" %%a in (`go env GOEXE`) do file hello%%a | grep '{{ conda_gofile }}'


rem Diagnostics
where go
go env


rem Run go's built-in tests
rem Expect FAIL, we run them to obtain logs
go tool dist test -k -v -no-rebuild -run=^^go_test:os$
go tool dist test -k -v -no-rebuild -run=^^go_test:cmd/go$
go tool dist test -k -v -no-rebuild -run=^^go_test:cmd/gofmt$


rem Expect PASS
go tool dist test -v -no-rebuild -run=!^^go_test:os^|go_test:cmd/go^|go_test:cmd/gofmt$
if errorlevel 1 exit 1


exit 0
