forked from code-cracker/code-cracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runTestsVB.ps1
55 lines (51 loc) · 1.84 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 = $lastRun = [System.DateTime]::Now
$testDllDirPath = "$PSScriptRoot\test\VisualBasic\CodeCracker.Test\bin\Debug\"
$testDllFileName = "CodeCracker.Test.VisualBasic.dll"
$Global:testDllFullFileName = "$testDllDirPath$testDllFileName"
$Global:xunitConsole = "$PSScriptRoot\packages\xunit.runner.console.2.0.0\tools\xunit.console.x86.exe"
if ($testClass -eq "now"){
. $Global:xunitConsole "$Global:testDllFullFileName"
return
}
function global:DebounceXunit {
try {
if (([System.DateTime]::Now - $script:lastRun).TotalMilliseconds -lt 2000) {
return
}
$Global:lastRun = [System.DateTime]::Now
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.VisualBasic.$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