test: add new startNewREPLSever testing utility#59964
Closed
dario-piotrowicz wants to merge 1 commit intonodejs:mainfrom
Closed
test: add new startNewREPLSever testing utility#59964dario-piotrowicz wants to merge 1 commit intonodejs:mainfrom
startNewREPLSever testing utility#59964dario-piotrowicz wants to merge 1 commit intonodejs:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59964 +/- ##
==========================================
- Coverage 88.41% 88.41% -0.01%
==========================================
Files 703 703
Lines 207398 207419 +21
Branches 39987 39997 +10
==========================================
+ Hits 183374 183390 +16
- Misses 15995 15998 +3
- Partials 8029 8031 +2 🚀 New features to boost your workflow:
|
H4ad
approved these changes
Sep 23, 2025
Collaborator
addaleax
pushed a commit
that referenced
this pull request
Sep 30, 2025
PR-URL: #59964 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Member
|
Landed in 9ac571d |
targos
pushed a commit
that referenced
this pull request
Oct 6, 2025
PR-URL: #59964 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a new testing utility called
startNewREPLSeverwhich simply starts a new repl server that can be used for testing.The reasoning for proposing this change are to reduce unnecessary code repetition (notice that the PR is net removing more than 450 lines of code1) and to also provide some consistency on how repl server are tested.
Currently in tests when a new repl server gets started some input/output streams need to be passed to it, sometimes they are implemented via
new stream.PassThrough(), some other times (more commonly) vianew ArrayStream(), sometimes a single stream is passed both as the input and output, sometimes different streams are passed instead.In most cases (as far as I can tell) there isn't a specific reason as to why an implementation has been chosen or not.
startNewREPLSeverremoves this variation by adopting what looked to me like the most commonly used implementation aspects.Another nice thing is that
startNewREPLSeverhelps with variable name consistency. Currently when a test repl server is started it is stored in a variable which name can ber,replServer,serverortestMe. Input streams can beinput,putInorinputStream. Output streams can beoutput,putInoroutputStream. (I am likely forgetting some variation too).startNewREPLSeverconsistently refers to these values respectively asreplServer,inputandoutput.Please note that my PR is not replacing all repl server starts in tests with
startNewREPLSever, mainly because sometimes that is not helpful (for example when testing the repl constructor default values) or because it would require some involved refactoring (and I think that this PR is pretty big as it is 😅, if this lands I can also see as a followup ifstartNewREPLSevercould, be used in a few other tests as well)Footnotes
The output accumulation logic is re-implemented multiple times as well as the error domain on error handler logic. ↩