Skip to content
Open
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
11 changes: 9 additions & 2 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ on:
workflow_dispatch: {}
push:
branches:
- master
- '**'
paths:
- 'fdsreader/**'
pull_request:
branches:
- '**'
paths:
- 'fdsreader/**'

Expand All @@ -20,13 +22,18 @@ permissions:
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']

name: Python ${{ matrix.python-version }} tests
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 8 additions & 0 deletions tests/acceptance_tests/test_version_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Basic tests to ensure version compatibility."""

from fdsreader import Simulation


def test_sim():
sim = Simulation("test.smv")
assert sim.chid == "test"
File renamed without changes.
80 changes: 80 additions & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
set -euo pipefail

PYTEST_ARGS="-v -W ignore::UserWarning"

# Get the tests directory (where this script is located)
TESTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$( cd "$TESTS_DIR/.." && pwd )"


# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Detect Python environment manager
if command_exists uv; then
PYTHON_CMD="uv run"
elif command_exists python3; then
PYTHON_CMD="python3 -m"
elif command_exists python; then
PYTHON_CMD="python -m"
else
echo "Error: No Python interpreter found (install uv or python3)" >&2
exit 1
fi

echo ""
echo -e "Preparing test data..."
cd "$TESTS_DIR/cases" || { echo -e "${RED} Cannot cd to $TESTS_DIR/cases${NC}"; exit 1; }

shopt -s nullglob

EXPECTED_DIRS=()
for f in *.tgz; do
[[ -f "$f" ]] || continue
EXPECTED_DIRS+=("${f%.tgz}")
done

NEED_EXTRACT=false

# Check if any expected directory is missing
for tgz_file in *.tgz; do
if [ -f "$tgz_file" ]; then
DIR_NAME="${tgz_file%.tgz}"
if [ ! -d "$DIR_NAME" ]; then
NEED_EXTRACT=true
break
fi
fi
done

if [ "$NEED_EXTRACT" = true ]; then
echo " Extracting test data files..."
for f in *.tgz; do
if [ -f "$f" ]; then
echo " Extracting $f..."
tar -xzf "$f"
if [ $? -ne 0 ]; then
echo -e "Failed to extract $f$"
exit 1
fi
fi
done
echo -e "Test data extracted"
else
echo -e "Test data already extracted"
fi

echo ""
echo -e "Running acceptance tests..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"


# Run the tests
if command_exists uv; then
uv run pytest ../acceptance_tests/ $PYTEST_ARGS
else
$PYTHON_CMD pytest ../acceptance_tests/ $PYTEST_ARGS
fi
16 changes: 0 additions & 16 deletions tests/test_version_compatibility.py

This file was deleted.