已开启
[Bug]: std.unittest report file names don't follow the name@org convention for packages with organization #846
Anisimov Konstantin创建于  9月2日
Anisimov Konstantin仓颉Developer
9月2日 创建

感谢对仓颉社区的支持与关注,欢迎反馈缺陷。 | Thanks for your support and attention to the community. We welcome feedback on any issues.

发生了什么问题? | Describe the issue that occurred.

For a package with an organization set in cjpm.toml (e.g. organization = "huawei", name = "test"), all artifacts produced by cjpm use the filesystem-safe name@org form (target/release/test@huawei/, libtest@huawei.a, test executables test@huawei, .outlog/.errlog files).

However, files produced by std.unittest reports derive their names from the raw package group name, which contains org:::

  • XML per-package reports: test-huawei::test.sub.xml (before commit 11e8ee86) / test-huawei__test.sub.xml (after it, : → _)
  • per-suite XML/CSV reports via reportFileName
  • bench baselines benchmarks/<group> (text_report.cj)
  • bench HTML per-case directories via TestCaseId.fqName() (id.cj)

This is inconsistent with the rest of the toolchain: no other artifact uses the huawei__test form.

期望行为是什么? | What is the expected behavior?

Report file names should use the same name@org convention as every other cjpm artifact, e.g. test-test.sub@huawei.xml for package huawei::test.sub. This matches how cjpm names the module directory (target/release/test@huawei/), libraries (libtest.sub@huawei.a), test executables (test.sub@huawei) and logs. Neither organization names nor package name segments can contain @, so the path@org form stays unambiguous.

如何复现该缺陷 | How to reproduce the bug

  1. Create a project with organization = "huawei" and name = "test" plus a subpackage test.sub, each with a @Test class.
  2. Run cjpm test --report-format=xml-per-package.
  3. Observe target/release/reports/tests/ contains test-huawei__test.xml / test-huawei__test.sub.xml instead of test-test@huawei.xml / test-test.sub@huawei.xml.

其他补充信息 | Additional information

Fix: apply org-name swapping (org::name → name@org, same semantics as cjpm's swapOrgName) in String.toSafeFileName() in stdlib/libs/std/unittest/report_unittest_xml.cj. This is the single choke point through which all four report file name flows go. Related HLT test: cangjie_test HLT/Tools/cjpm/cjpm_build/organization/test_002.

https://gitcode.com/Cangjie/cangjie_tools/pull/1265

cjc版本信息 | cjc version information

Current main (cangjie_runtime 8ec835cf+)

分支版本信息 | Branch version information

likedislike
AAnisimov Konstantin仓颉Developer
9月2日 关联了pull request:fix(unittest): use name@org convention in report file names
AAnisimov Konstantin仓颉Developer
9月2日 关联了pull request:test: add HLT case for cjpm test reports with organization
Anisimov Konstantin仓颉Developer
9月3日 评论:

Related: cangjie_tools#1228 passed swapOrgName-converted package names to std.unittest; it is reverted by Cangjie/cangjie_tools#1265. After the revert, report file name sanitization lives entirely in std.unittest (this issue's fix, PR #1730), while display names keep the org::name form.

likedislike
AAnisimov Konstantin仓颉Developer
9月3日 修改了issue 的描述
Sergey KovaltsovSergey Kovaltsov仓颉Developer
9月3日 关联了pull request:fix: cjpm bench report file name problem on windows
Sergey KovaltsovSergey Kovaltsov仓颉Developer
9月3日 删除了关联的pull request:fix: cjpm bench report file name problem on windows
Sergey KovaltsovSergey Kovaltsov仓颉Developer
9月3日 关联了pull request:fix: cjpm bench report file name problem on windows
Sergey KovaltsovSergey Kovaltsov仓颉Developer
9月3日 删除了关联的pull request:fix: cjpm bench report file name problem on windows
Sergey KovaltsovSergey Kovaltsov仓颉Developer
9月3日 关联了pull request:fix: cjpm bench report file name problem on windows