def test_for_valid_licenses(): """ Test that all *.py, *.rs and *.sh files contain a valid license. @type: style """ python_files = utils.get_files_from( find_path="..", pattern="*.py", exclude_names=EXCLUDE) rust_files = utils.get_files_from( find_path="..", pattern="*.rs", exclude_names=EXCLUDE) bash_files = utils.get_files_from( find_path="..", pattern="*.sh", exclude_names=EXCLUDE) all_files = rust_files + python_files + bash_files error_msg = [] for file in all_files: if _validate_license(file) is False: error_msg.append("{}".format(str(file))) assert not error_msg, "Files {} have invalid licenses".format((error_msg))
def test_python_style(): """Fail if there's misbehaving Python style in the test system.""" # List of linter commands that should be executed for each file linter_cmds = [ # Pylint 'python3 -m pylint --jobs=0 --persistent=no --score=no ' \ '--output-format=colorized --attr-rgx="[a-z_][a-z0-9_]{1,30}$" ' \ '--argument-rgx="[a-z_][a-z0-9_]{1,30}$" ' \ '--variable-rgx="[a-z_][a-z0-9_]{1,30}$" --disable=' \ 'bad-continuation,fixme,too-many-instance-attributes,import-error,' \ 'too-many-locals,too-many-arguments', # pycodestyle 'python3 -m pycodestyle --show-pep8 --show-source --exclude=../build', # pydocstyle "python3 -m pydocstyle --explain --source"] # Get all *.py files from the project python_files = utils.get_files_from( find_path="..", pattern="*.py", exclude_names=["build"]) # Assert if somehow no python files were found assert len(python_files) != 0 # Run commands utils.run_cmd_list_async([ f"{cmd} {fname}" for cmd in linter_cmds for fname in python_files ])
def test_python_pylint(): """ Test that python code passes linter checks. @type: build """ # List of linter commands that should be executed for each file linter_cmd = ( # Pylint "python3 -m pylint --jobs=0 --persistent=no --score=no " '--output-format=colorized --attr-rgx="[a-z_][a-z0-9_]{1,30}$" ' '--argument-rgx="[a-z_][a-z0-9_]{1,35}$" ' '--variable-rgx="[a-z_][a-z0-9_]{1,30}$" --disable=' "fixme,too-many-instance-attributes,import-error," "too-many-locals,too-many-arguments,consider-using-f-string," "consider-using-with,implicit-str-concat") # Get all *.py files from the project python_files = utils.get_files_from(find_path="..", pattern="*.py", exclude_names=["build", ".kernel"]) # Assert if somehow no python files were found assert len(python_files) != 0 # Run commands utils.run_cmd_list_async( [f"{linter_cmd} {fname}" for fname in python_files])
def test_for_valid_licenses(): """Fail if a file lacks a valid license.""" python_files = utils.get_files_from(find_path="..", pattern="*.py", exclude_names=["build"]) rust_files = utils.get_files_from(find_path="..", pattern="*.rs", exclude_names=["build"]) bash_files = utils.get_files_from(find_path="..", pattern="*.sh", exclude_names=["build"]) all_files = rust_files + python_files + bash_files error_msg = [] for file in all_files: if _validate_license(file) is False: error_msg.append("{}".format(str(file))) assert not error_msg, "Files {} have invalid licenses".format((error_msg))
def test_markdown_style(): """Fail if there's misbehaving markdown style in the test system.""" # Get all *.md files from the project md_files = utils.get_files_from(find_path="..", pattern="*.md", exclude_names=["build"]) # Assert if somehow no markdown files were found. assert len(md_files) != 0 # Run commands cmd = "mdl -c ../.mdlrc " for fname in md_files: cmd += fname + " " _, output, _ = utils.run_cmd(cmd) assert output == ""
def test_markdown_style(): """ Test that markdown files adhere to the style rules. @type: style """ # Get all *.md files from the project md_files = utils.get_files_from(find_path="..", pattern="*.md", exclude_names=["build"]) # Assert if somehow no markdown files were found. assert len(md_files) != 0 # Run commands cmd = "mdl -c ../.mdlrc " for fname in md_files: cmd += fname + " " _, output, _ = utils.run_cmd(cmd) assert output == ""