Skip to content

Commit

Permalink
Merge pull request #2 from julianneswinoga/feature/js/jsbsim-integrat…
Browse files Browse the repository at this point in the history
…ion-tests

Feature/js/jsbsim integration tests
  • Loading branch information
julianneswinoga committed Dec 6, 2022
2 parents 62bba22 + 988ca66 commit 64a7d6f
Show file tree
Hide file tree
Showing 13 changed files with 499 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ jobs:
- run:
name: Poetry show version
command: poetry --version
- when:
# 3.10 has a problem with numpy 1.19.5, from JSBSim
# This hack can be removed when 3.6 support is dropped
condition:
equal: [ "3.10", << parameters.python-version >> ]
steps:
- run:
name: Remove JSBSim
command: poetry remove --dev JSBSim
- run:
name: Delete JSBSim tests
command: rm --verbose tests/test_*JSBSim*.py
- run:
name: Poetry build
command: poetry build --no-ansi --no-interaction
Expand Down
3 changes: 2 additions & 1 deletion flightgear_python/fg_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def connect_tx(self, fg_host: str, fg_port: int):
def _fg_packet_roundtrip(self):
# Receive up to 1KB of data from FG
# blocking is fine here since we're in a separate process

try:
rx_msg, _ = self.fg_rx_sock.recvfrom(1024)
except socket.timeout as e:
Expand All @@ -106,6 +105,7 @@ def _rx_process(self):
print(f'Warning: TX not connected, not sending updates to FG for RX {self.fg_rx_sock.getsockname()}')

self.fg_rx_sock.settimeout(self.rx_timeout_s)
self.event_pipe.child_send((True,)) # Signal to parent that child is running
while True:
self._fg_packet_roundtrip()

Expand All @@ -115,6 +115,7 @@ def start(self):
"""
self.rx_proc = mp.Process(target=self._rx_process)
self.rx_proc.start()
_ = self.event_pipe.parent_recv() # Wait for child to actually run

def stop(self):
"""
Expand Down
109 changes: 92 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pytest-cov = "^3.0.0"
pytest = "==7.0.1"
GitPython = "==3.1.20"
pytest-mock = "==3.6.1"
JSBSim = "==1.1.11"

[tool.poetry.urls]
"Repository" = "https://github.com/julianneswinoga/flightgear-python"
Expand Down
14 changes: 10 additions & 4 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/bin/bash
set -e

python3.6 -m venv --clear .venv
if [ "$1" = 'clean' ]; then
python3.6 -m venv --clear .venv
fi

. ./.venv/bin/activate
pip3 install -U pip
pip3 install -U poetry
poetry update

if [ "$1" = 'clean' ]; then
pip3 install -U pip
pip3 install -U poetry
poetry update
fi
poetry build
poetry install
pytest --cov-report term-missing:skip-covered --cov=flightgear_python tests/
Loading

0 comments on commit 64a7d6f

Please sign in to comment.