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

fix(developer): make kmc log options consistent across all commands #13075

Merged

Conversation

mcdurdin
Copy link
Member

@mcdurdin mcdurdin commented Jan 30, 2025

Makes the --log-format, --log-level, and --color/--no-color options available for all commands and DRYs out some of the options processing for consistency. This has positive impact in particular on the Generator classes which removes the need for several unit tests as the interface can now be checked at compile time.

Fixes: #13072
Fixes: #13110
Unblocks: #13073

User Testing

We need to test that the logging options work consistently for all commands in kmc. Run tests for each of the commands below:

  • GROUP_ANALYZE_OSK_CHAR_USE: kmc analyze osk-char-use

  • GROUP_ANALYZE_REWRITE_FROM_OSK_CHAR_USE: kmc analyze osk-rewrite-from-char-use

  • GROUP_BUILD_FILE: kmc build file

  • GROUP_BUILD_LDML_TEST_DATA: kmc build ldml-test-data

  • GROUP_BUILD_WINDOWS_PACKAGE_INSTALLER: kmc build windows-package-installer

  • GROUP_MESSAGE: kmc message

  • GROUP_GENERATE_KEYMAN_KEYBOARD: kmc generate keyman-keyboard

  • GROUP_GENERATE_LDML_KEYBOARD: kmc generate ldml-keyboard

  • GROUP_GENERATE_LEXICAL_MODEL: kmc generate lexical-model

  • GROUP_COPY: kmc copy

  • TEST_LOG_LEVEL_SILENT: run the command with --log-level silent and verify that all messages are hidden

  • TEST_LOG_FORMAT_TSV: run the command with --log-format tsv and verify that all messages are printed in a tabular format

  • TEST_COLOR: run the command with --no-color --log-level verbose and verify that all printed messages have no color applied

Makes the `--log-format`, `--log-level`, and `--color`/`--no-color`
options available for all commands and DRYs out some of the options
processing for consistency. This has positive impact in particular on
the Generator classes which removes the need for several unit tests as
the interface can now be checked at compile time.

Fixes: #13072
Unblocks: #13073
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Jan 30, 2025

User Test Results

Test specification and instructions

  • ✅ GROUP_ANALYZE_OSK_CHAR_USE: kmc analyze osk-char-use

    3 tests PASSED
  • ✅ GROUP_ANALYZE_REWRITE_FROM_OSK_CHAR_USE: kmc analyze osk-rewrite-from-char-use

    3 tests PASSED
  • ✅ GROUP_BUILD_FILE: kmc build file

    3 tests PASSED
  • 🟩 GROUP_BUILD_LDML_TEST_DATA: kmc build ldml-test-data

  • 🟩 GROUP_BUILD_WINDOWS_PACKAGE_INSTALLER: kmc build windows-package-installer

  • ✅ GROUP_MESSAGE: kmc message

    3 tests PASSED
  • ✅ GROUP_GENERATE_KEYMAN_KEYBOARD: kmc generate keyman-keyboard

    3 tests PASSED
    • TEST_LOG_LEVEL_SILENT (PASSED): ): no log generated, and no errors, generate command worked
    • TEST_LOG_FORMAT_TSV (PASSED): ): no log generated, but no errors, generate command worked
    • TEST_COLOR (PASSED): ): no log generated, but no errors, generate command worked
  • ✅ GROUP_GENERATE_LDML_KEYBOARD: kmc generate ldml-keyboard

    3 tests PASSED
    • TEST_LOG_LEVEL_SILENT (PASSED): ): no log generated, and no errors, generate command worked
    • TEST_LOG_FORMAT_TSV (PASSED): ): no log generated, but no errors, generate command worked
    • TEST_COLOR (PASSED): ): no log generated, but no errors, generate command worked
  • ✅ GROUP_GENERATE_LEXICAL_MODEL: kmc generate lexical-model

    3 tests PASSED
    • TEST_LOG_LEVEL_SILENT (PASSED): ): no log generated, and no errors, generate command worked
    • TEST_LOG_FORMAT_TSV (PASSED): ): no log generated, but no errors, generate command worked
    • TEST_COLOR (PASSED): ): no log generated, but no errors, generate command worked
  • ✅ GROUP_COPY: kmc copy

    3 tests PASSED

Test Artifacts

@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S20 milestone Jan 30, 2025
@@ -45,32 +46,11 @@ describe('generateKeymanKeyboard', function() {
outPath = null;
});

it('should only allow a single id', async function() {
Copy link
Member Author

Choose a reason for hiding this comment

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

These two tests are no longer necessary as they are validated at compile-time.

Copy link
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

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

lgtm

const keyboardOptions = {
icon: true,
const keyboardOptions: GeneratorOptions = {
// icon: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this supposed to be part of #12971?

Same change on the other tests.ts

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it was missed because it was essentially ignored (because it was an untyped object). Once I added the GeneratorOptions type, that forced the removal of the icon property. No real harm done, fortunately!

Copy link
Member

@srl295 srl295 left a comment

Choose a reason for hiding this comment

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

nice DRY work

Base automatically changed from feat/developer/13060-relocate-files-in-kmc-copy to master January 30, 2025 23:06
Copy link
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

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

lgtm

Also add some resilience to option usage in kmc-generate; more work may
need to be done here in future.

Fixes: #13110
@dinakaranr
Copy link

Test Results

I tested this issue with the attached "Keyman-18.0.178-alpha-test-13075" build(03/02/2025) on Windows 10. I'm sharing my observation here.

GROUP_ANALYZE_OSK_CHAR_USE: kmc analyze osk-char-use

  • TEST_LOG_LEVEL_SILENT (Passed):
    Switched to Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-char-use -m ghanatext.json --log-level silent
    Verified that the file was created in the project folder.
    It works well.

  • TEST_LOG_FORMAT_TSV (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-char-use -m ghanatext.json --log-format tsv
    Verified that the file was created in the project folder.
    It works well.

  • TEST_COLOR (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-char-use -m ghanatext.json--no-color --log-level verbose
    Verified that the file was created in the project folder.
    It works well.

GROUP_ANALYZE_REWRITE_FROM_OSK_CHAR_USE: kmc analyze osk-rewrite-from-char-use

  • TEST_LOG_LEVEL_SILENT (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-rewrite-from-char-use -m ghanatext.json --log-level silent
    Verified that the file was created in the project folder.
    It works well.

  • TEST_LOG_FORMAT_TSV (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-rewrite-from-char-use -m ghanatext.json --log-format tsv
    Verified that the file was created in the project folder.
    It works well.

  • TEST_COLOR (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc analyze osk-rewrite-from-char-use -m ghanatext.json --no-color --log-level verbose
    Verified that the file was created in the project folder.
    It works well.

GROUP_BUILD_FILE: kmc build file

  • TEST_LOG_LEVEL_SILENT (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc build file --log-level silent
    Verified that the build file was created in the project folder.
    It works well.

  • TEST_LOG_FORMAT_TSV (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run the below command
    kmc build file --log-format tsv
    Verified that the build file was created in the project folder.
    It works well.

  • TEST_COLOR (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc build file --no-color --log-level verbose
    Verified that the build file was created in the project folder.
    It works well.

GROUP_BUILD_LDML_TEST_DATA: kmc build ldml-test-data

  • TEST_LOG_LEVEL_SILENT (Skip):
  • TEST_LOG_FORMAT_TSV (Skip):
  • TEST_COLOR (Skip):

GROUP_BUILD_WINDOWS_PACKAGE_INSTALLER: kmc build windows-package-installer

  • TEST_LOG_LEVEL_SILENT (Skip):
  • TEST_LOG_FORMAT_TSV (Skip):
  • TEST_COLOR (Skip):

GROUP_MESSAGE: kmc message

  • TEST_LOG_LEVEL_SILENT (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc message 400c --log-level silent
    Verified that the "HINT_PackageShouldNotRepeatLanguages" message with details.
    It works well.

  • TEST_LOG_FORMAT_TSV (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc message 400c --log-format tsv
    Verified that the "HINT_PackageShouldNotRepeatLanguages" message with details.
    It works well.

  • TEST_COLOR (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects\ghana_read)
    Open the command prompt from the project folder.
    Run below command
    kmc message 400c --no-color --log-level verbose
    Verified that the "HINT_PackageShouldNotRepeatLanguages" message with details.
    It works well.

GROUP_GENERATE_KEYMAN_KEYBOARD: kmc generate keyman-keyboard

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

GROUP_GENERATE_LDML_KEYBOARD: kmc generate ldml-keyboard

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

GROUP_GENERATE_LEXICAL_MODEL: kmc generate lexical-model

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

GROUP_COPY: kmc copy

  • TEST_LOG_LEVEL_SILENT (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects)
    Open the command prompt from the project folder.
    Run below command
    kmc copy "source keyman project folder path" -o "destination folder path" --log-level silent
    Verified that the project folder was copied into the destination folder path.
    It works well.

  • TEST_LOG_FORMAT_TSV (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects)
    Open the command prompt from the project folder.
    Run below command
    kmc copy "source keyman project folder path" -o "destination folder path" --log-level silent
    Verified that the project folder was copied into the destination folder path.
    It works well.

  • TEST_COLOR (Passed):
    Switched to the Project folder. (C:\Users\User_Name\Documents\Keyman Developer\Projects)
    Open the command prompt from the project folder.
    Run below command
    kmc copy "source keyman project folder path" -o "destination folder path" --log-level silent
    Verified that the project folder was copied into the destination folder path.
    It works well.

@keymanapp-test-bot keymanapp-test-bot bot added user-test-failed and removed user-test-required User tests have not been completed labels Feb 3, 2025
@mcdurdin
Copy link
Member Author

mcdurdin commented Feb 4, 2025

GROUP_GENERATE_KEYMAN_KEYBOARD: kmc generate keyman-keyboard

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

GROUP_GENERATE_LDML_KEYBOARD: kmc generate ldml-keyboard

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

GROUP_GENERATE_LEXICAL_MODEL: kmc generate lexical-model

  • TEST_LOG_LEVEL_SILENT (failed):
  • TEST_LOG_FORMAT_TSV (failed):
  • TEST_COLOR (failed):

Hi @dinakaranr, could you let me know what the failures were here please?

@dinakaranr
Copy link

Okay. I failed these three problems because you indicated I filed a PR13110 in GitHub for these three cases. I attempted to generate keyboards. However, no log lines show after performing commands. Please look at the screenshot. Thank you.

@mcdurdin
Copy link
Member Author

mcdurdin commented Feb 5, 2025

Thank you @dinakaranr. I think the generate command does not currently generate any logs unless there is an error. We should add some 'info' logs for normal operation, which I will put into a new issue to resolve during beta. So I think we can say that these passed, hurrah!

GROUP_GENERATE_KEYMAN_KEYBOARD: kmc generate keyman-keyboard
TEST_LOG_LEVEL_SILENT (PASS): no log generated, and no errors, generate command worked
TEST_LOG_FORMAT_TSV (PASS): no log generated, but no errors, generate command worked
TEST_COLOR (PASS): no log generated, but no errors, generate command worked
GROUP_GENERATE_LDML_KEYBOARD: kmc generate ldml-keyboard
TEST_LOG_LEVEL_SILENT (PASS): no log generated, and no errors, generate command worked
TEST_LOG_FORMAT_TSV (PASS): no log generated, but no errors, generate command worked
TEST_COLOR (PASS): no log generated, but no errors, generate command worked
GROUP_GENERATE_LEXICAL_MODEL: kmc generate lexical-model
TEST_LOG_LEVEL_SILENT (PASS): no log generated, and no errors, generate command worked
TEST_LOG_FORMAT_TSV (PASS): no log generated, but no errors, generate command worked
TEST_COLOR (PASS): no log generated, but no errors, generate command worked

@mcdurdin mcdurdin merged commit 2df63dd into master Feb 5, 2025
6 checks passed
@mcdurdin mcdurdin deleted the fix/developer/13072-make-kmc-log-options-consistent branch February 5, 2025 04:30
@keyman-server
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
5 participants