mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-24 08:41:16 +00:00
Lint tests, add tests to readme
This commit is contained in:
parent
ec870e7771
commit
2639109aa3
4
.github/workflows/format.yml
vendored
4
.github/workflows/format.yml
vendored
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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/
|
||||
```
|
||||
```
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user