diff --git a/.github/workflows/python-package-develop.yml b/.github/workflows/python-package-develop.yml new file mode 100644 index 0000000..1020519 --- /dev/null +++ b/.github/workflows/python-package-develop.yml @@ -0,0 +1,48 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: CI-Dev + +on: + push: + branches: [ develop ] + paths-ignore: + - 'License' + - 'README.md' + pull_request: + branches: [ develop ] + paths-ignore: + - 'License' + - 'README.md' + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements-dev.txt + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install -e . + - name: Lint with flake8 + run: | + flake8 c_formatter_42 + - name: Test with pytest + run: | + pytest -vvv + - name: Static type checking with mypy + run: | + mypy c_formatter_42 diff --git a/c_formatter_42/formatters/misc.py b/c_formatter_42/formatters/misc.py index 0316801..6b5b172 100644 --- a/c_formatter_42/formatters/misc.py +++ b/c_formatter_42/formatters/misc.py @@ -40,7 +40,7 @@ def remove_multiline_condition_space(content: str) -> str: def insert_void(content: str) -> str: return re.sub( - r"(?P[0-9a-zA-Z_]*\t+[0-9a-zA-Z_]*\s*)\(\s*\)", + r"(?P[0-9a-zA-Z_]+\t+[0-9a-zA-Z_]*\s*)\(\s*\)", lambda match: "{}({})".format(match.group("funcdef"), "void"), content, ) diff --git a/setup.cfg b/setup.cfg index 998b4d2..52f17e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = c_formatter_42 -version = 0.1.1 +version = 0.1.2 description = formatting tool complient with 42 school's norm long_description = file: README.md long_description_content_type = text/markdown diff --git a/tests/formatters/test_misc.py b/tests/formatters/test_misc.py index 203c057..8687fa9 100644 --- a/tests/formatters/test_misc.py +++ b/tests/formatters/test_misc.py @@ -98,6 +98,8 @@ def test_run_space_in_condition(): def test_insert_void(): assert "int main()" == insert_void("int main()") assert "void func ( )" == insert_void("void func ( )") - assert "int main(void)" == insert_void("int main()") - assert "void func (void)" == insert_void("void func ( )") - assert "void func (void)" == insert_void("void func ( )") + assert "int\tmain(void)" == insert_void("int\tmain()") + assert "void\tfunc (void)" == insert_void("void\tfunc ( )") + assert "void\t\tfunc (void)" == insert_void("void\t\tfunc ( )") + assert "\t(void *)foo()" == insert_void("\t(void *)foo()") + assert "\tfoo()" == insert_void("\tfoo()")