diff --git a/.build/BuildToolkit.ps1 b/.build/BuildToolkit.ps1 index 3deaec164..e96fb9685 100644 --- a/.build/BuildToolkit.ps1 +++ b/.build/BuildToolkit.ps1 @@ -4,7 +4,6 @@ $OpenCoverVersion = "4.7.922"; $DocFxVersion = "2.52.0"; $CodecovVersion = "1.10.0"; $ReportGeneratorVersion = "4.5.6"; -$GitLinkVersion = "3.1.0"; # Folder Pathes $RootPath = $MyInvocation.PSScriptRoot; @@ -31,9 +30,9 @@ $NugetPackageTarget = "https://www.myget.org/F/moryx/api/v2/package"; # Define Tools $global:MSBuildCli = "msbuild.exe"; +$global:DotNetCli = "dotnet.exe"; $global:NugetCli = "nuget.exe"; $global:GitCli = ""; -$global:GitLink = "$BuildTools\GitLink.$GitLinkVersion\build\GitLink.exe"; $global:OpenCoverCli = "$BuildTools\OpenCover.$OpenCoverVersion\tools\OpenCover.Console.exe"; $global:NunitCli = "$BuildTools\NUnit.ConsoleRunner.$NunitVersion\tools\nunit3-console.exe"; $global:CodecovCli = "$BuildTools\Codecov.$CodecovVersion\tools\codecov.exe"; @@ -83,6 +82,10 @@ function Invoke-Initialize([string]$Version = "1.0.0", [bool]$Cleanup = $False) $env:MORYX_BUILD_VERBOSITY = "minimal" } + if (-not $env:MORYX_TEST_VERBOSITY) { + $env:MORYX_TEST_VERBOSITY = "normal" + } + if (-not $env:MORYX_NUGET_VERBOSITY) { $env:MORYX_NUGET_VERBOSITY = "normal" } @@ -116,15 +119,15 @@ function Invoke-Initialize([string]$Version = "1.0.0", [bool]$Cleanup = $False) Write-Variable "ReportGeneratorCli" $global:ReportGeneratorCli; Write-Variable "DocFxCli" $global:DocFxCli; Write-Variable "GitCli" $global:GitCli; - Write-Variable "GitLink" $global:GitLink; Write-Variable "GitCommitHash" $global:GitCommitHash; Write-Variable "MORYX_BRANCH" $env:MORYX_BRANCH; Write-Variable "MORYX_VERSION" $env:MORYX_VERSION; Write-Variable "MORYX_ASSEMBLY_VERSION" $env:MORYX_ASSEMBLY_VERSION; + Write-Variable "MORYX_OPTIMIZE_CODE" $env:MORYX_OPTIMIZE_CODE; Write-Variable "MORYX_BUILDNUMBER" $env:MORYX_BUILDNUMBER; Write-Variable "MORYX_BUILD_CONFIG" $env:MORYX_BUILD_CONFIG; Write-Variable "MORYX_BUILD_VERBOSITY" $env:MORYX_BUILD_VERBOSITY; - Write-Variable "MORYX_OPTIMIZE_CODE" $env:MORYX_OPTIMIZE_CODE; + Write-Variable "MORYX_TEST_VERBOSITY" $env:MORYX_TEST_VERBOSITY; Write-Variable "MORYX_NUGET_VERBOSITY" $env:MORYX_NUGET_VERBOSITY; # Cleanp @@ -244,52 +247,60 @@ function Invoke-CoverTests($SearchPath = $RootPath, $SearchFilter = "*.csproj", CreateFolderIfNotExists $OpenCoverReportsDir; CreateFolderIfNotExists $NunitReportsDir; + $includeFilter = "+[Moryx*]*"; + $excludeFilter = "-[*nunit*]* -[*Tests]* -[*Model*]*"; + + if (Test-Path $FilterFile) { + $ignoreContent = Get-Content $FilterFile; + + foreach ($line in $ignoreContent) { + $parts = $line.Split(":"); + if ($parts.Count -lt 2) { + continue + } + + $filterType = $parts[0]; + $filterValue = $parts[1]; + + if ($filterType.StartsWith("INCLUDE")) { + $includeFilter += " $filterValue"; + } + + if ($filterType.StartsWith("EXCLUDE")) { + $excludeFilter += " $filterValue"; + } + } + + Write-Host "Active Filter: `r`n Include: $includeFilter `r`n Exclude: $excludeFilter"; + } + ForEach($testProject in $testProjects ) { $projectName = ([System.IO.Path]::GetFileNameWithoutExtension($testProject.Name)); $testAssembly = [System.IO.Path]::Combine($testProject.DirectoryName, "bin", $env:MORYX_BUILD_CONFIG, "$projectName.dll"); + $isNetCore = Get-CsprojIsNetCore($testProject); Write-Host "OpenCover Test: ${projectName}:"; $nunitXml = ($NunitReportsDir + "\$projectName.TestResult.xml"); $openCoverXml = ($OpenCoverReportsDir + "\$projectName.OpenCover.xml"); - # If assembly does not exists, the project will be build - if (-not (Test-Path $testAssembly)) { - Invoke-Build $testProject + if ($isNetCore) { + $targetArgs = '"test -v ' + $env:MORYX_TEST_VERBOSITY + ' -c ' + $env:MORYX_BUILD_CONFIG + ' ' + $testProject + '"'; + $openCoverAgs = "-target:$global:DotNetCli", "-targetargs:$targetArgs" } - - $includeFilter = "+[Moryx*]*"; - $excludeFilter = "-[*nunit*]* -[*Tests]* -[*Model*]*"; - - if (Test-Path $FilterFile) { - $ignoreContent = Get-Content $FilterFile; - - foreach ($line in $ignoreContent) { - $parts = $line.Split(":"); - if ($parts.Count -lt 2) { - continue - } - - $filterType = $parts[0]; - $filterValue = $parts[1]; - - if ($filterType.StartsWith("INCLUDE")) { - $includeFilter += " $filterValue"; - } - - if ($filterType.StartsWith("EXCLUDE")) { - $excludeFilter += " $filterValue"; - } + else { + # If assembly does not exists, the project will be build + if (-not (Test-Path $testAssembly)) { + Invoke-Build $testProject } - } - Write-Host "Active Filter: `r`n Include: $includeFilter `r`n Exclude: $excludeFilter"; + $openCoverAgs = "-target:$global:NunitCli", "-targetargs:/config:$env:MORYX_BUILD_CONFIG /result:$nunitXml $testAssembly" + } - $openCoverAgs = "-target:$global:NunitCli", "-targetargs:/config:$env:MORYX_BUILD_CONFIG /result:$nunitXml $testAssembly" - $openCoverAgs += "-log:Debug", "-register:administrator", "-output:$openCoverXml", "-hideskipped:all", "-skipautoprops", "-excludebyattribute:*OpenCoverIgnore*"; + $openCoverAgs += "-log:Debug", "-register:user", "-output:$openCoverXml", "-hideskipped:all", "-skipautoprops"; $openCoverAgs += "-returntargetcode" # We need the nunit return code $openCoverAgs += "-filter:$includeFilter $excludeFilter" - + & $global:OpenCoverCli $openCoverAgs $exitCode = [int]::Parse($LastExitCode); @@ -315,6 +326,20 @@ function Invoke-CoverTests($SearchPath = $RootPath, $SearchFilter = "*.csproj", } } +function Get-CsprojIsNetCore($csprojFile) { + [xml]$csprojContent = Get-Content $csprojFile.FullName + $sdkProject = $csprojContent.Project.Sdk; + if ($null -ne $sdkProject) { + # Read Target Framework + $targetFramework = $csprojContent.Project.PropertyGroup.TargetFramework; + if ($targetFramework -Match "netcoreapp") { + # NETCore + return $true; + } + } + return $false; +} + function Invoke-CoverReport { Write-Step "Creating cover report. Searching for OpenCover.xml files in $OpenCoverReportsDir." @@ -375,48 +400,6 @@ function Invoke-DocFx($Metadata = [System.IO.Path]::Combine($DocumentationDir, " CopyAndReplaceFolder $docFxDest "$DocumentationArtifcacts\DocFx"; } -function Invoke-SourceIndex([string]$RawUrl, [string]$SearchPath = [System.IO.Path]::Combine($PSScriptRoot, "..\")) { - Write-Step "Indexing SourceCode and patching PDBs to $RawUrl" - - if (-not (Test-Path $global:GitLink)) { - Install-Tool "GitLink" $GitLinkVersion $global:GitLink; - } - - $sourceLink = "$RawUrl/{revision}/{filename}"; - - Write-Host "SearchPath for Projects: $SearchPath"; - $csprojs = Get-Childitem $SearchPath -recurse | Where-Object {$_.extension -eq ".csproj"} - - foreach ($csporj in $csprojs) { - Write-Host; - Write-Host "Reading csproj: $($csporj.Name)"; - - $csprojXml = [xml](Get-Content $csporj.FullName); - - $outputGroup = $csprojXml.Project.PropertyGroup | Where-Object Condition -Like "*$env:MORYX_BUILD_CONFIG|AnyCPU*"; - $outputPath = $outputGroup.OutputPath; - - $assemblyGroup = $csprojXml.Project.PropertyGroup | Where-Object {-not ([string]::IsNullOrEmpty($_.AssemblyName)) } - $assemblyName = $assemblyGroup.AssemblyName; - - $pdbFileName = $($assemblyName + ".pdb"); - $projectPdbPath = [System.IO.Path]::Combine($outputPath, $pdbFileName); - $pdbPath = [System.IO.Path]::Combine($csporj.DirectoryName, $projectPdbPath); - - Write-Host "PDB path of assembly for $($csporj.Name) is: $projectPdbPath" - - if (-not (Test-Path $pdbPath)) { - Write-Host "PDB was not found. Project will be ignored!" - continue; - } - - $args = "-u", "$sourceLink"; - $args += $pdbPath - - & $global:GitLink $args - } -} - function Invoke-Pack($FilePath, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) { CreateFolderIfNotExists $NugetPackageArtifacts; diff --git a/src/Moryx.TestTools.SystemTest/HeartOfGoldController.cs b/src/Moryx.TestTools.SystemTest/HeartOfGoldController.cs index 886249cbb..52660dfd6 100644 --- a/src/Moryx.TestTools.SystemTest/HeartOfGoldController.cs +++ b/src/Moryx.TestTools.SystemTest/HeartOfGoldController.cs @@ -185,9 +185,9 @@ public HeartOfGoldController(string buildDirectoryName, string runtimeDirectoryN /// Starts the HeartOfGold executable. /// /// true if start succeeds, false if not - public bool StartHeartOfGold() + public bool StartApplication() { - return StartHeartOfGold(ApplicationExeName); + return StartApplication(ApplicationExeName); } /// @@ -196,25 +196,25 @@ public bool StartHeartOfGold() /// Name of the executable. /// true if start succeeds, false if not /// - /// Can't start HeartOfGold without RuntimeDir. + /// Can't start application without RuntimeDir. /// or - /// Can't start HeartOfGold without ConfigDir. + /// Can't start application without ConfigDir. /// or /// HeartOfGold is already running. /// - private bool StartHeartOfGold(string exeName) + private bool StartApplication(string exeName) { // check the runtime directory if (RuntimeDir == null) - throw new InvalidOperationException("Can't start HeartOfGold without RuntimeDir."); + throw new InvalidOperationException($"Can't start {ApplicationExeName} without RuntimeDir."); // check the config directory if (ConfigDir == null) - throw new InvalidOperationException("Can't start HeartOfGold without ConfigDir."); + throw new InvalidOperationException($"Can't start {ApplicationExeName} without ConfigDir."); // check that the process is not already running if (Process != null && !Process.HasExited) - throw new InvalidOperationException("HeartOfGold is already running."); + throw new InvalidOperationException($"{ApplicationExeName} is already running."); var wcfConfig = Path.Combine(RuntimeDir, ConfigDir, "Moryx.Tools.Wcf.WcfConfig" + ConfigConstants.FileExtension); if (File.Exists(wcfConfig)) diff --git a/src/Tests/Moryx.Runtime.SystemTests/BasicConfigTests.cs b/src/Tests/Moryx.Runtime.SystemTests/BasicConfigTests.cs index 2fdba75f6..d0ac30065 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/BasicConfigTests.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/BasicConfigTests.cs @@ -105,7 +105,7 @@ public void Setup() Console.WriteLine("Starting HeartOfGold"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); Assert.IsTrue(started, "Can't start HeartOfGold."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); diff --git a/src/Tests/Moryx.Runtime.SystemTests/BasicTests.cs b/src/Tests/Moryx.Runtime.SystemTests/BasicTests.cs index bcc7c43a8..21784da05 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/BasicTests.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/BasicTests.cs @@ -70,7 +70,7 @@ public void TestStartStop() { PrintStartMsg("TestStartStop"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); Assert.IsTrue(started, "Can't start HeartOfGold."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); @@ -90,7 +90,7 @@ public void TestStartTimeout() PrintStartMsg("TestStartTimeout"); _hogController.ExecutionTimeout = 5; - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); Assert.IsTrue(started, "Can't start HeartOfGold."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); @@ -107,7 +107,7 @@ public bool TestStartWaitStop(string service, ServerModuleState state) { PrintStartMsg("TestStartWaitStop('{0}', '{1}')", service, state); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); _hogController.CreateClients(); Assert.IsTrue(started, "Can't start HeartOfGold."); @@ -129,7 +129,7 @@ public void TestStartKill() { PrintStartMsg("TestStartKill"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); Assert.IsTrue(started, "Can't start HeartOfGold."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); diff --git a/src/Tests/Moryx.Runtime.SystemTests/DatabaseTests.cs b/src/Tests/Moryx.Runtime.SystemTests/DatabaseTests.cs index fffba3077..ba312af89 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/DatabaseTests.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/DatabaseTests.cs @@ -40,7 +40,7 @@ public void Setup() Console.WriteLine("Starting HeartOfGold"); - var started = _hogController.StartHeartOfGold(); + var started = _hogController.StartApplication(); Assert.IsTrue(started, "Can't start HeartOfGold."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); diff --git a/src/Tests/Moryx.Runtime.SystemTests/HogHelper.cs b/src/Tests/Moryx.Runtime.SystemTests/HogHelper.cs index cd25c4c49..1fb778135 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/HogHelper.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/HogHelper.cs @@ -27,7 +27,7 @@ public class HogHelper /// public bool StartHeartOfGold(string service) { - if (HogController.StartHeartOfGold()) + if (HogController.StartApplication()) { return HogController.WaitForService(service); } diff --git a/src/Tests/Moryx.Runtime.SystemTests/LifeCycleTests.cs b/src/Tests/Moryx.Runtime.SystemTests/LifeCycleTests.cs index 26f323bb1..b31a6b0e3 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/LifeCycleTests.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/LifeCycleTests.cs @@ -29,7 +29,7 @@ public void TestFixtureSetUp() Console.WriteLine("Starting HeartOfGold"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); _hogController.CreateClients(); Assert.IsTrue(started, "Can't start HeartOfGold."); diff --git a/src/Tests/Moryx.Runtime.SystemTests/LoggingTests.cs b/src/Tests/Moryx.Runtime.SystemTests/LoggingTests.cs index 87925dac0..aef53d8f2 100644 --- a/src/Tests/Moryx.Runtime.SystemTests/LoggingTests.cs +++ b/src/Tests/Moryx.Runtime.SystemTests/LoggingTests.cs @@ -70,7 +70,7 @@ public void TestFixtureSetUp() Console.WriteLine("Starting HeartOfGold"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); _hogController.CreateClients(); Assert.IsTrue(started, "Can't start HeartOfGold."); diff --git a/src/Tests/Moryx.Tests/Serialization/EntryToModelConverterTests.cs b/src/Tests/Moryx.Tests/Serialization/EntryToModelConverterTests.cs index 32521dd31..a0cf7b3ea 100644 --- a/src/Tests/Moryx.Tests/Serialization/EntryToModelConverterTests.cs +++ b/src/Tests/Moryx.Tests/Serialization/EntryToModelConverterTests.cs @@ -24,7 +24,7 @@ public void ConvertFromModelAndBackToModel() // Act var serverEntry = EntryConvert.EncodeObject(dummyClass, new DefaultSerialization { FormatProvider = new CultureInfo("en-us") }); - + var clientConverter = EntryToModelConverter.Create(new CultureInfo("en-us")); clientConverter.FromModel(serverEntry, dummyClassClient); diff --git a/src/Tests/Moryx.Tools.Wcf.SystemTests/ClientFactoryTests.cs b/src/Tests/Moryx.Tools.Wcf.SystemTests/ClientFactoryTests.cs index 3b7731171..38b520219 100644 --- a/src/Tests/Moryx.Tools.Wcf.SystemTests/ClientFactoryTests.cs +++ b/src/Tests/Moryx.Tools.Wcf.SystemTests/ClientFactoryTests.cs @@ -76,10 +76,10 @@ public void TestFixtureSetUp() Console.WriteLine("Starting HeartOfGold"); - bool started = _hogController.StartHeartOfGold(); + bool started = _hogController.StartApplication(); _hogController.CreateClients(); - Assert.IsTrue(started, "Can't start HeartOfGold."); + Assert.IsTrue(started, "Can't start application."); Assert.IsFalse(_hogController.Process.HasExited, "HeartOfGold has exited unexpectedly."); bool result = _hogController.WaitForService(ModuleController.ModuleName, ServerModuleState.Running, 10); diff --git a/src/Tests/Moryx.Tools.Wcf.SystemTests/VersionServiceTests.cs b/src/Tests/Moryx.Tools.Wcf.SystemTests/VersionServiceTests.cs index 008ba3f24..cac87e321 100644 --- a/src/Tests/Moryx.Tools.Wcf.SystemTests/VersionServiceTests.cs +++ b/src/Tests/Moryx.Tools.Wcf.SystemTests/VersionServiceTests.cs @@ -34,7 +34,7 @@ public void TestFixtureSetUp() Console.WriteLine("Starting HeartOfGold"); - var started = _hogController.StartHeartOfGold(); + var started = _hogController.StartApplication(); _hogController.CreateClients(); Assert.IsTrue(started, "Can't start HeartOfGold.");