Skip to content

test: Improve cs parse #2273

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

Merged
merged 1 commit into from
Aug 16, 2025
Merged

test: Improve cs parse #2273

merged 1 commit into from
Aug 16, 2025

Conversation

unknowIfGuestInDream
Copy link
Owner

@unknowIfGuestInDream unknowIfGuestInDream commented Aug 16, 2025

CLose #2195

Fixes #

Proposed Changes

  1. ...
  2. ...
  3. ...

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as either enhancement, bug, documentation or dependencies
  • Verify design and implementation

Summary by Sourcery

Adjust CSCcrlParseTest expectations by removing obsolete options and adding updated linker options to reflect recent parser support changes

Enhancements:

  • Update CSCcrlParseTest to align expected option names with current parser behavior
  • Remove deprecated CS options (e.g., stack protector, Goptimize, NoDebugInfo) from test expectations
  • Add and reorder Linker options (e.g., LinkOptionLibrary) in the expected list

Summary by CodeRabbit

  • 测试
    • 在 CI 环境条件禁用相关解析用例,提升稳定性。
    • 更新测试使用的 CCRL 标签清单,移除过时选项并调整分组与顺序,使之与最新配置对齐,减少噪声与误报。
  • 杂务
    • 无用户可见变更;生产功能与公开接口不受影响。

CLose #2195

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>
Copy link

Thank you for following naming conventions! 😻

Copy link

sourcery-ai bot commented Aug 16, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The pull request refines the CSC/Crl parsing test by updating the static initialization list of expected option identifiers: obsolete entries are removed, new ones are added, and ordering is adjusted to align with the current parser output.

File-Level Changes

Change Details Files
Update code generation option identifiers in test initialization
  • Removed COptionStackProtector-0, COptionStackProtectorValue-0, COptionControlFlowIntegrity-0, COptionInsertNopWithLabel-0
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java
Adjust linker input/output option identifiers
  • Added LinkOptionLibrary-0
  • Reordered LinkOptionBinary, LinkOptionEntry, LinkOptionEntryPoint
  • Removed HexOptionSpace-0 and HexOptionSpaceValue-0
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java
Remove outdated optimization and DSPAsm options
  • Removed COptionGoptimize-0
  • Removed DSPAsmOptionNoDebugInfo-0
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java

Assessment against linked issues

Issue Objective Addressed Explanation
#2195 Extract macro definitions from mtpj and generate corresponding build command options (e.g., -define=DEBUG -define=USE_UART). The diff only modifies a test file and does not show any logic for extracting macro definitions or generating build command options from mtpj files.
#2195 Extract header file paths from mtpj and generate corresponding build command options (e.g., -include=inc -include=drivers). No code in the diff implements extraction of header file paths or generation of -include options from mtpj files.
#2195 Extract compiler type/CPU architecture, optimization level, and output format from mtpj and generate corresponding build command options (e.g., -cpu=rl78, -O2, output format). The diff does not show any implementation for extracting compiler type, optimization level, or output format from mtpj files, nor does it generate related build command options.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

quine-bot bot commented Aug 16, 2025

👋 Figuring out if a PR is useful is hard, hopefully this will help.

  • @unknowIfGuestInDream has been on GitHub since 2019 and in that time has had 1268 public PRs merged
  • Don't you recognize them? They've been here before 🎉
  • Here's a good example of their work: javafxTool (Javafx scaffolding, built on JDK17 + JavaFX 21 + controlsfx 11 + Maven)
  • From looking at their profile, they seem to be good with Java and HTML.

Their most recently public accepted PR is: #2264

Copy link

vercel bot commented Aug 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
javafx-tool Ready Ready Preview Comment Aug 16, 2025 10:26am

Copy link

coderabbitai bot commented Aug 16, 2025

Walkthrough

在测试类 CSCcrlParseTest 中更新导入与注解,使 parseXpath 测试在 CI 环境中被禁用;并调整初始化时使用的 CCRL 标签到列表,移除/重排若干选项。变更仅限测试代码,无对外 API 变更。

Changes

Cohort / File(s) Summary
JUnit 条件禁用与导入调整
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java
添加 DisabledIfSystemProperty 导入并移除重复导入;为 parseXpath 添加 @DisabledIfSystemProperty(named="workEnv", matches="ci")
测试数据:CCRL 标签到更新
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java
更新 tagNames 初始化:移除 COptionStackProtector-0、COptionStackProtectorValue-0、COptionControlFlowIntegrity-0、COptionInsertNopWithLabel-0、COptionGoptimize-0;调整/合并 Link/Hex 相关项;移除 DSPAsmOptionNoDebugInfo-0;重排若干项

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant JUnit
  participant TestClass as CSCcrlParseTest
  CI->>JUnit: 运行测试 (workEnv=ci)
  JUnit->>TestClass: 发现 parseXpath
  TestClass-->>JUnit: @DisabledIfSystemProperty(workEnv=ci)
  JUnit-->>CI: 跳过 parseXpath
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
从 mtpj 提取宏定义并生成 -define 参数(#2195 仅修改测试与标签到,不涉及提取或生成命令行逻辑
从 mtpj 提取头文件路径并生成 -include 参数(#2195 未见相关解析与输出实现
解析编译器/CPU 架构并生成 -cpu 参数(#2195 无对应功能代码变更
解析优化等级并生成 -O 参数(#2195 未实现从 mtpj 到命令行的映射
解析链接器输出格式(如 hex)(#2195 未见链接输出格式生成逻辑

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
为 parseXpath 添加条件禁用注解(core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java) 与从 mtpj 提取并生成构建命令无直接关联
调整/精简 CCRL 标签到列表(core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java) 更改测试数据集合,未实现任何与命令生成相关的功能

Poem

我是码田里的小兔子,耳朵竖成天线📡
今天标签到瘦身,测试在云端睡个懒觉🛌
CI轻轻跳过,不再踢到石头🐾
等到命令生成那天,再来一段快乐的蹦跳🎶
咔哒咔哒,胡萝卜也点头🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch parsecc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

what-the-diff bot commented Aug 16, 2025

PR Summary

  • Implemented Conditional Test Execution
    Imported DisabledIfSystemProperty from JUnit 5. This new feature will allow the execution of our tests to be controlled based on specific system properties. This will help the development team manage testing conditions more effectively.

  • Removal of redundant import
    Cleared up some clutter in our code by eliminating a duplicate import of DisabledIfSystemProperty. This action ensures better readability and easier code maintenance.

  • Updated Array Elements of code generation and input control options

    • Removed an unnecessary element "COptionStackProtector-0" from the code generation options. This may improve the efficiency of code generation.
    • Introduced a new element "LinkOptionLibrary-0" to the input control options. This addition can potentially enhance the input control mechanism.
    • Cleaned up the code by getting rid of an extraneous element from the code generation array. This results in tidier and more condensed code, promoting ease of understanding.
  • Maintained Existing Functionality and Test Cases
    No changes were made to the current application functions and existing test cases. This means the solutions we offer and current testing procedures will operate as they always have. Thus, no direct changes to user experience or testing outputs.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

Copy link
Contributor

github-actions bot commented Aug 16, 2025

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

GitHub
Explore the GitHub Discussions forum for JetBrains Qodana. Discuss code, ask questions & collaborate with the developer community.

Copy link

@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: 0

🔭 Outside diff range comments (1)
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java (1)

83-86: 修复 tag 名中的尾部空格,避免 XPath/DOM 匹配失败

"COptionOsameCode-0 " 末尾多了一个空格,将导致 //COptionOsameCode-0 无法匹配到目标节点。

建议修复如下:

-            "COptionOaliasAnsi-0", "COptionOsameCode-0 ", "COptionObranchChaining-0", "COptionOalign-0", "COptionGoptimize-0",
+            "COptionOaliasAnsi-0", "COptionOsameCode-0", "COptionObranchChaining-0", "COptionOalign-0", "COptionGoptimize-0",
🧹 Nitpick comments (2)
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java (2)

123-126: 用 Collectors.joining 简化 XPath 表达式拼接

功能等价,代码更简洁,可读性更好。

-        String xpathExpr = Arrays.stream(tagNames)
-            .map(tag -> "//" + tag)
-            .reduce((a, b) -> a + " | " + b)
-            .orElse("");
+        String xpathExpr = Arrays.stream(tagNames)
+            .map(tag -> "//" + tag)
+            .collect(java.util.stream.Collectors.joining(" | "));

如果偏好顶部 import,也可补充:

import java.util.stream.Collectors;

并将 java.util.stream.Collectors 简化为 Collectors


119-163: 测试仅打印未断言,建议补充最小断言提升有效性

当前两个测试主要做解析与打印,失败仅在抛异常时触发。建议至少断言“应能解析到若干已知标签”,避免用例形同“烟雾测试”。

例如在 parseDoc 末尾增加“至少解析到一个非空值”的断言(示例):

long found = result.values().stream().filter(v -> v != null && !v.isEmpty()).count();
org.junit.jupiter.api.Assertions.assertTrue(found > 0, "应当至少解析到 1 个已知标签值");

如果你愿意,我可以基于 util/ccrl.mtpj 的实际内容起草更有针对性的断言(如 CPU=RL78、是否包含若干典型 include/library 定义等),并补一组“标签→命令行”映射的测试骨架以呼应 #2195

Also applies to: 165-196

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2bdc2a5 and 320e24b.

📒 Files selected for processing (1)
  • core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: build (17, ubuntu-latest, false)
  • GitHub Check: build (21, windows-latest, false)
  • GitHub Check: build (21, macos-latest, false)
  • GitHub Check: build (21, ubuntu-latest, false)
  • GitHub Check: build (17, macos-latest, false)
  • GitHub Check: build (17, windows-latest, false)
  • GitHub Check: qodana
  • GitHub Check: StepSecurity Harden-Runner
  • GitHub Check: Summary
🔇 Additional comments (5)
core/src/test/java/com/tlcsdm/core/util/CSCcrlParseTest.java (5)

33-33: 在 CI 中按系统属性禁用用例的导入已就绪 — LGTM

已引入 DisabledIfSystemProperty,与下方方法级注解配合可避免 CI 假失败。

请确保在 CI 流水线中传入 -DworkEnv=ci,例如:

  • Maven: mvn -B -DworkEnv=ci test
  • 或在 Surefire 配置中加上 <systemPropertyVariables><workEnv>ci</workEnv></systemPropertyVariables>

99-99: 输出控制标签列表调整 — LGTM

HexOptionForm-0 与若干 LinkOption* 的组合在“输出控制”分组内更清晰。


103-104: 链接阶段优化项分组 — LGTM

LinkOptionOptimize* 相关项集中于“Optimization”块,定位与维护更直观。


115-115: DSPAsm 标签精简 — LGTM

保留 DSPAsmOptionLabel-0DSPAsmOptionMacroIdentifyExact-0 合理,未见问题。


95-97: 已验证新增/重排的 Link 控制标签均存在于 ccrl.mtpj

  • 在 core/src/test/resources/util/ccrl.mtpj 中,使用 rg 逐项检查,确认以下标签均已定义:
    • <LinkOptionDefine-0/>
    • <LinkOptionInput-0/>
    • <LinkOptionLibrary-0/>
    • <LinkOptionBinary-0/>
    • <LinkOptionEntry-0>…</LinkOptionEntry-0>
    • <LinkOptionEntryPoint-0>…</LinkOptionEntryPoint-0>
  • 不会出现“未找到”问题,无需进一步修改。

@unknowIfGuestInDream unknowIfGuestInDream merged commit 5d0cb82 into master Aug 16, 2025
41 of 42 checks passed
@unknowIfGuestInDream unknowIfGuestInDream deleted the parsecc branch August 16, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] CS+ mtpj 提取构建命令
1 participant