From c9116c2d1840739d1794fc6ab9a14b71669665ac Mon Sep 17 00:00:00 2001 From: jhoneill Date: Sun, 8 Dec 2019 22:54:18 +0000 Subject: [PATCH] Add manifest check to tests --- CI/PS-CI.ps1 | 16 +++++++++------- __tests__/ImportExcelTests/Simple.tests.ps1 | 11 +++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CI/PS-CI.ps1 b/CI/PS-CI.ps1 index a22ba97..09e82d1 100644 --- a/CI/PS-CI.ps1 +++ b/CI/PS-CI.ps1 @@ -28,7 +28,7 @@ Param( [Parameter(ParameterSetName = 'Scope')] [switch]$CleanModuleDir ) -Function Show-warning { +Function Show-Warning { param( [Parameter(Position=0,ValueFromPipeline=$true)] $message @@ -49,8 +49,10 @@ if (-not $psdpath -or $psdpath.count -gt 1) { throw "Did not find a unique PSD file " } else { + try {$settings = Test-ModuleManifest -Path $psdpath -ErrorAction stop} + catch {throw $_ ; return} $ModuleName = $psdpath.Name -replace '\.psd1$' , '' - $Settings = $(& ([scriptblock]::Create(($psdpath | Get-Content -Raw)))) + # $Settings = $(& ([scriptblock]::Create(($psdpath | Get-Content -Raw)))) $approvedVerbs = Get-Verb | Select-Object -ExpandProperty verb $script:warningfile = Join-Path -Path $pwd -ChildPath "warnings.txt" } @@ -61,7 +63,7 @@ if (-not $SkipPreChecks) { #Check files in the manifest are present foreach ($file in $Settings.FileList) { if (-not (Test-Path $file)) { - show-warning "File $file in the manifest file list is not present" + Show-Warning "File $file in the manifest file list is not present" } } @@ -85,7 +87,7 @@ if (-not $SkipPreChecks) { $name = $file.name -replace(".ps1","") if ($name -notmatch ("(\w+)-\w+")) {Show-Warning "$name in the public folder is not a verb-noun name"} elseif ($Matches[1] -notin $approvedVerbs) {Show-Warning "$name in the public folder does not start with an approved verb"} - if(-not ($Settings.FunctionsToExport -ceq $name)) { + if(-not ($Settings.ExportedFunctions.Keys -ceq $name)) { Show-Warning ('File {0} in the public folder does not match an exported function in the manifest' -f $file.name) } else { @@ -102,7 +104,7 @@ if (-not $SkipPreChecks) { if ($m2.value -match "(?