Skip to content

Commit 25b6548

Browse files
authored
Fix build module tests (#1654)
1 parent 6e95790 commit 25b6548

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,6 @@ PSCompatibilityCollector/out/
221221

222222
# Folder of build module
223223
out
224+
225+
# Explicitely Include test dir
226+
!/Tests/**

BuildModule.tests.ps1 renamed to Tests/Build/BuildModule.tests.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
# these are tests for the build module
55

6-
import-module -force "./build.psm1"
6+
import-module -force "$PSScriptRoot\..\..\build.psm1"
77
Describe "Build Module Tests" {
88
Context "Global.json" {
99
BeforeAll {
10-
$globalJson = Get-Content (Join-Path $PSScriptRoot global.json) | ConvertFrom-Json
10+
$globalJson = Get-Content (Join-Path "$PSScriptRoot\..\..\" global.json) | ConvertFrom-Json
1111
$expectedVersion = $globalJson.sdk.version
1212
$result = Get-GlobalJsonSdkVersion
1313
}
@@ -105,7 +105,7 @@ Describe "Build Module Tests" {
105105
Context "Test result functions" {
106106
BeforeAll {
107107
$xmlFile = @'
108-
<?xml version="1.0" encoding="utf-8" standalone="no"?>
108+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
109109
<test-results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="nunit_schema_2.5.xsd" name="Pester" total="2" errors="0" failures="1" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2019-02-19" time="11:36:56">
110110
<environment platform="Darwin" clr-version="Unknown" os-version="18.2.0" cwd="/Users/jimtru/src/github/forks/JamesWTruher/PSScriptAnalyzer" user="jimtru" user-domain="" machine-name="Jims-Mac-mini.guest.corp.microsoft.com" nunit-version="2.5.8.0" />
111111
<culture-info current-culture="en-US" current-uiculture="en-US" />
@@ -133,8 +133,8 @@ Describe "Build Module Tests" {
133133
'@
134134

135135
$xmlFile | out-file TESTDRIVE:/results.xml
136-
$results = Get-TestResults -logfile TESTDRIVE:/results.xml
137-
$failures = Get-TestFailures -logfile TESTDRIVE:/results.xml
136+
$results = @(Get-TestResults -logfile TESTDRIVE:/results.xml)
137+
$failures = @(Get-TestFailures -logfile TESTDRIVE:/results.xml)
138138
}
139139

140140
It "Get-TestResults finds 2 results" {

build.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ function Test-ScriptAnalyzer
378378
$testModulePath = Join-Path "${projectRoot}" -ChildPath out
379379
}
380380
$testResultsFile = "'$(Join-Path ${projectRoot} -childPath TestResults.xml)'"
381-
$testScripts = "'${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
381+
$testScripts = "'${projectRoot}\Tests\Build','${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
382382
try {
383383
if ( $major -lt 5 ) {
384384
Rename-Item $script:destinationDir ${testModulePath}

0 commit comments

Comments
 (0)