Skip to content

Commit 2731cdb

Browse files
authored
Use pytest_xdist for unit-test speed up in CI (AtsushiSakai#459)
* Remove unnecessary plot * Remove unnecessary plot * update appveyor.yml
1 parent 67d7d5c commit 2731cdb

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

.github/workflows/Linux_CI.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: pip install mypy
3131
- name: install pycodestyle
3232
run: pip install pycodestyle
33+
- name: install pytest-xdist
34+
run: pip install pytest-xdist
3335
- name: mypy check
3436
run: |
3537
find AerialNavigation -name "*.py" | xargs mypy

.github/workflows/MacOS_CI.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ jobs:
2828
pip install -r requirements.txt
2929
- name: install coverage
3030
run: pip install coverage
31-
3231
- name: install mypy
3332
run: pip install mypy
34-
3533
- name: install pycodestyle
3634
run: pip install pycodestyle
37-
35+
- name: install pytest-xdist
36+
run: pip install pytest-xdist
3837
- name: mypy check
3938
run: |
4039
find AerialNavigation -name "*.py" | xargs mypy

PathPlanning/GridBasedSweepCPP/grid_based_sweep_coverage_path_planner.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import math
88
from enum import IntEnum
99

10-
import matplotlib.pyplot as plt
1110
import numpy as np
1211
from scipy.spatial.transform import Rotation as Rot
1312
from Mapping.grid_map_lib.grid_map_lib import GridMap
13+
import matplotlib.pyplot as plt
1414

1515
do_animation = True
1616

@@ -240,8 +240,6 @@ def sweep_path_search(sweep_searcher, grid_map, grid_search_animation=False):
240240
grid_map.plot_grid_map(ax=ax)
241241
plt.pause(1.0)
242242

243-
grid_map.plot_grid_map()
244-
245243
return px, py
246244

247245

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

292-
plt.cla()
293-
plt.plot(ox, oy, "-xb")
294-
plt.plot(px, py, "-r")
295-
plt.axis("equal")
296-
plt.grid(True)
297-
plt.pause(0.1)
298-
plt.close()
290+
plt.cla()
291+
plt.plot(ox, oy, "-xb")
292+
plt.plot(px, py, "-r")
293+
plt.axis("equal")
294+
plt.grid(True)
295+
plt.pause(0.1)
296+
plt.close()
299297

300298

301299
def main(): # pragma: no cover
@@ -316,7 +314,8 @@ def main(): # pragma: no cover
316314
resolution = 5.0
317315
planning_animation(ox, oy, resolution)
318316

319-
plt.show()
317+
if do_animation:
318+
plt.show()
320319
print("done!!")
321320

322321

PathPlanning/StateLatticePlanner/state_lattice_planner.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
try:
2626
import model_predictive_trajectory_generator as planner
2727
import motion_model
28-
except:
28+
except ImportError:
2929
raise
3030

3131

@@ -323,6 +323,7 @@ def lane_state_sampling_test1():
323323

324324

325325
def main():
326+
planner.show_animation = show_animation
326327
uniform_terminal_state_sampling_test1()
327328
uniform_terminal_state_sampling_test2()
328329
biased_terminal_state_sampling_test1()

appveyor.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ install:
3434
- SET PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
3535
- "python -m pip install --upgrade pip"
3636
- "python -m pip install -r requirements.txt"
37+
- "python -m pip install pytest-xdist"
3738

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

4445
test_script:
45-
- "pytest tests -Werror --durations=0"
46+
- "pytest tests -n auto -Werror --durations=0"

runtests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ echo "Run test suites! "
55
# -Werror: warning as error
66
# --durations=0: show ranking of test durations
77
# -l (--showlocals); show local variables when test failed
8-
pytest tests -l -Werror --durations=0
8+
pytest -n auto tests -l -Werror --durations=0

tests/test_state_lattice_planner.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import conftest # Add root path to sys.path
22
from PathPlanning.StateLatticePlanner import state_lattice_planner as m
3-
from PathPlanning.ModelPredictiveTrajectoryGenerator \
4-
import model_predictive_trajectory_generator as m2
53

64

75
def test1():
86
m.show_animation = False
9-
m2.show_animation = False
107
m.main()

0 commit comments

Comments
 (0)