Closed
[Bug-Report|缺陷反馈]: 修复 build.sh help 参数组合校验异常 #710
RobellAdd on  May 20Closed at  May 29
Robell
May 20 Create

### Describe the current behavior / 问题描述 (Mandatory / 必填)
代码质量扫描发现 build.sh 的帮助/参数预检存在 3 个功能质量问题:

  1. check_help_combinations 中循环使用了 ${arg[@]},而不是前面定义的 ${args[@]},导致 help 场景下的参数组合校验没有遍历真实入参,非法组合容易漏报。
  2. --cov 组合判断逻辑反了:当前代码在 --cov 与 -t/--test 或测试分片一起使用时返回错误,但 --cov 本应只能在测试模式下使用。
  3. 重复参数检测没有把 -j8、-j16 这类短参数归一化为同一个 -j,因此同一次调用中可以传入多个线程数,最终值取决于解析顺序,行为不清晰。

Environment / 环境信息 (Mandatory / 必填)

本地静态分析与脚本 help 路径验证;Windows 工作区 checkout + bash。由于 Windows checkout 下 build.sh 为 CRLF,测试时使用 LF 临时副本验证脚本逻辑,不修改仓库文件。

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

使用 LF 版本的 build.sh 运行:

bash build.sh -h --cov
bash build.sh -h -t --cov
bash build.sh -h -t --adv_test
bash build.sh -h -j8 -j16

修复前预期表现会被破坏:--cov 单独使用未被拦截,-t --cov 被误拦截,-t --adv_test 因循环变量错误未被 help 组合校验识别,重复 -j 带值形式未被识别为重复参数。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  • help 组合校验应遍历真实入参。
  • --cov 单独使用应失败;-t --cov 应进入测试帮助输出并成功。
  • -t 与测试分片互斥,应在 help 预检阶段失败。
  • 多个 -jN 线程参数应被识别为重复输入并失败。

修复后验证命令与结果:

bash -n <LF临时副本>                                                    # 通过,EXIT:0
bash <LF临时副本> -h --cov                                             # 正确报错,EXIT:1
bash <LF临时副本> -h -t --cov                                          # 正确输出 Test Options,EXIT:0
bash <LF临时副本> -h -t --adv_test                                     # 正确报互斥错误,EXIT:1
bash <LF临时副本> -h -j8 -j16                                          # 正确报重复 -j,EXIT:1
git diff --check                                                       # 通过,无 whitespace error

Special notes for this issue/备注 (Optional / 选填)

该问题包含代码逻辑修复,PR 不仅修改文档。

likedislike
RRobell
May 20 Added label: bug-report
RRobell
May 20 Associated pull request
CchenyiyuanCollaborators
May 20 Assign pengcheng1024 as responsible person
pengcheng1024Collaborators
May 21 Comments:

感谢您的反馈,我们将组织对应commiter对修复进行检视

likedislike
pengcheng1024Collaborators
May 22 Comments:

关联修复PR已合入,烦请确认

likedislike
Ppengcheng1024Collaborators
May 29 changed custom state from 进行中 to 已完成
Ppengcheng1024Collaborators
May 29 Close issue
CANN-robotCANN-robotCollaborators
May 29 Added label: Accepted
CANN-robotCANN-robotCollaborators
May 29 Added label: resolved