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

addons/namingng.py: Add tests for include guards, config file validation. #5815

Merged
merged 2 commits into from
Jan 2, 2024

Commits on Jan 1, 2024

  1. addons/namingng.py: Add checks for include guards.

    Include guard naming can be validated against various patterns:
    - prefixes/suffixes (_FILE_H, PROJECT_FILE_H, FILE_H_)
    - basename/full path (FILE_H, SUB_DIR_INC_FILE_H)
    - upper- or lowercase (FILE_H, file_h) or case kept as-is (File_h)
    - any combination of the above (project_sub_dir_inc_file_h_)
    
    A regexp can be specified to match header filenames. The default matches any
    filename not starting with / and ending with .h, intended to match C header
    files while exluding system files.
    
    The check is not limited to naming only; validity and presence of include
    guards can also be tested by setting "required":true in the config file.
    
    Enabling this feature requires adding the key "include_guard" to the namingng
    config file.
    
    The namingng unit test is extended to test various features of the include
    guard check.
    mvds00 committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    fd21729 View commit details
    Browse the repository at this point in the history
  2. addons/namingng.py: Add config sanity checks and unit test.

    The config file is parsed and (superficially) validated, before starting
    validation. Various errors are checked and reported, along with a non-zero exit
    status.
    
    After parsing and type validation, the config values are stored in an object,
    so they can be referenced as object members instead of dict keys
    (`conf.variable` instead of `conf["RE_VARNAME"]`). This separates config syntax
    from application code.
    
    A unit test is added to test config file validation.
    
    The example config JSON in namingng.py is fixed.
    mvds00 committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    3487a50 View commit details
    Browse the repository at this point in the history