diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bc84ccc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,86 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: +# re-enable whenever it works! +# schedule: +# - cron: '0 6 * * *' + +defaults: + run: + shell: bash + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + # got "ERROR tests/test_low.py - OSError: Unable to find libfuse" + # - windows-2019 + - ubuntu-latest + # got "installer: Error - The FUSE for macOS installation package is not compatible with this version of macOS." + # from osxfuse + # - macos-latest + # get "Error: The operation was canceled." after PASSED test, odd + # - macos-11 + + python: + - 3.7 + - 3.8 + - 3.9 + - '3.10' # Needs quotes so YAML doesn't think it's 3.1 + - '3.11' + + steps: + - name: Set up environment + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install Python dependencies and refuse itself + run: | + python -m pip install --upgrade pip wheel + pip install ".[dev]" + + - name: Install FUSE (Linux) + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get update -qq + sudo eatmydata apt-get install -y fuse + + - name: Install OSXFUSE (MacOS) + if: startsWith(matrix.os, 'macos') + run: | + brew update + brew install osxfuse + + - name: Install WinFsp (Windows) + if: startsWith(matrix.os, 'windows') + shell: pwsh + run: | + $url = 'https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-2.0.23075.msi' + Invoke-WebRequest -Uri $url -OutFile 'winfsp.msi' + Start-Process msiexec.exe -ArgumentList '/i', 'winfsp.msi', '/quiet', '/norestart' -Wait + + - name: Run all tests + run: | + python -m pytest -s -v --cov=refuse --cov-report=xml --pyargs refuse + + # enable later + #- name: Upload coverage to Codecov + # uses: codecov/codecov-action@v3 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # file: ./coverage.xml + # flags: unittests + # # name: codecov-umbrella + # # yml: ./codecov.yml + # fail_ci_if_error: false diff --git a/setup.py b/setup.py index 127705b..a1816d7 100644 --- a/setup.py +++ b/setup.py @@ -38,11 +38,11 @@ # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # BUMP VERSION HERE! -_version_ = '0.0.4' +_version_ = '0.0.5' # List all versions of Python which are supported -python_minor_min = 5 -python_minor_max = 8 +python_minor_min = 7 +python_minor_max = 11 confirmed_python_versions = [ 'Programming Language :: Python :: 3.{MINOR:d}'.format(MINOR = minor) for minor in range(python_minor_min, python_minor_max + 1) @@ -56,6 +56,7 @@ development_deps_list = [ 'coverage', 'pytest', + 'pytest-cov', 'python-language-server[all]', 'setuptools', 'Sphinx', diff --git a/src/refuse/_refactor.py b/src/refuse/_refactor.py index ca97b01..933e163 100644 --- a/src/refuse/_refactor.py +++ b/src/refuse/_refactor.py @@ -10,7 +10,7 @@ THIS FILE IS TEMPORARY AND WILL BE REMOVED! - Copyright (C) 2008-2020 refuse contributors + Copyright (C) 2008-2023 refuse contributors The contents of this file are subject to the Internet Systems Consortium (ISC) @@ -32,6 +32,7 @@ # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import os +import sys import ctypes from ctypes.util import find_library diff --git a/src/refuse/tests/__init__.py b/src/refuse/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/refuse/tests/test_high.py b/src/refuse/tests/test_high.py new file mode 100644 index 0000000..d9125fa --- /dev/null +++ b/src/refuse/tests/test_high.py @@ -0,0 +1,5 @@ +from ..high import FUSE, Operations + + +def test_FUSE(): + pass # for now just that we manage to import it ;) diff --git a/src/refuse/tests/test_low.py b/src/refuse/tests/test_low.py new file mode 100644 index 0000000..3ed07ff --- /dev/null +++ b/src/refuse/tests/test_low.py @@ -0,0 +1,26 @@ +import ctypes +from ..low import FUSELL, LibFUSE, fuse_args + +import pytest + + +@pytest.fixture +def fusell(tmp_path): + yield FUSELL(str(tmp_path)) + + +def test_LibFUSE_mount_unmount(tmp_path): + lib = LibFUSE() + args = ['fuse'] + # worth moving into helper to be reused here + argv = fuse_args(len(args), (ctypes.c_char_p * len(args))(*[arg.encode() for arg in args]), 0) + chan = lib.fuse_mount(str(tmp_path).encode(), argv) + lib.fuse_unmount(str(tmp_path).encode(), chan) + + +# +# likely fusell needs its own thread +# +#def test_nothing_much(fusell): +# assert str(fusell) +# assert repr(fusell)