Skip to content
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

test(developer): check correct use of u16chr when second parameter could be null #11894

Conversation

markcsinclair
Copy link
Contributor

@markcsinclair markcsinclair commented Jul 1, 2024

Fix the use of u16chr() with *q==0 in u16tok() bug (and anywhere else it is similarly misused) - see issue #11814

Tests for u16chr() and u16tok() (both variants) are included in gtest-kmxu16-test.cpp

Partially fixes: #11814 (another PR is needed for the first bug)

Related-to: #11910

@keymanapp-test-bot skip

@markcsinclair markcsinclair marked this pull request as draft July 1, 2024 10:15
@markcsinclair markcsinclair self-assigned this Jul 1, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Jul 1, 2024

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

mcdurdin added a commit that referenced this pull request Jul 2, 2024
@mcdurdin
Copy link
Member

mcdurdin commented Jul 2, 2024

I independently encountered the u16tok bug. I have pushed my branch so you can compare: #11910.

@mcdurdin mcdurdin marked this pull request as ready for review July 5, 2024 08:10
@mcdurdin mcdurdin marked this pull request as draft July 5, 2024 08:11
@darcywong00 darcywong00 modified the milestones: A18S5, A18S6 Jul 5, 2024
…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
… and remove unncessary prefix from two cases
@darcywong00 darcywong00 modified the milestones: A18S6, A18S7 Jul 19, 2024
…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
@markcsinclair
Copy link
Contributor Author

Ready for review, although waiting for PR #11910 to be merged into master first.

…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
@markcsinclair
Copy link
Contributor Author

PR #11910 has been merged into master, and in turn into this PR, so it is ready to be reviewed.

Compared to PR #11910, this PR offers more extensive testing of u16chr() and the two variants of u16tok(), plus testing of two Compiler.cpp functions, ProcessEthnologueStore() and LineTokenType() which were (incorrectly) suspected of containing misuse of u16chr(). The testing on ProcessEthnologueStore() did identify a different bug (see #11955) however.

@markcsinclair markcsinclair marked this pull request as ready for review July 23, 2024 10:44
…e-of-u16chr-when-second-parameter-could-be-null
…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, two small items -- one of which should probably be treated as a latent (if not currently visible) bug in the compiler?

Noting that the title and description suggest changes to the compiler code, not just the tests -- is there something missing?

Comment on lines 644 to 648
// comment without following space
u16cpy(str, u"c");
p = str;
EXPECT_EQ(T_UNKNOWN, LineTokenType(&p));
EXPECT_EQ(0, p - str);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I would have thought that this should be treated as a comment. It turns out that ReadLine() strips the comment before it ever gets to LineTokenType(), so we don't get failure:

case L'c':
case L'C':
if ((p == str || iswspace(*(p - 1))) && iswspace(*(p + 1))) {
InComment = TRUE;
*p = L' ';
}
continue;

(In ReadLine() the input has a trailing \n so iswspace(*(p+1)) is true.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left as is, except to add a comment to the test cf. ReadLine(). Should I open an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably open an issue, add the low priority label to it.

developer/src/kmcmplib/tests/gtest-kmx_u16-test.cpp Outdated Show resolved Hide resolved
@markcsinclair
Copy link
Contributor Author

Noting that the title and description suggest changes to the compiler code, not just the tests -- is there something missing?

This PR originally contained a fix to the compiler whilst in draft, but then you developed a fix in PR #11910. I merged that into this PR, adopting your fix and extending my tests (see my comments above). I will change the name of this PR to a reflect its final test-only content.

@markcsinclair markcsinclair changed the title fix(developer): correct use of u16chr when second parameter could be null test(developer): check correct use of u16chr when second parameter could be null Jul 30, 2024
…e-of-u16chr-when-second-parameter-could-be-null

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
@github-actions github-actions bot added the test Any acceptance test issue label Jul 30, 2024
@markcsinclair markcsinclair removed the fix label Jul 30, 2024
@mcdurdin
Copy link
Member

This PR originally contained a fix to the compiler whilst in draft, but then you developed a fix in PR #11910. I merged that into this PR, adopting your fix and extending my tests (see my comments above). I will change the name of this PR to a reflect its final test-only content.

And ... I knew that and forgot. Sorry for the hassle!

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@markcsinclair markcsinclair merged commit e8e28b6 into master Jul 31, 2024
4 checks passed
@markcsinclair markcsinclair deleted the fix/developer/correct-use-of-u16chr-when-second-parameter-could-be-null branch July 31, 2024 10:25
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.80-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(developer): incorrect handling of second parameter of index in kmcmplib compiler
4 participants