github.com/22Acacia/terraform@v0.6.5-0.20160105010053-c57aae34c157/make.bat (about)

     1  @echo off
     2  setlocal
     3  
     4  set _EXITCODE=0
     5  
     6  REM If no target is provided, default to test.
     7  if [%1]==[] goto test
     8  
     9  set _TARGETS=generate,test,testacc,testrace,updatedeps,vet
    10  
    11  REM Run target.
    12  for %%a in (%_TARGETS%) do (if x%1==x%%a goto %%a)
    13  goto usage
    14  
    15  REM generate runs `go generate` to build the dynamically generated
    16  REM source files.
    17  :generate
    18  	go generate ./...
    19  	goto :eof
    20  
    21  REM test runs the unit tests and vets the code.
    22  :test
    23  	call :testsetup
    24  	go test %_TEST% %TESTARGS% -timeout=30s -parallel=4
    25  	call :setMaxExitCode %ERRORLEVEL%
    26  	echo.
    27  	goto vet
    28  
    29  REM testacc runs acceptance tests.
    30  :testacc
    31  	call :testsetup
    32  	if x%_TEST% == x./... goto testacc_fail
    33  	if x%_TEST% == x.\... goto testacc_fail
    34  	set TF_ACC=1
    35  	go test %_TEST% -v %TESTARGS% -timeout 45m
    36  	exit /b %ERRORLEVEL%
    37  :testacc_fail
    38  	echo ERROR: Set TEST to a specific package.
    39  	exit /b 1
    40  
    41  REM testrace runs the race checker.
    42  :testrace
    43  	call :testsetup
    44  	go test -race %_TEST% %TESTARGS%
    45  	exit /b %ERRORLEVEL%
    46  
    47  REM testsetup calls `go generate` and defines the variables TF_ACC
    48  REM and _TEST. TF_ACC is always cleared. _TEST defaults to the value
    49  REM of the TEST environment variable, provided that TEST is defined,
    50  REM otherwise _TEST it is set to "./...".
    51  :testsetup
    52  	call :generate
    53  	set TF_ACC=
    54  	set _TEST=./...
    55  	if defined TEST set _TEST=%TEST%
    56  	goto :eof
    57  
    58  REM updatedeps installs all the dependencies that Terraform needs to
    59  REM run and build.
    60  :updatedeps
    61  	for /f "tokens=*" %%c in ('git symbolic-ref --short HEAD 2^>nul ^|^| git rev-parse HEAD') do set _REF=%%c
    62  	go get -u github.com/mitchellh/gox
    63  	go get -u golang.org/x/tools/cmd/stringer
    64  	go get -f -u -v ./...
    65  	call :setMaxExitCode %ERRORLEVEL%
    66  	git checkout %_REF% 1>nul 2>&1
    67  	exit /b %_EXITCODE%
    68  
    69  REM vet runs the Go source code static analysis tool `vet` to find
    70  REM any common errors.
    71  :vet
    72  	set _VETARGS=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
    73  	if defined VETARGS set _VETARGS=%VETARGS%
    74  
    75  	go tool vet 2>nul
    76  	if %ERRORLEVEL% equ 3 go get golang.org/x/tools/cmd/vet
    77  	
    78  	echo go tool vet %_VETARGS% .
    79  	go tool vet %_VETARGS% .
    80  	set _vetExitCode=%ERRORLEVEL%
    81  	if %_vetExitCode% equ 0 exit /b %_EXITCODE%
    82  	call :setMaxExitCode %_vetExitCode%
    83  	echo.
    84  	echo Vet found suspicious constructs. Please check the reported constructs
    85  	echo and fix them if necessary before submitting the code for reviewal.
    86  	exit /b %_EXITCODE%
    87  
    88  :setMaxExitCode
    89  	if %1 gtr %_EXITCODE% set _EXITCODE=%1
    90  	goto :eof
    91  
    92  :usage
    93  	echo usage: make [target]
    94  	echo.
    95  	echo target is in {%_TARGETS%}.
    96  	echo target defaults to test if none is provided.
    97  	exit /b 2
    98  	goto :eof