rfennell / AzurePipelines

A single Repo to contain the source for ALL my Azure DevOps Build/Release Extensions. The packages can be found in the Azure DevOps Marketplace
https://marketplace.visualstudio.com/search?term=fenn&target=VSTS&sortBy=Relevance
MIT License
342 stars 431 forks source link

Pester doesn't work on Hosted VS2017 queues #243

Closed dgee2 closed 6 years ago

dgee2 commented 6 years ago

VSTS Extension you are using

Pester

Where are you running it?

VSTS

Version of Extension/Task

current public - 6.*

Expected behaviour and actual behaviour

When running the task against the "Hosted VS2017" agents with the task set to use v4.0.8 of Pester, I receive the following errors

I believe that Pester is now included on the Hosted VS2017 build agents and therefore this line is not actually importing the module: Import-Module -Name $moduleFolder\Pester.psd1 I guess adding -Force on the end may fix this

##[section]Starting: Pester Test Runner
==============================================================================
Task         : Pester Test Runner from Black Marble
Description  : Run Pester tests without the need to install Pester in with the PMModule folder or in the source repo (Using Pester 3.4.3 or 4.0.8)
Version      : 6.1.36
Author       : Richard Fennell
Help         : Version: 6.1.36. [More Information](https://github.com/rfennell/vNextBuild/wiki/Pester-Task/)
==============================================================================
Preparing task execution handler.
Executing the powershell script: d:\a\_tasks\Pester_31ef0033-64e3-4c55-b888-f446541474a6\6.1.36\Pester.ps1
##[warning]Code coverage output not supported on Pester versions before 4.0.4.

Describing ConvertTo-DigitalAction

   Context Passed Single rawObject

    [-] Parses Id correctly 5.21s

      RuntimeException: '-Be' is not a valid Should operator.

      at Get-TestResult, C:\Program Files\WindowsPowerShell\Modules\Pester\3.4.0\Functions\Assertions\Should.ps1: line 42

##[error]System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'First'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
   at System.Management.Automation.ValidateEnumeratedArgumentsAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
   at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at ConvertTo-FailureLines<Process>(Closure , FunctionContext )
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
Tests completed in 10.5s

Passed: 6 Failed: 37 Skipped: 0 Pending: 0 Inconclusive: 0

##[error]Microsoft.PowerShell.Commands.WriteErrorException: Pester returned errors
##[error]PowerShell script completed with 2 errors.
##[section]Finishing: Pester Test Runner

Steps to reproduce the problem

Run Pester against any PS module on the Hosted VS2017 queue

ChrisLGardner commented 6 years ago

That looks like it's importing pester 3.4 instead of the specified version. I'll have a look into this a bit later as we should have fixed this with the last release.


From: Daniel Gee notifications@github.com Sent: Sunday, January 14, 2018 12:31:30 AM To: rfennell/vNextBuild Cc: Subscribed Subject: [rfennell/vNextBuild] Pester doesn't work on Hosted VS2017 queues (#243)

VSTS Extension you are using

Pester

Where are you running it?

VSTS

Version of Extension/Task

current public - 6.*

Expected behaviour and actual behaviour

When running the task against the "Hosted VS2017" agents with the task set to use v4.0.8 of Pester, I receive the following errors

I believe that Pester is now included on the Hosted VS2017 build agents and therefore this line is not actually importing the module: Import-Module -Name $moduleFolder\Pester.psd1https://github.com/rfennell/vNextBuild/blob/543a52a8c0478e57a91a03692ef02db4b1d00d75/Extensions/Pester/task/Pester.ps1#L88 I guess adding -Force on the end may fix this

[section]Starting: Pester Test Runner

============================================================================== Task : Pester Test Runner from Black Marble Description : Run Pester tests without the need to install Pester in with the PMModule folder or in the source repo (Using Pester 3.4.3 or 4.0.8) Version : 6.1.36 Author : Richard Fennell Help : Version: 6.1.36. More Information

Preparing task execution handler. Executing the powershell script: d:\a_tasks\Pester_31ef0033-64e3-4c55-b888-f446541474a6\6.1.36\Pester.ps1

[warning]Code coverage output not supported on Pester versions before 4.0.4.

Describing ConvertTo-DigitalAction

Context Passed Single rawObject

[-] Parses Id correctly 5.21s

  RuntimeException: '-Be' is not a valid Should operator.

  at Get-TestResult, C:\Program Files\WindowsPowerShell\Modules\Pester\3.4.0\Functions\Assertions\Should.ps1: line 42

[error]System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'First'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.

at System.Management.Automation.ValidateEnumeratedArgumentsAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics) at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at ConvertTo-FailureLines(Closure , FunctionContext ) at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) at System.Management.Automation.PSScriptCmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() Tests completed in 10.5s

Passed: 6 Failed: 37 Skipped: 0 Pending: 0 Inconclusive: 0

[error]Microsoft.PowerShell.Commands.WriteErrorException: Pester returned errors

[error]PowerShell script completed with 2 errors.

[section]Finishing: Pester Test Runner

Steps to reproduce the problem

Run Pester against any PS module on the Hosted VS2017 queue

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/rfennell/vNextBuild/issues/243, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQDqFqHQl45hHCCJCmdmC1LVlVspytvLks5tKUrigaJpZM4RdbJY.

rfennell commented 6 years ago

@dgee2 could you run you build again with the system.debug build variable set to try so we get a detailed debug log.

We need to see the parameters being set on the task, and any other messages.

If the former what do you see when you force usage of pester 4.0.x from with task?

rfennell commented 6 years ago

I ran my validation build against the current VS2017 and it did not error, whether or not I was picking the versions of Pester.

For now I would suggest you pick the option to used the 4.0.8 version included within the task while we look into the loading logic further

rfennell commented 6 years ago

As per my standard practice I am closing this issue as I have heard nothing for a while and I think I have provides a solution/workaround.

If this issue remains a problem please do not hesitate to re-open it