Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[cmdpal] Migrate some plugin's unit tests from PT run to cmdpal.#40462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
moooyo wants to merge16 commits intomain
base:main
Choose a base branch
Loading
fromyuleng/cmdpal/ut/timeDate-test

Conversation

moooyo
Copy link
Contributor

@moooyomoooyo commentedJul 8, 2025
edited
Loading

Summary of the Pull Request

Migrate blow plugin's from UT to cmdpal:

  1. TimeDate
  2. WindowWalker
  3. System
  4. Registry

This PR is mostly helped by Copilot. Please feel free to change cases in the future.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Yu Leng added9 commitsJuly 4, 2025 17:37
- Migrated unit tests for four PowerToys launcher plugins (Registry, Calculator, WindowWalker, System) to the CmdPal extension framework.- Created new test projects with updated namespaces and structure.- Added comprehensive tests for each extension, ensuring functionality aligns with the new CmdPal architecture.- Updated project configurations to target .NET 9.0 and use MSTest framework with Moq for mocking.- Ensured all tests compile and run correctly in the new environment.
- Refactored ExtendedCalculatorParserTests to use SettingsManager for input validation.- Simplified BasicStructureTest and ensured proper test class structure.- Enhanced BasicTests with additional assertions for command and icon helpers.- Updated QueryTests to reflect changes in command properties and added placeholder tests for network commands.- Improved ImageTests to dynamically access icon properties using reflection.- Added InternalsVisibleTo attributes to allow unit tests access to internal members of extension projects.- Fixed project nesting in PowerToys.sln for better organization of unit test projects.- Documented changes and troubleshooting steps for Visual Studio project visibility issues.
@moooyomoooyo requested a review fromhtcfreekJuly 8, 2025 07:48
@moooyomoooyo self-assigned thisJul 8, 2025
@moooyomoooyo added the Product-Command PaletteRefers to the Command Palette utility labelJul 8, 2025
@moooyomoooyo added this to thePowerToys 0.93 milestoneJul 8, 2025
@moooyomoooyo marked this pull request as ready for reviewJuly 8, 2025 07:56
@crutkascrutkas changed the title[cmdpal] Migrate some plugin's UT from PT run to cmdpal.[cmdpal] Migrate some plugin's unit tests from PT run to cmdpal.Jul 8, 2025
@moooyo
Copy link
ContributorAuthor

/azp run

@azure-pipelinesAzure Pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines 247 to 248
// [DataRow("ime", "", false)] // Partial match should not work
// OK, we need to investigate why ime case does not work
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

only shouldn't work for fallback

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I did some investigate. The reason for this gap is in the cmdpal we assume all query is "keyword search" but for v1 is not.

I think we need to change the related logic? I don't know which one is "correct". any idea?

@@ -298,6 +298,7 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta
}
else
{
inputParsingErrorMsg = Resources.Microsoft_plugin_timedate_InvalidInput_ErrorMessageTitle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why this chabge?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I see all other code path will have inputParsingErrorMsg if return false. Seems we miss it in the main branch?

@yeelam-gordonyeelam-gordon added the Area-Testsissues that relate to tests labelJul 10, 2025
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR migrates unit tests for the TimeDate, WindowWalker, System, and Registry plugins from PT run to the cmdpal framework, adds internal visibility for tests, and patches error messaging in the TimeAndDateHelper.

  • AddedInternalsVisibleTo attributes in each extension’s.csproj to allow unit tests to access internal members.
  • Inserted assignment toinputParsingErrorMsg inTimeAndDateHelper to populate the out parameter on parse failure.
  • Added or updated numerous test projects underExtTests/, along with ausing System; import inAvailableResult.cs.

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

FileDescription
Microsoft.CmdPal.Ext.*.csprojGrant test assemblies internal visibility
TimeAndDateHelper.csPopulate error message on parse failure
AvailableResult.csAddedusing System; import
PowerToys.slnRegistered new test projects in solution
Comments suppressed due to low confidence (6)

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs:301

  • [nitpick] The resource key name uses underscores and lowercase segments; consider renaming it to follow PascalCase (e.g.,TimeDate_InvalidInput_ErrorMessageTitle) for consistency with other resource identifiers.
            inputParsingErrorMsg = Resources.Microsoft_plugin_timedate_InvalidInput_ErrorMessageTitle;

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj:50

  • If the extension assembly is strong-named, InternalsVisibleTo should include the test assembly’s public key token; without it, internal visibility may not be granted to the signed assembly.
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj:15

  • Consider specifying the public key token in the InternalsVisibleTo attribute if this assembly is signed, so that the test project can access internal members.
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.System/Microsoft.CmdPal.Ext.System.csproj:37

  • When using InternalsVisibleTo on a strong-named assembly, include the public key token of the consuming test assembly to ensure proper internal access.
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj:15

  • Add the test assembly’s public key to the InternalsVisibleTo attribute if this assembly is strong-named; otherwise the visibility grant may fail at runtime.
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs:4

  • [nitpick] Theusing System; directive appears unused in this file; consider removing it to keep the imports clean.
using System;

[TestMethod]
public void GetRegistryBaseKeyTestMoreThanOneBaseKey()
{
var (baseKeyList, _) = RegistryHelper.GetRegistryBaseKey("HKC\\Control Panel\\Accessibility"); /* #no-spell-check-line */

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern^.*/\* #no-spell-check-line */.*$ (candidate-pattern)
[TestMethod]
public void GetRegistryBaseKeyTestMoreThanOneBaseKey()
{
var (baseKeyList, _) = RegistryHelper.GetRegistryBaseKey("HKC\\Control Panel\\Accessibility"); /* #no-spell-check-line */

Check warning

Code scanning / check-spelling

Candidate Pattern Warning

Line matches candidate pattern^.*\\bno-spell-check(?:-line|)(?:\\s.*|)$ (candidate-pattern)
@htcfreek
Copy link
Collaborator

what about calculator plugin?

@moooyo
Copy link
ContributorAuthor

moooyo commentedJul 12, 2025 via email

leilei(our teammate) will take calculator one. I've discussed with him last week.

@moooyo
Copy link
ContributorAuthor

what about calculator plugin?

We will complete all plugin ut migration before next release. If possible.

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

Copilot code reviewCopilotCopilot left review comments

@htcfreekhtcfreekhtcfreek requested changes

At least 1 approving review is required to merge this pull request.

Assignees

@moooyomoooyo

Labels
Area-Testsissues that relate to testsProduct-Command PaletteRefers to the Command Palette utility
Projects
None yet
Milestone
PowerToys 0.93
Development

Successfully merging this pull request may close these issues.

3 participants
@moooyo@htcfreek@yeelam-gordon

[8]ページ先頭

©2009-2025 Movatter.jp