Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: empty implement testing 1.84 api #4167

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

Ricbet
Copy link
Member

@Ricbet Ricbet commented Nov 13, 2024

Types

  • 🎉 New Features

Background or solution

  • Support TestController.invalidateTestResults
  • Support TestMessage.contextValue
  • Support TestRunProfile.supportsContinuousRun
  • Support TestRunRequest.continuous
  • Support TestRunRequest.preserveFocus // 1.87 版本中已删除

Changelog

空实现 1.84 版本的 testing 插件 api

Summary by CodeRabbit

  • 新功能

    • 添加了 $markTestRetired 方法,用于标记测试或控制器为已退役。
    • TestMessage 中新增 contextValue 属性,以提供更详细的错误报告。
    • 引入 supportsContinuousRun 属性,支持持续测试执行。
    • 新增 invalidateTestResults 方法,允许标记测试结果为过时。
  • 文档

    • 更新了 runHandler 方法的文档,说明支持持续运行的配置。

@Ricbet Ricbet self-assigned this Nov 13, 2024
@opensumi opensumi bot added the 🎨 feature feature required label Nov 13, 2024
Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

该拉取请求引入了多个更改,主要集中在测试管理功能的增强上。新增了$markTestRetired方法,以便将测试标记为不再使用。同时,TestMessage命名空间和相关接口进行了更新,增加了contextValue属性,以便更好地处理测试消息的上下文。其他文件中也进行了相应的结构和接口修改,以支持这些新特性。

Changes

文件路径 更改摘要
packages/extension/src/browser/vscode/api/main.thread.tests.ts 新增方法:`$markTestRetired(testIds: string[]
packages/extension/src/common/vscode/converter.ts 更新函数:fromto,新增contextValue属性
packages/extension/src/common/vscode/ext-types.ts 新增属性:contextValue?: string
packages/extension/src/common/vscode/tests.ts 新增方法:`$markTestRetired(testIds: string[]
packages/extension/src/hosted/api/vscode/ext.host.tests.ts 新增接口:ITestRunProfile;更新createRunProfile方法;新增属性activeProfiles: Set<number>;新增事件onDidChangeDefault
packages/testing/src/common/testCollection.ts 新增属性:supportsContinuousRun: boolean;更新ITestErrorMessage接口,新增contextValue属性
packages/types/vscode/typings/vscode.tests.d.ts 新增属性:supportsContinuousRun: boolean;新增方法:invalidateTestResults;更新TestRunRequest类,新增continuous属性;新增contextValue属性
packages/utils/src/event.ts 更新方法:chain,引入新的参数和类以增强事件处理能力

Possibly related PRs

Suggested labels

🎨 feature

Suggested reviewers

  • bytemain

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (5)
packages/extension/src/common/vscode/tests.ts (1)

116-117: 接口方法签名正确,建议添加文档注释

方法签名设计合理,可以同时支持标记单个测试或整个控制器为已废弃。不过建议添加 JSDoc 文档注释来说明:

  • 参数 testIds 为空时的行为
  • 方法的具体作用
  • 使用示例

建议添加如下文档注释:

+/**
+ * 将指定的测试或整个控制器标记为已废弃。
+ * @param testIds 要标记为已废弃的测试ID数组。如果未提供,则标记所有测试。
+ */
$markTestRetired(testIds: string[] | undefined): void;
packages/extension/src/browser/vscode/api/main.thread.tests.ts (1)

213-215: 建议添加方法文档注释

为了提高代码的可维护性,建议添加详细的方法文档,说明:

  • 方法的用途
  • 参数说明
  • 可能的副作用

建议添加如下文档:

+ /**
+  * 将指定的测试标记为已失效
+  * @param testIds 要标记为失效的测试ID数组。如果为undefined,则标记所有测试
+  */
  $markTestRetired(testIds: string[] | undefined): void {
packages/testing/src/common/testCollection.ts (2)

96-96: 新属性需要添加注释说明

supportsContinuousRun 属性的添加符合预期,但建议添加JSDoc注释来说明该属性的用途和预期行为。

建议添加如下注释:

+  /** 指示测试运行配置是否支持持续运行模式 */
   supportsContinuousRun: boolean;

160-160: 错误消息上下文属性需要文档说明

contextValue 属性的添加增强了错误消息的上下文信息能力,建议添加注释说明其用途。

建议添加如下注释:

+  /** 提供额外的错误消息上下文信息,用于更详细的错误处理 */
   contextValue: string | undefined;
packages/utils/src/event.ts (1)

421-425: 考虑在evaluate方法中添加错误处理

ChainableSynthesis类的evaluate方法中,如果steps数组中的某个步骤抛出异常,可能会导致整个链条中断。建议在循环中添加错误处理,以确保链式调用的可靠性。

可以在循环中添加try...catch块:

for (const step of this.steps) {
+ try {
    value = step(value);
+ } catch (error) {
+   // 处理错误,例如记录日志或继续下一个步骤
+   console.error('Error in ChainableSynthesis step:', error);
+   continue;
+ }
  if (value === HaltChainable) {
    break;
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1d04d80 and b95e204.

📒 Files selected for processing (8)
  • packages/extension/src/browser/vscode/api/main.thread.tests.ts (1 hunks)
  • packages/extension/src/common/vscode/converter.ts (2 hunks)
  • packages/extension/src/common/vscode/ext-types.ts (1 hunks)
  • packages/extension/src/common/vscode/tests.ts (1 hunks)
  • packages/extension/src/hosted/api/vscode/ext.host.tests.ts (12 hunks)
  • packages/testing/src/common/testCollection.ts (2 hunks)
  • packages/types/vscode/typings/vscode.tests.d.ts (5 hunks)
  • packages/utils/src/event.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/extension/src/common/vscode/ext-types.ts
🧰 Additional context used
🪛 Biome
packages/extension/src/hosted/api/vscode/ext.host.tests.ts

[error] 288-288: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)

🔇 Additional comments (14)
packages/extension/src/browser/vscode/api/main.thread.tests.ts (1)

213-215: 验证方法调用的影响范围

需要确认此方法的实现对其他测试相关功能的影响。

packages/extension/src/common/vscode/converter.ts (2)

1628-1628: 新增的 contextValue 属性实现正确

在 TestMessage.from() 方法中正确添加了 contextValue 属性的转换。


1639-1639: 新增的 contextValue 属性实现正确

在 TestMessage.to() 方法中正确添加了 contextValue 属性的转换,保持了与 from() 方法的对称性。

packages/extension/src/hosted/api/vscode/ext.host.tests.ts (7)

73-73: 继承 Disposable 并调用 super()

ExtHostTestsImpl 类现在继承自 Disposable,并在构造函数中正确调用了 super(),确保了父类的初始化。

Also applies to: 88-88


241-248: 更新 createRunProfile 方法签名

createRunProfile 方法新增了可选参数 supportsContinuousRun,扩展了方法的功能,设计合理。


284-291: 改进 invalidateTestResults 方法的实现

新增了 invalidateTestResults 方法,用于标记测试结果失效,实现了更精细的控制。

🧰 Tools
🪛 Biome

[error] 288-288: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


955-966: 新增 updateProfile 辅助函数

引入了 updateProfile 函数,用于统一更新测试配置,增强了代码的可维护性。


987-994: 添加 supportsContinuousRun 的访问器

TestRunProfileImpl 类增加了 supportsContinuousRun 的 getter 和 setter,符合扩展需求。


1040-1045: 添加 onDidChangeDefault 事件

新增了 onDidChangeDefault 事件,用于监听默认配置的变化,增强了扩展性的支持。


1083-1084: 请验证 supportsContinuousRun 属性在主线程中的实现

注释指出主线程未实现 supportsContinuousRun。为了确保功能完整性,请确认主线程是否正确处理了该属性。

您可以运行以下脚本来检查主线程中是否实现了 supportsContinuousRun

packages/types/vscode/typings/vscode.tests.d.ts (4)

81-86: supportsContinuousRun 属性添加正确

此属性的添加符合预期,文档注释与代码一致,并明确默认值为 false


105-109: runHandler 文档更新完善

supportsContinuousRunTestRunRequest.continuous 的说明清晰,指导开发者如何在连续运行测试时处理源码变化。


303-307: TestRunRequest 中添加 continuous 属性

属性添加正确,文档清晰地说明了属性的用途及适用条件。


571-600: TestMessage 中添加 contextValue 属性

新增的 contextValue 属性使测试消息支持上下文相关的操作,文档提供了详细的示例和使用说明,便于开发者理解和应用。

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 5.60748% with 101 lines in your changes missing coverage. Please review.

Project coverage is 54.12%. Comparing base (1d04d80) to head (b95e204).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../extension/src/hosted/api/vscode/ext.host.tests.ts 6.66% 44 Missing and 12 partials ⚠️
packages/utils/src/event.ts 4.54% 36 Missing and 6 partials ⚠️
...ension/src/browser/vscode/api/main.thread.tests.ts 0.00% 2 Missing ⚠️
packages/extension/src/common/vscode/converter.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4167      +/-   ##
==========================================
- Coverage   54.16%   54.12%   -0.05%     
==========================================
  Files        1598     1598              
  Lines       97631    97721      +90     
  Branches    19979    19999      +20     
==========================================
+ Hits        52885    52887       +2     
- Misses      37167    37238      +71     
- Partials     7579     7596      +17     
Flag Coverage Δ
jsdom 49.68% <5.60%> (-0.05%) ⬇️
node 15.58% <1.86%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Ricbet Ricbet merged commit bb5e972 into main Nov 14, 2024
13 checks passed
@Ricbet Ricbet deleted the feat/implement-test-api branch November 14, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 feature feature required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants