blob: fdaacfff44119be5fd4f1318f9f642690a0d1ecf [file] [log] [blame]
Russ Cox4c1abd62012-02-04 00:48:31 -05001:: Copyright 2012 The Go Authors. All rights reserved.
2:: Use of this source code is governed by a BSD-style
3:: license that can be found in the LICENSE file.
4@echo off
5
Alex Brainman034c72a2012-02-16 10:44:55 +11006:: Keep environment variables within this script
7:: unless invoked with --no-local.
8if x%1==x--no-local goto nolocal
9if x%2==x--no-local goto nolocal
10setlocal
11:nolocal
12
Russ Cox4c1abd62012-02-04 00:48:31 -050013set GOBUILDFAIL=0
14
Shenghou Ma23322ab2012-03-21 00:47:27 +080015:: we disallow local import for non-local packages, if %GOROOT% happens
16:: to be under %GOPATH%, then some tests below will fail
17set GOPATH=
18
Russ Cox4c1abd62012-02-04 00:48:31 -050019rem TODO avoid rebuild if possible
20
21if x%1==x--no-rebuild goto norebuild
22echo # Building packages and commands.
23go install -a -v std
24if errorlevel 1 goto fail
Hector Chu7fc47922012-02-16 20:49:50 +000025echo.
Russ Cox4c1abd62012-02-04 00:48:31 -050026:norebuild
27
Shenghou Ma34ace102012-04-04 23:14:54 +080028:: we must unset GOROOT_FINAL before tests, because runtime/debug requires
29:: correct access to source code, so if we have GOROOT_FINAL in effect,
30:: at least runtime/debug test will fail.
31set GOROOT_FINAL=
32
Shenghou Ma1e954292012-08-07 09:38:35 +080033:: get CGO_ENABLED
34go env > env.bat
35if errorlevel 1 goto fail
36call env.bat
37del env.bat
38echo.
39
Russ Cox4c1abd62012-02-04 00:48:31 -050040echo # Testing packages.
41go test std -short -timeout=120s
42if errorlevel 1 goto fail
Hector Chu7fc47922012-02-16 20:49:50 +000043echo.
Russ Cox4c1abd62012-02-04 00:48:31 -050044
Dmitriy Vyukov13045842014-03-06 13:16:14 +040045set OLDGOMAXPROCS=%GOMAXPROCS%
46
47:: We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
48:: creation of first goroutines and first garbage collections in the parallel setting.
49echo # GOMAXPROCS=2 runtime -cpu=1,2,4
50set GOMAXPROCS=2
Alex Brainman09e72f52013-07-12 12:30:18 +100051go test runtime -short -timeout=300s -cpu=1,2,4
Russ Cox4c1abd62012-02-04 00:48:31 -050052if errorlevel 1 goto fail
Hector Chu7fc47922012-02-16 20:49:50 +000053echo.
Russ Cox4c1abd62012-02-04 00:48:31 -050054
Dmitriy Vyukov13045842014-03-06 13:16:14 +040055set GOMAXPROCS=%OLDGOMAXPROCS%
56set OLDGOMAXPROCS=
57
Russ Cox4c1abd62012-02-04 00:48:31 -050058echo # sync -cpu=10
59go test sync -short -timeout=120s -cpu=10
60if errorlevel 1 goto fail
Hector Chu7fc47922012-02-16 20:49:50 +000061echo.
Russ Cox4c1abd62012-02-04 00:48:31 -050062
Alex Brainman72f2b562014-02-18 16:48:34 +110063:: Race detector only supported on Linux and OS X,
64:: and only on amd64, and only when cgo is enabled.
Rémy Oudompheng475e7d02014-02-19 08:19:27 +010065if not "%GOHOSTOS%-%GOOS%-%GOARCH%-%CGO_ENABLED%" == "windows-windows-amd64-1" goto norace
Dmitriy Vyukov1ebf2d82012-11-07 23:59:09 +040066echo # Testing race detector.
Alex Brainmanc7a64cc2013-08-15 12:13:00 +100067go test -race -i runtime/race flag
68if errorlevel 1 goto fail
69go test -race -run=Output runtime/race
Dmitriy Vyukov1ebf2d82012-11-07 23:59:09 +040070if errorlevel 1 goto fail
71go test -race -short flag
72if errorlevel 1 goto fail
73echo.
74:norace
75
Andrew Gerrand5f1af162013-08-01 13:49:00 +100076echo # ..\misc\goplay
77go build ..\misc\goplay
Alex Brainman7fbef932012-03-20 14:04:20 +110078if errorlevel 1 goto fail
79echo.
80
Alex Brainman8627e5c2012-09-19 12:07:25 +100081echo # ..\test\bench\go1
82go test ..\test\bench\go1
83if errorlevel 1 goto fail
84echo.
Alex Brainman7fbef932012-03-20 14:04:20 +110085
Shenghou Ma1e954292012-08-07 09:38:35 +080086:: cgo tests
Shenghou Ma1e954292012-08-07 09:38:35 +080087if x%CGO_ENABLED% == x0 goto nocgo
Shenghou Ma54908142012-09-26 22:34:25 +080088echo # ..\misc\cgo\life
Alex Brainman77fb0c12013-03-25 12:13:34 +110089go run "%GOROOT%\test\run.go" - ..\misc\cgo\life
Shenghou Ma54908142012-09-26 22:34:25 +080090if errorlevel 1 goto fail
91echo.
Shenghou Ma551d8b92012-08-17 03:42:34 +080092
Shenghou Ma674bbaf2012-09-20 00:27:23 +080093echo # ..\misc\cgo\stdio
Alex Brainman77fb0c12013-03-25 12:13:34 +110094go run "%GOROOT%\test\run.go" - ..\misc\cgo\stdio
Shenghou Ma674bbaf2012-09-20 00:27:23 +080095if errorlevel 1 goto fail
96echo.
Shenghou Ma551d8b92012-08-17 03:42:34 +080097
Alex Brainman8627e5c2012-09-19 12:07:25 +100098echo # ..\misc\cgo\test
99go test ..\misc\cgo\test
100if errorlevel 1 goto fail
101echo.
Shenghou Ma8c72b812013-04-23 04:42:04 +0800102
103echo # ..\misc\cgo\testso
104cd ..\misc\cgo\testso
105set FAIL=0
106call test.bat
107cd ..\..\..\src
108if %FAIL%==1 goto fail
109echo.
Shenghou Ma1e954292012-08-07 09:38:35 +0800110:nocgo
111
Shenghou Ma5b7562d2012-09-03 03:49:03 +0800112echo # ..\doc\progs
Alex Brainman77fb0c12013-03-25 12:13:34 +1100113go run "%GOROOT%\test\run.go" - ..\doc\progs
Shenghou Ma5b7562d2012-09-03 03:49:03 +0800114if errorlevel 1 goto fail
115echo.
116
Russ Cox5e41fe02012-03-05 22:47:23 -0500117:: TODO: The other tests in run.bash.
118
Dave Cheney36c4a732012-11-15 11:40:10 +1100119
120set OLDGOMAXPROCS=%GOMAXPROCS%
121
Alex Brainmanee26a5e2012-11-01 13:04:08 +1100122echo # ..\test
Alex Brainman7c128492012-03-13 12:51:28 +1100123cd ..\test
124set FAIL=0
Dave Cheney36c4a732012-11-15 11:40:10 +1100125set GOMAXPROCS=
Russ Cox5e41fe02012-03-05 22:47:23 -0500126go run run.go
Alex Brainman7c128492012-03-13 12:51:28 +1100127if errorlevel 1 set FAIL=1
128cd ..\src
Russ Cox5e41fe02012-03-05 22:47:23 -0500129echo.
Alex Brainman7c128492012-03-13 12:51:28 +1100130if %FAIL%==1 goto fail
Russ Cox4c1abd62012-02-04 00:48:31 -0500131
Dave Cheney36c4a732012-11-15 11:40:10 +1100132set GOMAXPROCS=%OLDGOMAXPROCS%
133set OLDGOMAXPROCS=
134
Alex Brainman7fbef932012-03-20 14:04:20 +1100135echo # Checking API compatibility.
Russ Coxb78410b2013-08-09 18:44:00 -0400136go run "%GOROOT%\src\cmd\api\run.go"
Alex Brainman7fbef932012-03-20 14:04:20 +1100137if errorlevel 1 goto fail
138echo.
139
Russ Cox4c1abd62012-02-04 00:48:31 -0500140echo ALL TESTS PASSED
141goto end
142
143:fail
144set GOBUILDFAIL=1
145
146:end