You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🟡 列宽计算逻辑与超长字段处理存在矛盾
第2.2节说“超长字段不截断、不填充,其后字段允许自然右移”,但格式化器又要求“操作码和操作数的最小宽度分别为8和15”。如果字段超长,后续字段自然右移,但后续字段本身可能也需要对齐到统一列?超长字段后,统一对齐列是否会失效?例如操作码超长到20,操作数列起始位置会随之后移,但后续行的操作数是否也应以该行起始位置为准?文档未说明是否所有行对同一字段使用同一最大宽度(经过裁剪),还是仅基于当前行自身的长度。建议指定列宽计算基于所有合法行的 max 值(经过 min 裁剪),而不是逐行独立。
🟡 Lack of timeout — subprocess.run() in run_cli() has no timeout argument. If the script hangs, the test suite will hang indefinitely.
Suggestion: Add a reasonable timeout, e.g. timeout=10.
🟡 Brittle hardcoded expected strings — Tests like test_cli_abi_register_names_changes_only_comment assert specific comment text ("# ra = sp + gp"). These are implementation details of the beautifier and may change.
Suggestion: Either document these as intentional public output, or match against a pattern (e.g. re.search(r'#\s+\w+')).
💭 Imprecise type hint — run_cli(*args: object) is too loose. Path objects are passed in practice, but object allows any type.
Suggestion: Use *args: str | Path and let str(arg) handle conversion.
💭 Redundant empty-string assertions — assert completed.stderr == "" is fine, but assert not completed.stderr is more idiomatic and avoids the subtle case where stderr is None (though unlikely with text=True).
Suggestion: Use assert not completed.stderr for brevity.
📁 tests/test_asm_beautifier_comments.py
🔴 Potential KeyError in test_all_parser_instructions_have_working_templates — Line 60: _SAMPLE_OPERANDS[role] crashes if INSTRUCTION_SPECS contains an operand role not in _SAMPLE_OPERANDS (e.g., "funct7").
Suggestion: Either verify all roles are covered, or use _SAMPLE_OPERANDS.get(role, "") with a fallback.
🟡 Fragile whitespace assertion — test_abi_aliases_only_change_generated_comment (line 109) asserts "lw x5, 8(x2)" in result. The exact number of spaces depends on beautify_asm alignment logic.
Suggestion: Assert on individual tokens (e.g., "x5" in result and "8(x2)" in result) or use a regex for flexible spacing.
🟡 Exact string equality in test_no_align_only_appends_comment_without_reformatting_code — Line 145: assert result == "add a0,a1,a2 # a0 = a1 + a2" (two spaces before #). This is brittle if the comment spacing logic changes.
Suggestion: Use assert result.endswith("# a0 = a1 + a2") and check that the code part is unchanged.
🟡 test_abi_aliases_do_not_change_non_register_roles (line 130) assumes li x1,x2 generates # ra = x2. This relies on the internal template for li; if li is later expanded or its template changes, the test breaks.
Suggestion: If li is a pseudo-instruction, either test it separately or mock _gen_comment for that opcode, or document the assumption.
💭 test_all_parser_instructions_have_working_templates only tests the minimum operand count for each instruction. Instructions with more operands (e.g., fence with more than min_operands) may have different templates or break.
Suggestion: Add a variant that uses the full operand list (e.g., len(spec.operand_roles)) to ensure templates work for all combinations.
💭 test_empty_opcode_has_no_template_comment (line 82) passes opcode=None to _gen_comment. This is good, but verify that the implementation actually handles None gracefully (e.g., by checking for opcode truthiness). If not, this test could mask a crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.