1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#Requires -Version 7.0
Param(
[string] $serviceDirectory
)
$repoRoot = Resolve-Path "$PSScriptRoot/../../"
Push-Location $repoRoot/eng/tools/smoketests
# create a smoketests directory
$smoketestsDir = Join-Path $repoRoot sdk smoketests
Write-Host "Creating a new directory for smoketests at $smoketestsDir"
New-Item -Path $smoketestsDir -ItemType Directory
Push-Location $smoketestsDir
Write-Host "Running 'go mod init' in $pwd"
go mod init github.com/Azure/azure-sdk-for-go/sdk/smoketests
Pop-Location
# Run smoketests script
Write-Host "Running 'go run . -serviceDirectory $serviceDirectory'"
go run . -serviceDirectory $serviceDirectory
if ($LASTEXITCODE) {
exit $LASTEXITCODE
}
Pop-Location
# Run go mod tidy and go build. If these succeed the smoke tests pass
Push-Location $smoketestsDir
go fmt ./...
Write-Host "Printing content of go.mod file:"
Get-Content go.mod
Write-Host "Printing content of main.go file"
Get-Content main.go
go mod tidy
go build ./...
go run .
Pop-Location
# Clean-up the directory created
Remove-Item -Path $smoketestsDir -Recurse -Force
|