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

20 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-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/hdl_registers/hdl_registers 

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

9 

10# Third party libraries 

11from tsfpga.git_utils import find_git_files 

12from tsfpga.test.lint.test_copyright import CopyrightHeader 

13 

14# First party libraries 

15from hdl_registers import REPO_ROOT 

16 

17COPYRIGHT_HOLDER = "Lukas Vik" 

18COPYRIGHT_TEXT = [ 

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

20 "be run", 

21 "in real time.", 

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

23 "https://gitlab.com/hdl_registers/hdl_registers", 

24] 

25 

26 

27def files_to_check_for_copyright_header(): 

28 files = [] 

29 

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

31 for file_ending in file_endings: 

32 files += find_git_files( 

33 directory=REPO_ROOT, 

34 file_endings_include=file_ending, 

35 ) 

36 

37 return files 

38 

39 

40def test_copyright_header_of_all_checked_in_files(): 

41 test_ok = True 

42 for file in files_to_check_for_copyright_header(): 

43 copyright_header_checker = CopyrightHeader(file, COPYRIGHT_HOLDER, COPYRIGHT_TEXT) 

44 

45 if not copyright_header_checker.check_file(): 

46 test_ok = False 

47 expected = copyright_header_checker.expected_copyright_header 

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

49 assert test_ok