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

scripts: kconfig: lint.py: Improve error reporting #21577

Merged
merged 1 commit into from
Jan 9, 2020

Conversation

ulfalizer
Copy link
Collaborator

@ulfalizer ulfalizer commented Dec 23, 2019

If the working directory for a command was missing (usually due to
forgetting to run 'west update'), you'd get a FileNotFoundError
exception along with a cryptic error like

'git' not found

Only catch OSError instead (which is a base class of FileNotFoundError),
and always show the exception message. It makes it clear that it's the
working directory that's missing.

Add some other misc. improvements too:

  • Turn stderr output from external commands into a warning instead of
    an error

  • Add err() and warn() helpers

  • Include the command name in messages

ulfalizer added a commit to ulfalizer/ci-tools that referenced this pull request Dec 23, 2019
Similar improvements to
zephyrproject-rtos/zephyr#21577. No custom
potentially-missing working directory is used here, but always including
the exception message still feels more robust.

Use err() instead of sys.exit() in git(), and have it include the
command name, which is helpful in logs.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
ulfalizer added a commit to ulfalizer/ci-tools that referenced this pull request Dec 31, 2019
Similar improvements to
zephyrproject-rtos/zephyr#21577. No custom
potentially-missing working directory is used here, but always including
the exception message still feels more robust.

Use err() instead of sys.exit() in git(), and have it include the
command name, which is helpful in logs.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
nashif pushed a commit to zephyrproject-rtos/ci-tools that referenced this pull request Jan 2, 2020
Similar improvements to
zephyrproject-rtos/zephyr#21577. No custom
potentially-missing working directory is used here, but always including
the exception message still feels more robust.

Use err() instead of sys.exit() in git(), and have it include the
command name, which is helpful in logs.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
@carlescufi
Copy link
Member

@ulfalizer please rebase

If the working directory for a command was missing (usually due to
forgetting to run 'west update'), you'd get a FileNotFoundError
exception along with a cryptic error like

    'git' not found

Only catch OSError instead (which is a base class of FileNotFoundError),
and always show the exception message. It makes it clear that it's the
working directory that's missing.

Add some other misc. improvements too:

 - Turn stderr output from external commands into a warning instead of
   an error

 - Add err() and warn() helpers

 - Include the command name in messages

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
@ulfalizer
Copy link
Collaborator Author

Rebased. Think it was just a random failure.

@nashif nashif merged commit 5372ded into zephyrproject-rtos:master Jan 9, 2020
ulfalizer added a commit to ulfalizer/zephyr that referenced this pull request Jan 10, 2020
Gets these commits in:

    check_compliance.py: Detect refs to undef. symbols in samples and
    tests

    Extend the check for references to undefined Kconfig symbols to also
    detect undefined symbols in samples and tests.

    Samples and tests were skipped due to using separate Kconfig trees,
    which hid the symbols defined in them. Work around it by grepping
    for Kconfig symbol definitions in them instead.

    Keep properly parsing the main Kconfig tree, as it's needed to see
    symbol names that are stitched together with the Kconfig
    preprocessor.

    ------------------------------------------------------------------

    check_compliance.py: Detect bad header comments and other nits

    Add a generic kitchen-sink Nits test for various minor nits that
    aren't already covered by tools like checkpatch.pl and pylint. So
    far checks this:

     - Header comments in Kconfig files

     - Missing newlines at the end of various source files (probably a
       bad editor setting)

     - Leading/trailing blank lines in files

    ------------------------------------------------------------------

    check_compliance.py: Kconfig: Flag redundant $ZEPHYR_BASE in
    'source'

    'source's like

        source "$(ZEPHYR_BASE)/Kconfig.zephyr"

    can be simplified to

        source "Kconfig.zephyr"

    since $srctree already points to the Zephyr root.

    Flag it in the Nits test.

    This also avoids absolute paths showing up in some places.

    ------------------------------------------------------------------

    check_compliance.py: Improve error reporting for Git commands

    Similar improvements to
    zephyrproject-rtos#21577. No custom
    potentially-missing working directory is used here, but always
    including the exception message still feels more robust.

    Use err() instead of sys.exit() in git(), and have it include the
    command name, which is helpful in logs.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
nashif pushed a commit that referenced this pull request Jan 10, 2020
Gets these commits in:

    check_compliance.py: Detect refs to undef. symbols in samples and
    tests

    Extend the check for references to undefined Kconfig symbols to also
    detect undefined symbols in samples and tests.

    Samples and tests were skipped due to using separate Kconfig trees,
    which hid the symbols defined in them. Work around it by grepping
    for Kconfig symbol definitions in them instead.

    Keep properly parsing the main Kconfig tree, as it's needed to see
    symbol names that are stitched together with the Kconfig
    preprocessor.

    ------------------------------------------------------------------

    check_compliance.py: Detect bad header comments and other nits

    Add a generic kitchen-sink Nits test for various minor nits that
    aren't already covered by tools like checkpatch.pl and pylint. So
    far checks this:

     - Header comments in Kconfig files

     - Missing newlines at the end of various source files (probably a
       bad editor setting)

     - Leading/trailing blank lines in files

    ------------------------------------------------------------------

    check_compliance.py: Kconfig: Flag redundant $ZEPHYR_BASE in
    'source'

    'source's like

        source "$(ZEPHYR_BASE)/Kconfig.zephyr"

    can be simplified to

        source "Kconfig.zephyr"

    since $srctree already points to the Zephyr root.

    Flag it in the Nits test.

    This also avoids absolute paths showing up in some places.

    ------------------------------------------------------------------

    check_compliance.py: Improve error reporting for Git commands

    Similar improvements to
    #21577. No custom
    potentially-missing working directory is used here, but always
    including the exception message still feels more robust.

    Use err() instead of sys.exit() in git(), and have it include the
    command name, which is helpful in logs.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants