-
Notifications
You must be signed in to change notification settings - Fork 71
Replace system lambda #601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
This is a code example in tests of replacing the "system-lambda" library specific to our needs of checking program output to the terminal/console. The `ContextForTerminal` test class is reusable, but unclear we should provide this even as copy/paste for folks browsing our test code. Along the way: - Find that the PMD rule on "CommentSize" is awful. We should suppress it by default. When you write large comments (for example, in Javadoc) your build should not break. - Suppressions of PMD checks, or rewriting for Checkstyle. This is a smell that either code is wonky, or this is too low-level to make a good example. - Reminder that the old Java APIs only dealt with UTF issues in a half-ass fashion. A reason to use libraries that dealt with this for you. - Reminder that terminal/console out/err is not thread-safe, and no library can fix that.
This is a code example in tests of replacing the "system-lambda" library specific to our needs of checking program output to the terminal/console. The `ContextForTerminal` test class is reusable, but unclear we should provide this even as copy/paste for folks browsing our test code. Along the way: - Find that the PMD rule on "CommentSize" is awful. We should suppress it by default. When you write large comments (for example, in Javadoc) your build should not break. - Suppressions of PMD checks, or rewriting for Checkstyle. This is a smell that either code is wonky, or this is too low-level to make a good example. - Reminder that the old Java APIs only dealt with UTF issues in a half-ass fashion. A reason to use libraries that dealt with this for you. - Reminder that terminal/console out/err is not thread-safe, and no library can fix that.
IntelliJ is happier with the line breaks in this commit. Also, update the javadocs with better links and wording.
5 tasks
Making things public helps with Javadoc generation.
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.
Howdy!
I'm looking to replace the
system-lambda
test library with small, local, bespoke code. This library specializes in nicer Java code for messing withSystem
globals in the JVM such as STDOUT/STDERR, et al.This addresses #483. Currently the build on this branch is green.
To consider before approving:
Should the project provide example replacement code rather than continuing to use a 3rd-party library?
Use a code style that:
system-lambda
with improved naming:captureTerminal
(this code) vstapSystemOutNormalized
(system-lambda library) (Expected discussion on naming for "captureTerminal" -- all TWers love noodling on naming 😀)TerminalContext
and only the static method ofcaptureTerminal
should be visible. Do not look behind the curtain: we mess with JDK global statics)@Bukharovsi GitHub auto-suggested you to review.
:D
We won't depend on your feedback to decide if to merge this PR--there is a lot on your plate right now--, but would love your thoughts!I really like the https://github.com/stefanbirkner/system-lambda library, and use it in some side projects where I need to test complicated things about the terminal or environment. For the example code in this project, it feels like using a cannon to hit an orange.
Footnotes
system-lambda
does is to wrap a continuation (the call to test). Describing it this way is unhelpful for most programmers. We are wrapping calls (Application.main
) that access monads for STDOUT and STDERR (such a scholarly description meaning "side effect"), and capturing the data sent to them so we can test these interactions.Yep, this is what testing "Hello, world" looks like! No way I want to talk about it this way to the general programmer audience.