Skip to content

Commit

Permalink
Merge pull request #6 from sarthak4allworks/main
Browse files Browse the repository at this point in the history
Updated JoinStykerJsonFile function.
  • Loading branch information
rajbos authored May 16, 2022
2 parents 4c838fe + 3eaf9d5 commit aedd8fb
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions Run Stryker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function RunForOneAssembly ($csprojPath, $testPath, $solutionPath, $outputPath)
Set-Location $testPath

Write-Host "Calling Stryker"
dotnet stryker --project-file "$csprojPath" --solution-path $solutionPath --reporters "['json', 'progress']"
dotnet stryker --project "$csprojPath" --solution $solutionPath --reporter "json" --reporter "progress"

if( -not $? ){
Write-Host "Error in running Stryker, exiting the script"
Expand Down Expand Up @@ -35,26 +35,29 @@ function RunForOneAssembly ($csprojPath, $testPath, $solutionPath, $outputPath)
}

function JoinStykerJsonFile ($additionalFile, $joinedFileName) {
# Stryker report json files object is not an array :-(, so we cannot join them and have to do it manually
$report = (Get-Content $joinedFileName | Out-String)
$additionalContent = (Get-Content $additionalFile | Out-String)

$searchString = '"files": {'
$searchStringLength = $searchString.Length
$startCopy = $additionalContent.IndexOf($searchString)
$offSet = 9
$copyText = $additionalContent.Substring($startCopy+$searchStringLength, $additionalContent.Length-$offSet-$startCopy-$searchStringLength)

# save the first part of the report file
$startCopy = $report.Substring(0, $report.Length-$offSet)
# add in the new copy text
$startCopy = $startCopy + ",`r`n" + $copyText
# add in the end of the file again
$fileEnding = $report.Substring($report.Length-$offSet, $offSet)
$startCopy = $startCopy + $fileEnding

# save the new file to disk
Set-Content -Path $joinedFileName -Value $startCopy
# Stryker report json files object is not an array :-(, so we cannot join them and have to do it manually
$report = (Get-Content $joinedFileName | Out-String)
$additionalContent = (Get-Content $additionalFile | Out-String)

$searchString = '"files":{'
$searchStringLength = $searchString.Length
$startCopy = $additionalContent.IndexOf($searchString)
$offSet = 2
$copyText = $additionalContent.Substring($startCopy+$searchStringLength, $additionalContent.Length-$offSet-$startCopy-$searchStringLength)

# save the first part of the report file
$lastIndex = $report.LastIndexOf('}}')
$startCopy = $report.Substring(0, $lastIndex)

# add in the new copy text
$startCopy = $startCopy + ", " + $copyText

# add in the end of the file again
$fileEnding = $report.Substring($report.Length-$offSet, $offSet)
$startCopy = $startCopy + $fileEnding

# save the new file to disk
Set-Content -Path $joinedFileName -Value $startCopy
}

function JoinJsonWithHtmlFile ($joinedJsonFileName, $reportFileName, $emptyReportFileName, $reportTitle) {
Expand Down

0 comments on commit aedd8fb

Please sign in to comment.