Skip to content

Commit

Permalink
pw_presubmit: Add logging to pragma_once check
Browse files Browse the repository at this point in the history
This makes it easier to track down specific files if exceptions occur.

Change-Id: Iacba4aa6676ea7457c7748701eedc322b2c9144b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/113515
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
  • Loading branch information
mohrr authored and CQ Bot Account committed Oct 8, 2022
1 parent 56d8316 commit af77ba6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pw_presubmit/py/pw_presubmit/cpp_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# the License.
"""C++-related checks."""

import logging

from pw_presubmit import (
build,
Check,
Expand All @@ -21,12 +23,15 @@
filter_paths,
)

_LOG: logging.Logger = logging.getLogger(__name__)


@filter_paths(endswith=format_code.CPP_HEADER_EXTS, exclude=(r'\.pb\.h$', ))
def pragma_once(ctx: PresubmitContext) -> None:
"""Presubmit check that ensures all header files contain '#pragma once'."""

for path in ctx.paths:
_LOG.debug('Checking %s', path)
with open(path) as file:
for line in file:
if line.startswith('#pragma once'):
Expand Down

0 comments on commit af77ba6

Please sign in to comment.