forked from StefanScherer/dockerfiles-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ps1
39 lines (34 loc) · 946 Bytes
/
test.ps1
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
$ErrorActionPreference = 'Stop';
$files = ""
Write-Host Starting test
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
Write-Host Pull request $env:APPVEYOR_PULL_REQUEST_NUMBER
$files = $(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master))
} else {
Write-Host Branch $env:APPVEYOR_REPO_BRANCH
$files = $(git diff --name-only HEAD~1)
}
Write-Host Changed files:
$dirs = @{}
$files | ForEach-Object {
Write-Host $_
$dir = $_ -replace "\/[^\/]+$", ""
$dir = $dir -replace "/", "\"
if (Test-Path "$dir\test.bat") {
Write-Host "Storing $dir for test"
$dirs.Set_Item($dir, 1)
} else {
$dir = $dir -replace "\\[^\\]+$", ""
if (Test-Path "$dir\test.bat") {
Write-Host "Storing $dir for test"
$dirs.Set_Item($dir, 1)
}
}
}
$dirs.GetEnumerator() | Sort-Object Name | ForEach-Object {
$dir = $_.Name
Write-Host Testing in directory $dir
pushd $dir
. .\test.bat
popd
}