Skip to content

Commit

Permalink
Use pytest_xdist for unit-test speed up in CI (AtsushiSakai#459)
Browse files Browse the repository at this point in the history
* Remove unnecessary plot

* Remove unnecessary plot

* update appveyor.yml
  • Loading branch information
AtsushiSakai authored Jan 16, 2021
1 parent 67d7d5c commit 2731cdb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/Linux_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
run: pip install mypy
- name: install pycodestyle
run: pip install pycodestyle
- name: install pytest-xdist
run: pip install pytest-xdist
- name: mypy check
run: |
find AerialNavigation -name "*.py" | xargs mypy
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/MacOS_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ jobs:
pip install -r requirements.txt
- name: install coverage
run: pip install coverage

- name: install mypy
run: pip install mypy

- name: install pycodestyle
run: pip install pycodestyle

- name: install pytest-xdist
run: pip install pytest-xdist
- name: mypy check
run: |
find AerialNavigation -name "*.py" | xargs mypy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import math
from enum import IntEnum

import matplotlib.pyplot as plt
import numpy as np
from scipy.spatial.transform import Rotation as Rot
from Mapping.grid_map_lib.grid_map_lib import GridMap
import matplotlib.pyplot as plt

do_animation = True

Expand Down Expand Up @@ -240,8 +240,6 @@ def sweep_path_search(sweep_searcher, grid_map, grid_search_animation=False):
grid_map.plot_grid_map(ax=ax)
plt.pause(1.0)

grid_map.plot_grid_map()

return px, py


Expand Down Expand Up @@ -289,13 +287,13 @@ def planning_animation(ox, oy, resolution): # pragma: no cover
plt.grid(True)
plt.pause(0.1)

plt.cla()
plt.plot(ox, oy, "-xb")
plt.plot(px, py, "-r")
plt.axis("equal")
plt.grid(True)
plt.pause(0.1)
plt.close()
plt.cla()
plt.plot(ox, oy, "-xb")
plt.plot(px, py, "-r")
plt.axis("equal")
plt.grid(True)
plt.pause(0.1)
plt.close()


def main(): # pragma: no cover
Expand All @@ -316,7 +314,8 @@ def main(): # pragma: no cover
resolution = 5.0
planning_animation(ox, oy, resolution)

plt.show()
if do_animation:
plt.show()
print("done!!")


Expand Down
3 changes: 2 additions & 1 deletion PathPlanning/StateLatticePlanner/state_lattice_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
try:
import model_predictive_trajectory_generator as planner
import motion_model
except:
except ImportError:
raise


Expand Down Expand Up @@ -323,6 +323,7 @@ def lane_state_sampling_test1():


def main():
planner.show_animation = show_animation
uniform_terminal_state_sampling_test1()
uniform_terminal_state_sampling_test2()
biased_terminal_state_sampling_test1()
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install:
- SET PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
- "python -m pip install --upgrade pip"
- "python -m pip install -r requirements.txt"
- "python -m pip install pytest-xdist"

# Check that we have the expected version and architecture for Python
- "python --version"
Expand All @@ -42,4 +43,4 @@ install:
build: off

test_script:
- "pytest tests -Werror --durations=0"
- "pytest tests -n auto -Werror --durations=0"
2 changes: 1 addition & 1 deletion runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ echo "Run test suites! "
# -Werror: warning as error
# --durations=0: show ranking of test durations
# -l (--showlocals); show local variables when test failed
pytest tests -l -Werror --durations=0
pytest -n auto tests -l -Werror --durations=0
3 changes: 0 additions & 3 deletions tests/test_state_lattice_planner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import conftest # Add root path to sys.path
from PathPlanning.StateLatticePlanner import state_lattice_planner as m
from PathPlanning.ModelPredictiveTrajectoryGenerator \
import model_predictive_trajectory_generator as m2


def test1():
m.show_animation = False
m2.show_animation = False
m.main()

0 comments on commit 2731cdb

Please sign in to comment.