From c630a585fa61aac7b8b1debd4b084731ba76c7b7 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 11 Aug 2019 00:36:16 -0400 Subject: [PATCH] coverage attempt --- .gitignore | 1 + azure-pipelines.yml | 48 ++++++++++++++++----------------------------- build.sh | 2 ++ test.sh | 15 ++++++++++++-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 46478856c..7e4c52560 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ _rawPackage/ _dotTrace* _tests/ *.Result.xml +coverage.xml setup/Output/ *.~is diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 38ddf9682..5ea5408e2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -155,7 +155,7 @@ stages: inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Linux Unit + arguments: Linux Unit Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -197,7 +197,7 @@ stages: inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Linux Integration + arguments: Linux Integration Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -221,7 +221,7 @@ stages: inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Windows Unit + arguments: Windows Unit Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -253,14 +253,14 @@ stages: destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' - bash: | ls -R ${BUILD_ARTIFACTSTAGINGDIRECTORY} - mkdir -p .\\bin - cp -R -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}\\bin\\Lidarr\\* .\\bin + mkdir -p ./bin + cp -R -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/* ./bin - task: Bash@3 displayName: Windows Integration Tests inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Windows Integration + arguments: Windows Integration Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -284,7 +284,7 @@ stages: inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Windows Automation + arguments: Windows Automation Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -308,17 +308,17 @@ stages: inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Mac Unit + arguments: Mac Unit Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' testResultsFiles: '**/TestResult.xml' testRunTitle: 'macOS Unit Tests' - - job: Mac_Integration_Tests - displayName: macOS Integration + - job: Unit_Test_Coverage + displayName: Coverage pool: - vmImage: 'macOS-10.13' + vmImage: 'ubuntu-16.04' steps: - checkout: self - task: DownloadPipelineArtifact@2 @@ -327,28 +327,14 @@ stages: buildType: 'current' artifactName: Tests targetPath: $(testsFolder) - - task: DownloadPipelineArtifact@2 - displayName: Download Build Artifact - inputs: - buildType: 'current' - artifactName: Lidarr - itemPattern: '**/Lidarr.**.osx.tar.gz' - targetPath: $(Build.ArtifactStagingDirectory) - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/Lidarr.**.osx.tar.gz' - destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' - - bash: | - mkdir ./bin - cp -R -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/* ./bin - task: Bash@3 - displayName: macOS Integration Tests + displayName: Coverage Unit Tests inputs: targetType: 'filePath' filePath: ./test.sh - arguments: Mac Integration - - task: PublishTestResults@2 + arguments: Linux Unit Coverage + - task: PublishCodeCoverageResults@1 + displayName: Publish Coverage Results inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '**/TestResult.xml' - testRunTitle: 'macOS Integration Tests' \ No newline at end of file + codeCoverageTool: 'cobertura' + summaryFileLocation: '**/Coverage.xml' \ No newline at end of file diff --git a/build.sh b/build.sh index cfadd7752..346923372 100755 --- a/build.sh +++ b/build.sh @@ -261,8 +261,10 @@ PackageTests() if [ $runtime = "dotnet" ] ; then $nuget install NUnit.ConsoleRunner -Version 3.7.0 -Output $testPackageFolder + $nuget install OpenCover -Version 4.7.922 -Output $testPackageFolder else mono $nuget install NUnit.ConsoleRunner -Version 3.7.0 -Output $testPackageFolder + mono $nuget install OpenCover -Version 4.7.922 -Output $testPackageFolder fi cp $outputFolder/*.dll $testPackageFolder diff --git a/test.sh b/test.sh index 79b3b1141..e98c62cbb 100755 --- a/test.sh +++ b/test.sh @@ -1,11 +1,13 @@ #! /bin/bash PLATFORM=$1 TYPE=$2 +COVERAGE=$3 WHERE="cat != ManualTest" TEST_DIR="." TEST_PATTERN="*Test.dll" ASSEMBLIES="" TEST_LOG_FILE="TestLog.txt" +COVERAGE_FILE="$TEST_DIR/Coverage.xml" if [ -d "$TEST_DIR/_tests" ]; then TEST_DIR="$TEST_DIR/_tests" @@ -17,6 +19,7 @@ rm -f "$TEST_LOG_FILE" export LIDARR_TESTS_LOG_OUTPUT="File" NUNIT="$TEST_DIR/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe" +OPEN_COVER="$TEST_DIR/OpenCover.4.7.922/tools/OpenCover.Console.exe" NUNIT_COMMAND="$NUNIT" NUNIT_PARAMS="--workers=1" @@ -53,8 +56,16 @@ for i in `find $TEST_DIR -name "$TEST_PATTERN"`; do ASSEMBLIES="$ASSEMBLIES $i" done -$NUNIT_COMMAND --where "$WHERE" $NUNIT_PARAMS $ASSEMBLIES; -EXIT_CODE=$? +if [ "$COVERAGE" = "Coverage" ]; then + $OPEN_COVER -register:user -target:"$NUNIT" -targetargs:"$NUNIT_PARAMS --where=\"$WHERE\" $ASSEMBLIES" -output:"$COVERAGE_FILE"; + EXIT_CODE=$? +elif [ "$COVERAGE" = "Test" ] ; then + $NUNIT_COMMAND --where "$WHERE" $NUNIT_PARAMS $ASSEMBLIES; + EXIT_CODE=$? +else + echo "Run Type must be provided as third argument: Coverage or Test" + exit 3 +fi if [ "$EXIT_CODE" -ge 0 ]; then echo "Failed tests: $EXIT_CODE"