Coverage for hdl_registers/test/lint/test_copyright.py: 85%

20 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-09-29 22:03 +0000

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the hdl_registers project, a HDL register generator fast enough to be run 

5# in real time. 

6# https://hdl-registers.com 

7# https://gitlab.com/tsfpga/hdl_registers 

8# -------------------------------------------------------------------------------------------------- 

9 

10from tsfpga.git_utils import find_git_files 

11from tsfpga.test.lint.test_copyright import CopyrightHeader 

12 

13from hdl_registers import REPO_ROOT 

14 

15COPYRIGHT_HOLDER = "Lukas Vik" 

16COPYRIGHT_TEXT = [ 

17 "This file is part of the hdl_registers project, a HDL register generator fast enough to " 

18 "be run", 

19 "in real time.", 

20 "https://hdl-registers.com", 

21 "https://gitlab.com/tsfpga/hdl_registers", 

22] 

23 

24 

25def files_to_check_for_copyright_header(): 

26 files = [] 

27 

28 file_endings = (".py", ".vhd", ".tcl", ".cpp", ".h") 

29 for file_ending in file_endings: 

30 files += find_git_files( 

31 directory=REPO_ROOT, 

32 file_endings_include=file_ending, 

33 ) 

34 

35 return files 

36 

37 

38def test_copyright_header_of_all_checked_in_files(): 

39 test_ok = True 

40 for file in files_to_check_for_copyright_header(): 

41 copyright_header_checker = CopyrightHeader(file, COPYRIGHT_HOLDER, COPYRIGHT_TEXT) 

42 

43 if not copyright_header_checker.check_file(): 

44 test_ok = False 

45 expected = copyright_header_checker.expected_copyright_header 

46 print(f"Fail for {file}\nExpected:\n{expected}") 

47 assert test_ok