Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@niheaven
Copy link
Member

@niheaven niheaven commented Oct 24, 2022

Description

Initial works to refactor Scoop Core tests.

Adapt to Pester 5 for all the tests, and this may not compatible with current bucket tests (must explicitly require Pester 5, which is 4 now)

diff --git a/bin/test.ps1 b/bin/test.ps1
index d2d93f2..94de7bc 100644
--- a/bin/test.ps1
+++ b/bin/test.ps1
@@ -1,10 +1,20 @@
-#Requires -Modules @{ ModuleName = 'Pester'; MaximumVersion = '4.99' }
+#Requires -Version 5.1
+#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.2.0' }
 
 <#
 .SYNOPSIS
     Execute Pester tests in repository root directory.
 #>
 
-$result = Invoke-Pester "$PSScriptRoot\.." -PassThru
+$pesterConfig = New-PesterConfiguration -Hashtable @{
+    Run    = @{
+        Path     = "$PSScriptRoot\.."
+        PassThru = $true
+    }
+    Output = @{
+        Verbosity = 'Detailed'
+    }
+}
+$result = Invoke-Pester -Configuration $pesterConfig
 
 exit $result.FailedCount

I've tried my best to make Import-Bucket-Tests.ps1 be compatible with Pester 4, but haven't found the solution. The first run in bucket always breaks the test, while the second run is succeed. But in buckets' CI, the process only run once. The bug here is Pester 5's Discovery and Run feature runs Discovery in its own folder, and deprecate the use of $MyInvocation.PSScriptRoot or $MyInvocation.PSCommandPath in tests, so I could not pass correct folder parameter to the tests.

Motivation and Context

The tests in Scoop should be refactored and reorgnized to reflect the growing code base, and the first step is using Pester 5.

How Has This Been Tested?

Now it has 130 tests in total, and 31 of them are only for Windows.

Windows:

image

Ubuntu:

image

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@niheaven
Copy link
Member Author

I'll merge this PR if @ScoopInstaller/maintainers have no comments, since this is just about tests. Further refactoring of tests will be done then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants