Logs an error if a source file does not include its header.
(filename, include_state, error)
| 2464 | |
| 2465 | |
| 2466 | def CheckHeaderFileIncluded(filename, include_state, error): |
| 2467 | """Logs an error if a source file does not include its header.""" |
| 2468 | |
| 2469 | # Do not check test files |
| 2470 | fileinfo = FileInfo(filename) |
| 2471 | if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): |
| 2472 | return |
| 2473 | |
| 2474 | for ext in GetHeaderExtensions(): |
| 2475 | basefilename = filename[0:len(filename) - len(fileinfo.Extension())] |
| 2476 | headerfile = basefilename + '.' + ext |
| 2477 | if not os.path.exists(headerfile): |
| 2478 | continue |
| 2479 | headername = FileInfo(headerfile).RepositoryName() |
| 2480 | first_include = None |
| 2481 | include_uses_unix_dir_aliases = False |
| 2482 | for section_list in include_state.include_list: |
| 2483 | for f in section_list: |
| 2484 | include_text = f[0] |
| 2485 | if "./" in include_text: |
| 2486 | include_uses_unix_dir_aliases = True |
| 2487 | if headername in include_text or include_text in headername: |
| 2488 | return |
| 2489 | if not first_include: |
| 2490 | first_include = f[1] |
| 2491 | |
| 2492 | message = '%s should include its header file %s' % (fileinfo.RepositoryName(), headername) |
| 2493 | if include_uses_unix_dir_aliases: |
| 2494 | message += ". Relative paths like . and .. are not allowed." |
| 2495 | |
| 2496 | error(filename, first_include, 'build/include', 5, message) |
| 2497 | |
| 2498 | |
| 2499 | def CheckForBadCharacters(filename, lines, error): |
no test coverage detected