- Notifications
You must be signed in to change notification settings - Fork7.2k
[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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- 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.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
...modules/cmdpal/ExtTests/Microsoft.CmdPal.Ext.TimeDate.UnitTests/FallbackTimeDateItemTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...modules/cmdpal/ExtTests/Microsoft.CmdPal.Ext.TimeDate.UnitTests/FallbackTimeDateItemTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/modules/cmdpal/ExtTests/Microsoft.CmdPal.Ext.TimeDate.UnitTests/IconTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
// [DataRow("ime", "", false)] // Partial match should not work | ||
// OK, we need to investigate why ime case does not work |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why this chabge?
There was a problem hiding this comment.
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?
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResult.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/modules/cmdpal/ExtTests/Microsoft.CmdPal.Ext.System.UnitTests/BasicTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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.
- Added
InternalsVisibleTo
attributes in each extension’s.csproj
to allow unit tests to access internal members. - Inserted assignment to
inputParsingErrorMsg
inTimeAndDateHelper
to populate the out parameter on parse failure. - Added or updated numerous test projects under
ExtTests/
, 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.
File | Description |
---|---|
Microsoft.CmdPal.Ext.*.csproj | Grant test assemblies internal visibility |
TimeAndDateHelper.cs | Populate error message on parse failure |
AvailableResult.cs | Addedusing System; import |
PowerToys.sln | Registered 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] The
using 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
[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
what about calculator plugin? |
leilei(our teammate) will take calculator one. I've discussed with him last week. |
We will complete all plugin ut migration before next release. If possible. |
Uh oh!
There was an error while loading.Please reload this page.
Summary of the Pull Request
Migrate blow plugin's from UT to cmdpal:
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