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
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
parallel = true
include =
src/algorithms/classic/graph_based/*
*_manager.py
src/maps/*
src/simulator/*
src/structures/*
src/algorithms/configuration/*
12 changes: 7 additions & 5 deletions .github/workflows/test-PRs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
build:

runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8.5]
Expand All @@ -27,8 +27,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install xvfb scrot
python -m pip install --upgrade pip
sudo apt-get install -y xvfb scrot gcc
python -m pip install --upgrade pip setuptools wheel
pip install flake8 coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
Expand All @@ -40,5 +40,7 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests with coverage and upload
run: |
coverage run tests/run_tests.py --cov-report=xml --spawn-display
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} -e PYTHON
CODECOV_EXEC="coverage run -p"
$CODECOV_EXEC tests/run_tests.py --spawn-display
ls -a
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} -e PYTHON -f '.coverage.*'
33 changes: 18 additions & 15 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
from algorithms.configuration.configuration import Configuration
from algorithms.algorithm_manager import AlgorithmManager
from maps.map_manager import MapManager
from algorithms.lstm.trainer import Trainer
from analyzer.analyzer import Analyzer
from generator.generator import Generator
from simulator.services.debug import DebugLevel
from simulator.services.services import Services
from simulator.simulator import Simulator
from utility.misc import flatten
from utility.argparse import add_configuration_flags

import copy
import sys
import os
import argparse
from typing import List, Callable

# Compatibility for running with codecov, add 'PathBench/src' to system path for module imports
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

from algorithms.configuration.configuration import Configuration # noqa: E402
from algorithms.algorithm_manager import AlgorithmManager # noqa: E402
from maps.map_manager import MapManager # noqa: E402
from algorithms.lstm.trainer import Trainer # noqa: E402
from analyzer.analyzer import Analyzer # noqa: E402
from generator.generator import Generator # noqa: E402
from simulator.services.debug import DebugLevel # noqa: E402
from simulator.services.services import Services # noqa: E402
from simulator.simulator import Simulator # noqa: E402
from utility.misc import flatten # noqa: E402
from utility.argparse import add_configuration_flags # noqa: E402

import argparse # noqa: E402
from typing import List, Callable # noqa: E402

class MainRunner:
main_services: Services
Expand Down
8 changes: 6 additions & 2 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
import unittest
from unittest import TestLoader, TestSuite, TextTestRunner, TestResult

from utils import make_src_modules_importable
# Compatibility for running with codecov, add 'PathBench/tests' to system path for module imports
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

from utils import make_src_modules_importable # noqa: E402

def run() -> bool:
# add src folder to system path
make_src_modules_importable()

tests_path = os.path.dirname(os.path.abspath(__file__))

parser = argparse.ArgumentParser(prog="run_tests.py",
description="PathBench test runner",
formatter_class=argparse.RawTextHelpFormatter)
Expand All @@ -28,6 +31,7 @@ def run() -> bool:
res: TestResult = testRunner.run(tests)
return (len(res.errors) == 0 and len(res.failures) == 0)


if __name__ == '__main__':
res = run()
sys.exit(int(not res))
6 changes: 5 additions & 1 deletion tests/test_graphics/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ def setup(args: argparse.Namespace, visualiser_args: List[str]) -> None:
# enforce correct display being used
pyautogui._pyautogui_x11._display = Xlib.display.Display(os.environ['DISPLAY'])

# Fall back to sys executable if no env variable to specify how to run with codecov
executable_name = os.environ.get("CODECOV_EXEC", sys.executable)
print(f"Using executable {executable_name}")

if not args.no_launch_visualiser:
launch_process([sys.executable, os.path.join(SRC_PATH, 'main.py'), '-d', args.debug, '-v', '-Vwindowed-fullscreen',
launch_process([executable_name, os.path.join(SRC_PATH, 'main.py'), '-d', args.debug, '-v', '-Vwindowed-fullscreen',
'-Vaudio-library-name=null', '--deterministic'] + visualiser_args,
on_kill=lambda _: pyautogui.press('esc'))

Expand Down
3 changes: 3 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def handle_display_args(args) -> None:
from utility.process import launch_process
sys.path.pop(0) # remove src folder from path

if 'DISPLAY' not in os.environ:
args.spawn_display = ':99'

if args.spawn_display:
cmd = ["Xvfb", args.spawn_display, "-screen", "0", "2112x1376x24", "-fbdir", "/var/tmp"]
if 'DISPLAY' in os.environ:
Expand Down