Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add not worth mentioning initial skeleton for testing using pytest #37

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
86 changes: 86 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attempt to run tests with this seems to just stall on macos-11 without any feedback: see https://github.com/yarikoptic/refuse/actions/runs/4559603821/jobs/8043727829 (still running ,will check if outputs anything tomorrow)


- 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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well -- either low is not intended for Windows at all or smth else need to be done since we get ERROR tests/test_low.py - OSError: Unable to find libfuse . See https://github.com/yarikoptic/refuse/actions/runs/4559603821/jobs/8043726950 for more detail


- 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
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -56,6 +56,7 @@
development_deps_list = [
'coverage',
'pytest',
'pytest-cov',
'python-language-server[all]',
'setuptools',
'Sphinx',
Expand Down
3 changes: 2 additions & 1 deletion src/refuse/_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

THIS FILE IS TEMPORARY AND WILL BE REMOVED!

Copyright (C) 2008-2020 refuse contributors
Copyright (C) 2008-2023 refuse contributors

<LICENSE_BLOCK>
The contents of this file are subject to the Internet Systems Consortium (ISC)
Expand All @@ -32,6 +32,7 @@
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

import os
import sys
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

congratulate on the first bug fix contributed due to initiating the testing ;)

import ctypes
from ctypes.util import find_library

Expand Down
Empty file added src/refuse/tests/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions src/refuse/tests/test_high.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ..high import FUSE, Operations


def test_FUSE():
pass # for now just that we manage to import it ;)
26 changes: 26 additions & 0 deletions src/refuse/tests/test_low.py
Original file line number Diff line number Diff line change
@@ -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)