Repository navigation
Implement GNU R (read one line from file) command - #544
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #544 +/- ##
==========================================
+ Coverage 82.84% 83.88% +1.04%
==========================================
Files 13 14 +1
Lines 6865 6974 +109
Branches 401 405 +4
==========================================
+ Hits 5687 5850 +163
+ Misses 1175 1121 -54
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by 3.17%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | access_log_translit |
1 s | 1 s | +3.17% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Jorge-Polanco-Roque:feat/R-read-one-line (48c1a03) with main (c46dd6d)
|
please add tests to improve the coverage. some tests are missing to reach important cases |
|
Thanks — added tests to cover the missing cases: unit tests for |
|
Added integration tests for R covering the cases that were missing: address-gated R that only advances when it runs, independent cursors across different files, and a final line without a trailing newline. While writing them I also caught and fixed a real divergence from GNU: multiple |
|
GNU sed testsuite comparison: |
1 similar comment
|
GNU sed testsuite comparison: |
|
Gentle ping — this has been open ~10 days. I added the integration tests you asked for (the missing R cases: multiple files, address ranges, and end-of-input handling), and the GNU sed testsuite comparison is clean. Happy to rebase or adjust if anything else is needed. Thanks! |
| Ok(CommandHandling::Continue) | ||
| } | ||
|
|
||
| // Handles R |
There was a problem hiding this comment.
does it make a test of the GNU testsuite pass? if so, please mention it in the commit message
| return compilation_error(lines, line, ERR_SANDBOX); | ||
| } | ||
| let path = read_file_path(lines, line)?; | ||
| // GNU sed shares a single cursor per file path among all `R` commands |
There was a problem hiding this comment.
the why is already documented on named_readers in command.rs, please keep only one :)
| n_addr: 2, | ||
| handler: compile_empty_command, | ||
| }), | ||
| 'R' if !posix => Ok(CommandSpec { |
There was a problem hiding this comment.
please also add R to the list of GNU extensions in README.md (next to W)
| @@ -0,0 +1,101 @@ | |||
| // An abstraction for input files read one line at a time by the `R` command | |||
There was a problem hiding this comment.
please squash the 5 commits into one, with the usual sed: prefix
The R command reads one line at a time from a named file. All R commands naming the same file share a single cursor so they read successive lines, matching GNU sed. Rejected under --sandbox like the other file commands. Includes unit and integration tests. Makes the GNU sed testsuite `cmd-R` test pass.
4eb793d to
48c1a03
Compare
|
Thanks @sylvestre! Addressed all four:
Rebased on main while at it; fmt/tests green. |
|
GNU sed testsuite comparison: |
|
Thanks for your PR |
Closes #394.
Implements the GNU
Rcommand, the line-oriented counterpart tor(mirroring howWrelates tow, added in #531).R filenamequeues the next successive line offilenameto be inserted into the output stream at the end of the current cycle. Each cycle consumes one more line; once the file is exhausted no line is queued.Behavior
NamedReader, analogous toNamedWriter).--sandbox, exactly liker/w/W.Tests
NamedReader(successive lines, final line without newline, missing file).--posixrejection,--sandboxrejection.cargo fmt --all -- --check,cargo test --all, andcargo clippy --all-targets --workspace -psed -- -D warningsall pass locally.