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

test: test more platforms #37

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
schedule:
- cron: "1 0 */7 * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
name: Format
Expand All @@ -40,7 +44,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: [ubuntu-latest]
runs-on: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
Expand Down
44 changes: 44 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from __future__ import annotations

import os
import shutil
import subprocess
import time

import pytest


@pytest.fixture(scope="module")
def available_port():
"""
Get an available port on localhost.
"""
import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# Bind to port 0 to let the OS choose an available port
s.bind(("localhost", 0))
# Get the selected port
_, port = s.getsockname()
return port


@pytest.fixture(scope="module")
def server(tmpdir_factory, available_port):
srvdir = tmpdir_factory.mktemp("srv")
tmp_path = os.path.join(srvdir, "Folder")
os.mkdir(tmp_path)
xrootd_executable = shutil.which("xrootd")
proc = subprocess.Popen([xrootd_executable, "-p", str(available_port), str(srvdir)])
time.sleep(2) # give it some startup
yield f"root://localhost:{available_port}/{tmp_path}", tmp_path
proc.terminate()
proc.wait(timeout=10)


@pytest.fixture()
def clear_server(server):
url, path = server
shutil.rmtree(path)
os.mkdir(path)
yield
Loading
Loading