diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 1e6bd769..16ad85ae 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -30,10 +30,10 @@ jobs: - name: Install python libraries shell: bash run: | - pip install black pylint -r tools/requirements.txt + pip install black pylint pytest -r tools/requirements.txt - name: Run pylint and black shell: bash run: | - pylint tools --ignore=build,tests + pylint tools --ignore=build black --check tools diff --git a/.pylintrc b/.pylintrc index 91e2143d..7afd8185 100644 --- a/.pylintrc +++ b/.pylintrc @@ -431,7 +431,8 @@ disable=raw-checker-failed, use-symbolic-message-instead, missing-class-docstring, missing-function-docstring, - missing-module-docstring + missing-module-docstring, + fixme # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/tools/README.md b/tools/README.md index a5062a3f..4c0cbae9 100644 --- a/tools/README.md +++ b/tools/README.md @@ -18,15 +18,26 @@ This verifies exports by comparing the exports of an original DLL and the recomp ## checkorder This checks the order of C++ source and header files to make sure the functions are in order +## isledecomp +This is a library that is used by rhe above scripts. it has a collection of useful classes and functions + +### Testing +`isledecomp` has a small suite of tests. Install pylint and run it, passing in the directory: + +``` +pip install pytest +pytest tools/isledecomp/tests/ +``` + ## Development In order to keep the code clean and consistent, we use `pylint` and `black`: ``` pip install black pylint ``` -### To run pylint: +### To run pylint (ignores build and virtualenv): ``` -pylint tools/ --ignore=build,tests,bin,lib +pylint tools/ --ignore=build,bin,lib ``` ### To check code formatting without rewriting files: @@ -36,4 +47,4 @@ black --check tools/ ### To apply code formatting: ``` black tools/ -``` \ No newline at end of file +``` diff --git a/tools/isledecomp/tests/test_parser.py b/tools/isledecomp/tests/test_parser.py index 1760d688..48bb0e44 100644 --- a/tools/isledecomp/tests/test_parser.py +++ b/tools/isledecomp/tests/test_parser.py @@ -1,5 +1,4 @@ import os -import pytest from typing import List, TextIO from isledecomp.parser import find_code_blocks from isledecomp.parser.util import CodeBlock @@ -11,7 +10,7 @@ def sample_file(filename: str) -> TextIO: """Wrapper for opening the samples from the directory that does not depend on the cwd where we run the test""" full_path = os.path.join(SAMPLE_DIR, filename) - return open(full_path, "r") + return open(full_path, "r", encoding="utf-8") def code_blocks_are_sorted(blocks: List[CodeBlock]) -> bool: diff --git a/tools/isledecomp/tests/test_parser_util.py b/tools/isledecomp/tests/test_parser_util.py index a65ab503..91fd285b 100644 --- a/tools/isledecomp/tests/test_parser_util.py +++ b/tools/isledecomp/tests/test_parser_util.py @@ -1,6 +1,6 @@ -import pytest from collections import namedtuple from typing import List +import pytest from isledecomp.parser.util import ( is_blank_or_comment, match_offset_comment, @@ -69,14 +69,14 @@ def test_is_blank_or_comment(line: str, expected: bool): ] -@pytest.mark.parametrize("match, exact, line", offset_comment_samples) -def test_offset_match(line: str, match: bool, exact): +@pytest.mark.parametrize("match, _, line", offset_comment_samples) +def test_offset_match(line: str, match: bool, _): did_match = match_offset_comment(line) is not None assert did_match is match -@pytest.mark.parametrize("match, exact, line", offset_comment_samples) -def test_exact_offset_comment(line: str, exact: bool, match): +@pytest.mark.parametrize("_, exact, line", offset_comment_samples) +def test_exact_offset_comment(line: str, exact: bool, _): assert is_exact_offset_comment(line) is exact