diff --git a/.gitignore b/.gitignore index 4f674094d..92c1621bd 100644 --- a/.gitignore +++ b/.gitignore @@ -221,3 +221,6 @@ PSCompatibilityCollector/out/ # Folder of build module out + +# Explicitely Include test dir +!/Tests/** diff --git a/BuildModule.tests.ps1 b/Tests/Build/BuildModule.tests.ps1 similarity index 95% rename from BuildModule.tests.ps1 rename to Tests/Build/BuildModule.tests.ps1 index 417ba5ae9..542ac2a52 100644 --- a/BuildModule.tests.ps1 +++ b/Tests/Build/BuildModule.tests.ps1 @@ -3,11 +3,11 @@ # these are tests for the build module -import-module -force "./build.psm1" +import-module -force "$PSScriptRoot\..\..\build.psm1" Describe "Build Module Tests" { Context "Global.json" { BeforeAll { - $globalJson = Get-Content (Join-Path $PSScriptRoot global.json) | ConvertFrom-Json + $globalJson = Get-Content (Join-Path "$PSScriptRoot\..\..\" global.json) | ConvertFrom-Json $expectedVersion = $globalJson.sdk.version $result = Get-GlobalJsonSdkVersion } @@ -105,7 +105,7 @@ Describe "Build Module Tests" { Context "Test result functions" { BeforeAll { $xmlFile = @' - + @@ -133,8 +133,8 @@ Describe "Build Module Tests" { '@ $xmlFile | out-file TESTDRIVE:/results.xml - $results = Get-TestResults -logfile TESTDRIVE:/results.xml - $failures = Get-TestFailures -logfile TESTDRIVE:/results.xml + $results = @(Get-TestResults -logfile TESTDRIVE:/results.xml) + $failures = @(Get-TestFailures -logfile TESTDRIVE:/results.xml) } It "Get-TestResults finds 2 results" { diff --git a/build.psm1 b/build.psm1 index 8a61674ee..82b736861 100644 --- a/build.psm1 +++ b/build.psm1 @@ -378,7 +378,7 @@ function Test-ScriptAnalyzer $testModulePath = Join-Path "${projectRoot}" -ChildPath out } $testResultsFile = "'$(Join-Path ${projectRoot} -childPath TestResults.xml)'" - $testScripts = "'${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'" + $testScripts = "'${projectRoot}\Tests\Build','${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'" try { if ( $major -lt 5 ) { Rename-Item $script:destinationDir ${testModulePath}