Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 1 | :: 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 Brainman | 034c72a | 2012-02-16 10:44:55 +1100 | [diff] [blame] | 6 | :: Keep environment variables within this script |
| 7 | :: unless invoked with --no-local. |
| 8 | if x%1==x--no-local goto nolocal |
| 9 | if x%2==x--no-local goto nolocal |
| 10 | setlocal |
| 11 | :nolocal |
| 12 | |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 13 | set GOBUILDFAIL=0 |
| 14 | |
Shenghou Ma | 23322ab | 2012-03-21 00:47:27 +0800 | [diff] [blame] | 15 | :: we disallow local import for non-local packages, if %GOROOT% happens |
| 16 | :: to be under %GOPATH%, then some tests below will fail |
| 17 | set GOPATH= |
| 18 | |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 19 | rem TODO avoid rebuild if possible |
| 20 | |
| 21 | if x%1==x--no-rebuild goto norebuild |
| 22 | echo # Building packages and commands. |
| 23 | go install -a -v std |
| 24 | if errorlevel 1 goto fail |
Hector Chu | 7fc4792 | 2012-02-16 20:49:50 +0000 | [diff] [blame] | 25 | echo. |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 26 | :norebuild |
| 27 | |
Shenghou Ma | 34ace10 | 2012-04-04 23:14:54 +0800 | [diff] [blame] | 28 | :: 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. |
| 31 | set GOROOT_FINAL= |
| 32 | |
Shenghou Ma | 1e95429 | 2012-08-07 09:38:35 +0800 | [diff] [blame] | 33 | :: get CGO_ENABLED |
| 34 | go env > env.bat |
| 35 | if errorlevel 1 goto fail |
| 36 | call env.bat |
| 37 | del env.bat |
| 38 | echo. |
| 39 | |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 40 | echo # Testing packages. |
| 41 | go test std -short -timeout=120s |
| 42 | if errorlevel 1 goto fail |
Hector Chu | 7fc4792 | 2012-02-16 20:49:50 +0000 | [diff] [blame] | 43 | echo. |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 44 | |
Dmitriy Vyukov | 1304584 | 2014-03-06 13:16:14 +0400 | [diff] [blame] | 45 | set 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. |
| 49 | echo # GOMAXPROCS=2 runtime -cpu=1,2,4 |
| 50 | set GOMAXPROCS=2 |
Alex Brainman | 09e72f5 | 2013-07-12 12:30:18 +1000 | [diff] [blame] | 51 | go test runtime -short -timeout=300s -cpu=1,2,4 |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 52 | if errorlevel 1 goto fail |
Hector Chu | 7fc4792 | 2012-02-16 20:49:50 +0000 | [diff] [blame] | 53 | echo. |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 54 | |
Dmitriy Vyukov | 1304584 | 2014-03-06 13:16:14 +0400 | [diff] [blame] | 55 | set GOMAXPROCS=%OLDGOMAXPROCS% |
| 56 | set OLDGOMAXPROCS= |
| 57 | |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 58 | echo # sync -cpu=10 |
| 59 | go test sync -short -timeout=120s -cpu=10 |
| 60 | if errorlevel 1 goto fail |
Hector Chu | 7fc4792 | 2012-02-16 20:49:50 +0000 | [diff] [blame] | 61 | echo. |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 62 | |
Alex Brainman | 72f2b56 | 2014-02-18 16:48:34 +1100 | [diff] [blame] | 63 | :: Race detector only supported on Linux and OS X, |
| 64 | :: and only on amd64, and only when cgo is enabled. |
Rémy Oudompheng | 475e7d0 | 2014-02-19 08:19:27 +0100 | [diff] [blame] | 65 | if not "%GOHOSTOS%-%GOOS%-%GOARCH%-%CGO_ENABLED%" == "windows-windows-amd64-1" goto norace |
Dmitriy Vyukov | 1ebf2d8 | 2012-11-07 23:59:09 +0400 | [diff] [blame] | 66 | echo # Testing race detector. |
Alex Brainman | c7a64cc | 2013-08-15 12:13:00 +1000 | [diff] [blame] | 67 | go test -race -i runtime/race flag |
| 68 | if errorlevel 1 goto fail |
| 69 | go test -race -run=Output runtime/race |
Dmitriy Vyukov | 1ebf2d8 | 2012-11-07 23:59:09 +0400 | [diff] [blame] | 70 | if errorlevel 1 goto fail |
| 71 | go test -race -short flag |
| 72 | if errorlevel 1 goto fail |
| 73 | echo. |
| 74 | :norace |
| 75 | |
Andrew Gerrand | 5f1af16 | 2013-08-01 13:49:00 +1000 | [diff] [blame] | 76 | echo # ..\misc\goplay |
| 77 | go build ..\misc\goplay |
Alex Brainman | 7fbef93 | 2012-03-20 14:04:20 +1100 | [diff] [blame] | 78 | if errorlevel 1 goto fail |
| 79 | echo. |
| 80 | |
Alex Brainman | 8627e5c | 2012-09-19 12:07:25 +1000 | [diff] [blame] | 81 | echo # ..\test\bench\go1 |
| 82 | go test ..\test\bench\go1 |
| 83 | if errorlevel 1 goto fail |
| 84 | echo. |
Alex Brainman | 7fbef93 | 2012-03-20 14:04:20 +1100 | [diff] [blame] | 85 | |
Shenghou Ma | 1e95429 | 2012-08-07 09:38:35 +0800 | [diff] [blame] | 86 | :: cgo tests |
Shenghou Ma | 1e95429 | 2012-08-07 09:38:35 +0800 | [diff] [blame] | 87 | if x%CGO_ENABLED% == x0 goto nocgo |
Shenghou Ma | 5490814 | 2012-09-26 22:34:25 +0800 | [diff] [blame] | 88 | echo # ..\misc\cgo\life |
Alex Brainman | 77fb0c1 | 2013-03-25 12:13:34 +1100 | [diff] [blame] | 89 | go run "%GOROOT%\test\run.go" - ..\misc\cgo\life |
Shenghou Ma | 5490814 | 2012-09-26 22:34:25 +0800 | [diff] [blame] | 90 | if errorlevel 1 goto fail |
| 91 | echo. |
Shenghou Ma | 551d8b9 | 2012-08-17 03:42:34 +0800 | [diff] [blame] | 92 | |
Shenghou Ma | 674bbaf | 2012-09-20 00:27:23 +0800 | [diff] [blame] | 93 | echo # ..\misc\cgo\stdio |
Alex Brainman | 77fb0c1 | 2013-03-25 12:13:34 +1100 | [diff] [blame] | 94 | go run "%GOROOT%\test\run.go" - ..\misc\cgo\stdio |
Shenghou Ma | 674bbaf | 2012-09-20 00:27:23 +0800 | [diff] [blame] | 95 | if errorlevel 1 goto fail |
| 96 | echo. |
Shenghou Ma | 551d8b9 | 2012-08-17 03:42:34 +0800 | [diff] [blame] | 97 | |
Alex Brainman | 8627e5c | 2012-09-19 12:07:25 +1000 | [diff] [blame] | 98 | echo # ..\misc\cgo\test |
| 99 | go test ..\misc\cgo\test |
| 100 | if errorlevel 1 goto fail |
| 101 | echo. |
Shenghou Ma | 8c72b81 | 2013-04-23 04:42:04 +0800 | [diff] [blame] | 102 | |
| 103 | echo # ..\misc\cgo\testso |
| 104 | cd ..\misc\cgo\testso |
| 105 | set FAIL=0 |
| 106 | call test.bat |
| 107 | cd ..\..\..\src |
| 108 | if %FAIL%==1 goto fail |
| 109 | echo. |
Shenghou Ma | 1e95429 | 2012-08-07 09:38:35 +0800 | [diff] [blame] | 110 | :nocgo |
| 111 | |
Shenghou Ma | 5b7562d | 2012-09-03 03:49:03 +0800 | [diff] [blame] | 112 | echo # ..\doc\progs |
Alex Brainman | 77fb0c1 | 2013-03-25 12:13:34 +1100 | [diff] [blame] | 113 | go run "%GOROOT%\test\run.go" - ..\doc\progs |
Shenghou Ma | 5b7562d | 2012-09-03 03:49:03 +0800 | [diff] [blame] | 114 | if errorlevel 1 goto fail |
| 115 | echo. |
| 116 | |
Russ Cox | 5e41fe0 | 2012-03-05 22:47:23 -0500 | [diff] [blame] | 117 | :: TODO: The other tests in run.bash. |
| 118 | |
Dave Cheney | 36c4a73 | 2012-11-15 11:40:10 +1100 | [diff] [blame] | 119 | |
| 120 | set OLDGOMAXPROCS=%GOMAXPROCS% |
| 121 | |
Alex Brainman | ee26a5e | 2012-11-01 13:04:08 +1100 | [diff] [blame] | 122 | echo # ..\test |
Alex Brainman | 7c12849 | 2012-03-13 12:51:28 +1100 | [diff] [blame] | 123 | cd ..\test |
| 124 | set FAIL=0 |
Dave Cheney | 36c4a73 | 2012-11-15 11:40:10 +1100 | [diff] [blame] | 125 | set GOMAXPROCS= |
Russ Cox | 5e41fe0 | 2012-03-05 22:47:23 -0500 | [diff] [blame] | 126 | go run run.go |
Alex Brainman | 7c12849 | 2012-03-13 12:51:28 +1100 | [diff] [blame] | 127 | if errorlevel 1 set FAIL=1 |
| 128 | cd ..\src |
Russ Cox | 5e41fe0 | 2012-03-05 22:47:23 -0500 | [diff] [blame] | 129 | echo. |
Alex Brainman | 7c12849 | 2012-03-13 12:51:28 +1100 | [diff] [blame] | 130 | if %FAIL%==1 goto fail |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 131 | |
Dave Cheney | 36c4a73 | 2012-11-15 11:40:10 +1100 | [diff] [blame] | 132 | set GOMAXPROCS=%OLDGOMAXPROCS% |
| 133 | set OLDGOMAXPROCS= |
| 134 | |
Alex Brainman | 7fbef93 | 2012-03-20 14:04:20 +1100 | [diff] [blame] | 135 | echo # Checking API compatibility. |
Russ Cox | b78410b | 2013-08-09 18:44:00 -0400 | [diff] [blame] | 136 | go run "%GOROOT%\src\cmd\api\run.go" |
Alex Brainman | 7fbef93 | 2012-03-20 14:04:20 +1100 | [diff] [blame] | 137 | if errorlevel 1 goto fail |
| 138 | echo. |
| 139 | |
Russ Cox | 4c1abd6 | 2012-02-04 00:48:31 -0500 | [diff] [blame] | 140 | echo ALL TESTS PASSED |
| 141 | goto end |
| 142 | |
| 143 | :fail |
| 144 | set GOBUILDFAIL=1 |
| 145 | |
| 146 | :end |