-
Notifications
You must be signed in to change notification settings - Fork 0
/
runTestsVB.ps1
55 lines (51 loc) · 1.78 KB
/
runTestsVB.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
param([String]$testClass)
$Global:lastRun = $(date)
$testDllDirPath = "$PSScriptRoot\test\VisualBasic\CodeCracker.Test\bin\Debug\"
$testDllFileName = "CodeCracker.Test.VisualBasic.dll"
$Global:testDllFullFileName = "$testDllDirPath$testDllFileName"
$Global:xunitConsole = "$PSScriptRoot\packages\xunit.runners.2.0.0-rc1-build2826\tools\xunit.console.x86.exe"
if ($testClass -eq "now"){
. $Global:xunitConsole "$Global:testDllFullFileName"
return
}
function global:DebounceXunit {
try {
if (($(date) - $script:lastRun).TotalMilliseconds -lt 2000) {
return
}
$Global:lastRun = $(date)
If ($Global:testClass) {
Start-Process $Global:xunitConsole -ArgumentList "`"$Global:testDllFullFileName`" -class $Global:testClass" -NoNewWindow
} Else {
Start-Process $Global:xunitConsole -ArgumentList "`"$Global:testDllFullFileName`"" -NoNewWindow
}
}
catch
{
Write-Host $_.Exception.Message
}
}
Write-Host "Watching $testDllDirPath"
If ($testClass) {
If ($testClass.StartsWith("CodeCracker.Test") -eq $false) {
$testClass = "CodeCracker.Test.$testClass"
}
Write-Host "Only for $testClass"
}
$Global:testClass = $testClass
try {
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $testDllDirPath
$watcher.Filter = $testDllFileName
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite
$changed = Register-ObjectEvent $watcher "Changed" -Action { DebounceXunit }
}
catch {
Write-Host $_.Exception.Message
}
#if we do that, then we don't get any console output:
#Write-Host "Press any key to continue ..."
#[System.Console]::ReadKey()
#Unregister-Event $changed.Id