forked from NModbus4/NModbus4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests-and-coverage.ps1
24 lines (24 loc) · 1.28 KB
/
run-tests-and-coverage.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
$isPullRequest = $env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null
$packagesDir = "./packages"
$coverageDir = "./codecoverage"
$xunitConsoleExe = "$packagesDir/xunit.runner.console.2.0.0/tools/xunit.console.exe"
$openCoverExe = "$packagesDir/OpenCover.4.6.166/tools/OpenCover.Console.exe"
$reportGeneratorExe = "$packagesDir/ReportGenerator.2.2.0.0/tools/ReportGenerator.exe"
$testDir = "*Tests/bin/*"
$tests = @("$testDir/*Tests.dll")
$targetArgs = Get-ChildItem $tests -Recurse
$openCoverXml = "opencover_report.xml"
$xunitXml = "xunit_report.xml"
$converallsNetExe = "$packagesDir/coveralls.io.1.3.4/tools/coveralls.net.exe"
$openCoverArgs = @('-register:user', "`"-target:$xunitConsoleExe`"", "`"-targetargs:$targetArgs -appveyor -noshadow -nologo -quiet`"", "`"-filter:+[NModbus4]*`"", "`"-output:$openCoverXml`"", '-coverbytest:*Tests.dll', '-log:All', '-returntargetcode')
& $xunitConsoleExe $targetArgs -xml $xunitXml
$testsFailed = Select-String $xunitXml -pattern "<failure .*>" -Quiet
if (!$testsFailed)
{
& $openCoverExe $openCoverArgs
& $reportGeneratorExe -verbosity:Info "`"-reports:$openCoverXml`"" "`"-targetdir:$coverageDir`""
if (!$isPullRequest)
{
& $converallsNetExe --opencover $openCoverXml --full-sources --repo-token gSRzaRcGVrNfpOrbaEwGCEej4KypnMnK1
}
}