PSVersionTable.Tests.ps1 handles certain builds incorrectly.

Open Beginner friendly
#27,503 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
powershell
Domain
testing-qa

Research direction

Start in test/powershell/Host/PSVersionTable.Tests.ps1, especially the GitCommitId assertions around line 55, and compare them with the GitCommitId format described in PSVersionInfoGenerator.cs. Update the test's pattern or expectation so the reported 7.6.2-0-g... value is handled correctly, then run the PSVersionTable tests and confirm the clean-tag build produces no error.

Written by the indexing model from the issue text.

Description

Needs-Triage
Prerequisites
Steps to reproduce

Affected version: All up to trunk.

There's a logic mismatch in PSVersionTable.Tests.ps1. More specifically, it tests here whether or not a commit build matches "^(\d+\.\d+\.\d+)(-.+)?" - and the issue is that GitCommitId absolutely can look like that and will indeed. See the comments here in PSVersionInfoGenerator.cs about how such a GitCommitId can look - but most importantly, it's ALWAYS prefixed by the version - and thus always matching the string it should not match.

As you can see, my GitCommitId after a clean build from the 7.6.2 git tag is 7.6.2-0-g0d3c290a8737d4252ee75c052d16190ffcdb7d19. This matches of course.

Expected behavior
No error.
Actual behavior
[-] GitCommitId property 3ms
      Expected regular expression '^(\d+\.\d+\.\d+)(-.+)?-(\d+)-g(.+)$' to not match '7.6.2-0-g0d3c290a8737d4252ee75c052d16190ffcdb7d19', but it did match.
      55:        $PSVersionTable.GitCommitId | Should -Not -Match $unexpectectGitCommitIdPattern
      at <ScriptBlock>, /home/aurutils/.cache/aurutils/sync/powershell/src/PowerShell/test/powershell/Host/PSVersionTable.Tests.ps1: line 55
Error details

Environment data
Name                           Value
----                           -----
PSVersion                      7.6.2
PSEdition                      Core
GitCommitId                    7.6.2-0-g0d3c290a8737d4252ee75c052d16190ffcdb7d19
OS                             Arch Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 11h
Merged PRs (30d)
86

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PowerShell

All issues in PowerShell/PowerShell

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.