-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add a test for placeholder escaping #9
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,17 @@ setup() { | |
[[ "$output" = *"https://manned.org/7z"* ]] | ||
} | ||
|
||
# Source: https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md#page-structure | ||
# bats test_tags=required | ||
@test "REQUIRED: supports escaping the placeholder syntax" { | ||
run $PATH_TO_TLDR_CLIENT docker inspect | ||
[[ $status -eq 0 ]] | ||
[[ "$output" = *"{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}"* ]] | ||
run $PATH_TO_TLDR_CLIENT --platform windows mount | ||
[[ $status -eq 0 ]] | ||
[[ "$output" = *"\\computer_name\share_name"* ]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test and the associated specifications are odd to me. If we are using CommonMark, then The page should have With the specifications as they are written, I don't think the specifications make sense. This does look to me like it tests what the specifications intended, though. |
||
} | ||
|
||
# Source: https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md#arguments | ||
# bats test_tags=optional | ||
@test "OPTIONAL: supports --list argument to list all pages" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that suggestion adds much value, meanwhile it does add potential complexity with handling different styles, colors, or ANSI codes between arguments in different clients.
I think we should stick to the original proposal.
Reference: #9 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe split this into the past version and this suggestion, making the latter optional, with NO_COLOR set to true? I do think that the backslashes can confuse clients.Well, the other test already tests the placeholder between the escaped curly brackets, right? So what's the point here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which test are you referring to there?
I don't think we're testing escaped curly braces yet. It was a relatively recent addition to the spec compared to when I wrote these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was talking about the other line of this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two tests are different.
\{\{arg\}\}
→{{arg}}
\\arg
→\\arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'm not saying they are equivalent. But the double backslash test, want it or not, also tests the rendering of the placeholders, so it should theoretically suffer from the same problems you mentioned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you're trying to say. These are both handling entirely different scenarios. It's possible to craft input that could pass or fail both, but this is about how escapes are handled, which any clients could handle one escape correctly but not the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Microsoft documentation:
The original Markdown is:
If I'm getting it right, it should be rendered as:
Yeah, they are different, because the mount page doesn't test escaped placeholders, but it does test text between the placeholders, so it could theorically suffer from the problems you mentioned such as ANSI codes.
I hope you understand me now 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I'm following now! Yeah, the second test is actually written wrong then in that case.
That really should say placeholder syntax, escaped curly braces are fine. Clients are free to render it as
\\{{computer_name}}\{{share_name}}
or\\computer_name\share_name
, usually if a client does the latter they use colors/styles to signify the args.It should only check what it wants to test, so the
\\
part, or we could check for multiple tokens like\\
andcomputer_name
, but the assertions should not include the{{
.