Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[correctness][missing-coverage][sort] Mixed files and repeated stdin lack a regression test

已关闭 适合新手
#635 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
83/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
testing

调研方向

阅读 builtins/sort/sort_test.go:380-415 中现有的输入源测试,以及 tests/scenarios/cmd/sort/basic/ 下的场景测试。使用所述文件和重复的 - 操作数,添加建议的 tests/scenarios/cmd/sort/basic/mixed_files_repeated_stdin.yaml 用例。运行 go test ./tests -run '^TestShellScenarios$/cmd/sort';用例通过并确认预期的排序输出,其中未终止的记录彼此分开,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Generated by the rshell behavior correctness scanner.

  • Contract: BEH-004
  • Classification: missing-coverage
  • Impact: low
  • Target: sort
  • Scanned commit: 514d1cb8188fda6b1accca5955dfab3b0e8aa34a

Existing tests cover stdin, one '-' operand, multiple files, and unterminated records separately. They do not meaningfully cover their interaction: a file followed by repeated '-' operands must consume stdin once and preserve separate record boundaries when both inputs lack final newlines. The tested behavior matched GNU; no defect was demonstrated.

Contract sources
  • docs/BEHAVIOR_CONTRACTS.md:45-49: Standard input, '-', file operands, and multiple inputs must interact like the reference command.
  • sort --help: Command help promises sorted concatenation and stdin reading for '-' operands.
  • builtins/sort/sort_test.go:380-415: Existing input-source tests exercise these cases separately.
Implementation references
  • builtins/sort/sort.go:372-387: Operands are read individually and their records appended before sorting.
  • builtins/sort/sort.go:427-446: Each '-' operand wraps the same stdin reader.

Fixture setup

Create data.txt with exact bytes "b\nd" and stdin.txt with exact bytes "c\na" in a fresh temporary directory. Neither file ends with a newline.

Reproducer

sort data.txt - - < stdin.txt

Commands used:

  • GOENV_VERSION=1.26.3 timeout 300s go build -o /tmp/zz_correctness_scan_rshell ./cmd/rshell
  • In a fresh fixture directory: /tmp/zz_correctness_scan_rshell --allowed-commands rshell:sort --allowed-paths "$PWD" -c 'sort data.txt - - < stdin.txt'
  • In an equivalent fresh fixture directory: LC_ALL=C bash --noprofile --norc -c 'sort data.txt - - < stdin.txt'
  • GOENV_VERSION=1.26.3 timeout 300s go test ./tests -run '^TestShellScenarios$/cmd/sort' -count=2 -v

Verification

  • Reproduction runs: 4
  • Reference: GNU sort 9.4 matched the expected result twice from fresh fixtures. Both CLI executions and both temporary scenario executions passed.
  • Temporary test: tests/scenarios/cmd/sort/zz_correctness_scan_cases/zz_correctness_scan_mixed_inputs.yaml (removed)
  • Suggested regression-test location: tests/scenarios/cmd/sort/basic/mixed_files_repeated_stdin.yaml

Fingerprint: f38bb9f21b7f40b8e04041b1bb63daaa0387a24dcc0256fd43134ff98b63622f

主要语言
Go
星标
31
派生
3
平均合并
1 天 13 小时
30 天内合并 PR
23

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DataDog/rshell 的其他 Issue

查看 DataDog/rshell 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。