【发布时间】:2019-01-23 19:45:56
【问题描述】:
我正在使用 powershell 并在本地和 TravisCI 上运行我的测试。
模块清单
RequiredModules = @('ClipboardText')
特拉维斯配置
目前我在运行测试之前安装了powershell 和pester
addons:
apt:
sources:
- sourceline: deb [arch=amd64] https://packages.microsoft.com/ubuntu/14.04/prod trusty main
key_url: https://packages.microsoft.com/keys/microsoft.asc
packages:
- powershell
- xclip
before_script:
- pwsh -Command 'Install-Module -Name Pester -Force -Scope CurrentUser'
script:
- make test
生成文件
test:
pwsh -Command 'Get-childItem -Recurse *.test.ps1 | foreach { Invoke-Pester -EnableExit $$_ }'
特拉维斯构建
Build 抛出错误:
Import-Module : The required module 'ClipboardText' is not loaded.
Load the module or remove the module from 'RequiredModules' in the file '/home/travis/build/edouard-lopez/lesspass-powershell/lesspass.psd1'.
At /home/travis/build/edouard-lopez/lesspass-powershell/Clipboard.test.ps1:1 char:1
+ Import-Module $PSScriptRoot/lesspass.psd1 -Force # force code to be ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (/home/travis/bu...l/lesspass.psd1:String) [Import-Module], MissingMemberException
+ FullyQualifiedErrorId : Modules_InvalidManifest,Microsoft.PowerShell.Commands.ImportModuleCommand
问题
我认为声明 RequiredModules 会安装 ClipboardText 从而允许我的测试正确执行。
如果我在本地手动安装模块 ClipboardText,我的测试工作正常,但是在 CI 和我的模块的未来分发上做正确的事情吗?
【问题讨论】:
-
它会加载模块,但不会安装它。机器上已经安装了吗?如果是,请检查模块的安装路径。它应该位于适用于所有用户的全球位置。
标签: powershell continuous-integration travis-ci pester import-module