Skip to content

Commit 9ef417d

Browse files
committed
all: Refactor tests significantly
This lets us use different profiles for different tests. It also lets us put all tests for a particular plugin in it's own directory and makes it easier for users to see how to write tests for their own plugins not hosted here.
1 parent 1f6c907 commit 9ef417d

File tree

85 files changed

+650
-2446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+650
-2446
lines changed

.github/workflows/build-cloe.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
run: |
5555
make -f Makefile.all export-vendor &&
5656
make ${{ matrix.package_target }}
57+
- name: Build smoketest dependencies
58+
run: |
59+
make smoketest-deps
5760
- name: Run smoketests
5861
run: |
5962
make smoketest

.lvimrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ augroup rstsettings
1515
autocmd Filetype rst set tw=79 cc=80
1616
augroup end
1717

18+
if &filetype == "json"
19+
setlocal filetype=json5
20+
syntax off
21+
syntax on
22+
endif
23+
1824
doau Filetype
1925

2026
" Define AddPackageToPath function that can be used

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ include Makefile.setup
4141
include Makefile.all
4242

4343
# Workspace targets -----------------------------------------------------------
44-
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all smoketest
44+
.PHONY: lockfile status deploy sphinx doxygen docker-all docker-test docker-release purge-all smoketest smoketest-deps
4545
help::
4646
echo "Available workspace targets:"
4747
echo " smoketest to run BATS system tests"
@@ -98,11 +98,11 @@ doxygen:
9898
mkdir -p ${BUILD_DIR}/doxygen
9999
doxygen Doxyfile
100100

101-
smoketest:
101+
smoketest-deps: smoketest-deps-select
102+
# Call this target with WITH_VTD=1 to include VTD binding tests.
103+
104+
smoketest: smoketest-select
102105
# Call this target with WITH_VTD=1 to include VTD binding tests.
103-
$(call print_header, "Running smoke tests...")
104-
@${CLOE_LAUNCH} clean -P conantest.py
105-
@\time -f "\nTotal smoketest time (real) = %e sec" bash -c "source tests/setup_testname.bash && bats tests"
106106

107107
purge-all:
108108
$(call print_header, "Removing all cloe Conan packages...")

Makefile.all

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ $(filter-out cloe, ${ALL_PKGS} ${ALL_VENDOR_PKGS}):
130130
# Re-define cloe target to use Makefile.package, and only run for targets
131131
# where it makes sense, since "cloe" is a Conan meta-package.
132132
cloe:
133-
for case in export package package-outdated list purge clean; do \
134-
if [[ "$$(echo '${MAKECMDGOALS}' | sed -re ${REGEX_TARGET})" == "$${case}" ]]; then \
133+
for case in export package package-outdated list purge clean smoketest smoketest-deps; do \
134+
if [ "$$(echo '${MAKECMDGOALS}' | sed -re ${REGEX_TARGET})" == "$${case}" ]; then \
135135
${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS}" $${case} || exit 1; \
136136
fi \
137137
done
@@ -262,6 +262,9 @@ $(call make_select_target, package-select, "create selected packages with po
262262
$(call make_select_target, list-select, "list selected package install files [conan-cache]")
263263
$(call make_select_target, purge-select, "remove selected packages from cache [conan-cache]")
264264

265+
$(call make_select_target, smoketest-select, "run tests for selected packages [conan-cache]")
266+
$(call make_select_target, smoketest-deps-select, "build test deps for selected packages [conan-cache]")
267+
265268
help::
266269
echo
267270

Makefile.package

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
PROJECT_ROOT := $(dir $(abspath $(lastword ${MAKEFILE_LIST})))
1919
PROJECT_VERSION := $(shell [ -r ${PROJECT_ROOT}/VERSION ] && cat ${PROJECT_ROOT}/VERSION || echo unknown)
2020

21+
CLOE_ROOT := ${PROJECT_ROOT}
22+
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
23+
24+
SHELL := /bin/bash
2125
DATE := $(shell date +"%Y%m%d")
2226
TIMESTAMP := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
2327

@@ -115,18 +119,20 @@ endif
115119

116120
# INFORMATIONAL TARGETS -------------------------------------------------------
117121
.DEFAULT: help
118-
.SILENT: help status parse-info parse-editable info-name info-version info-channel info-fqn info
119-
.PHONY: help status parse-info parse-editable info-name info-version info-channel info-fqn info
122+
.SILENT: help status parse-info parse-editable info-name info-version info-channel info-fqn info smoketest smoketest-deps
123+
.PHONY: help status parse-info parse-editable info-name info-version info-channel info-fqn info smoketest smoketest-deps
120124
help:: parse-info parse-editable
121125
echo "Usage: make <target>"
122126
echo
123127
echo "The following targets define common operations with this package in"
124128
echo "editable (local in-source) and uneditable (in the Conan cache) modes."
125129
echo
126130
echo "Available targets:"
127-
echo " help to show this help"
128-
echo " status to show status of package"
129-
echo " info to show detailed package info"
131+
echo " help to show this help"
132+
echo " status to show status of package"
133+
echo " info to show detailed package info"
134+
echo " smoketest-deps to build smoketest dependencies for package"
135+
echo " smoketest to run smoketests for package (requires built packages)"
130136
echo
131137
echo " export to export recipe and sources [conan-cache]"
132138
echo " download to download or create package [conan-cache]"
@@ -218,6 +224,20 @@ info: parse-info
218224
echo ${PACKAGE_INFO}; \
219225
fi
220226

227+
smoketest:
228+
@for profile in tests/profile_*.py; do \
229+
test -f "$${profile}" || continue; \
230+
printf "Running BATS tests with profile: $${profile}\n\n"; \
231+
SHELL=/bin/bash ${CLOE_LAUNCH} shell -P "$${profile}" -- -c "source ${CLOE_ROOT}/tests/setup_testname.bash; bats tests"; \
232+
done
233+
234+
smoketest-deps:
235+
@for profile in tests/profile_*.py; do \
236+
test -f "$${profile}" || continue; \
237+
echo "Building dependencies for profile: $${profile}"; \
238+
${CLOE_LAUNCH} prepare -P "$${profile}"; \
239+
done
240+
221241
# CONFIGURATION TARGETS -------------------------------------------------------
222242
.PHONY: editable uneditable
223243

dist/docker/Dockerfile.archlinux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RUN --mount=type=cache,target=/ccache \
6767
# Build Cloe.
6868
COPY . /cloe
6969
ARG PROJECT_VERSION=unknown
70-
ARG PACKAGE_TARGET=package-auto
70+
ARG PACKAGE_TARGET="package-auto smoketest-deps"
7171
RUN --mount=type=cache,target=/ccache \
7272
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
7373
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \

dist/docker/Dockerfile.bionic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ RUN --mount=type=cache,target=/ccache \
6868
# Build Cloe.
6969
COPY . /cloe
7070
ARG PROJECT_VERSION=unknown
71-
ARG PACKAGE_TARGET=package-auto
71+
ARG PACKAGE_TARGET="package-auto smoketest-deps"
7272
RUN --mount=type=cache,target=/ccache \
7373
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
7474
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \

dist/docker/Dockerfile.focal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN --mount=type=cache,target=/ccache \
8585
# Build Cloe.
8686
COPY . /cloe
8787
ARG PROJECT_VERSION=unknown
88-
ARG PACKAGE_TARGET=package-auto
88+
ARG PACKAGE_TARGET="package-auto smoketest-deps"
8989
RUN --mount=type=cache,target=/ccache \
9090
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
9191
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \

dist/docker/Dockerfile.xenial

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ RUN --mount=type=cache,target=/ccache \
120120
# Build Cloe.
121121
COPY . /cloe
122122
ARG PROJECT_VERSION=unknown
123-
ARG PACKAGE_TARGET=package-auto
123+
ARG PACKAGE_TARGET="package-auto smoketest-deps"
124124
RUN --mount=type=cache,target=/ccache \
125125
--mount=type=secret,target=/root/setup.sh,id=setup,mode=0400 \
126126
if [ -r /root/setup.sh ]; then . /root/setup.sh; fi && \

engine/tests/config_nop_infinite.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"version": "4",
3+
"include": [
4+
"controller_virtue.json",
5+
"controller_basic.json"
6+
],
7+
"simulators": [
8+
{
9+
"binding": "nop"
10+
}
11+
],
12+
"vehicles": [
13+
{
14+
"name": "default",
15+
"from": {
16+
"simulator": "nop",
17+
"index": 0
18+
},
19+
"components": {
20+
"cloe::speedometer": {
21+
"binding": "speedometer",
22+
"name": "default_speed",
23+
"from": "cloe::gndtruth_ego_sensor"
24+
},
25+
"cloe::default_world_sensor": {
26+
"binding": "noisy_object_sensor",
27+
"name": "noisy_object_sensor",
28+
"from": "cloe::default_world_sensor",
29+
"args": {
30+
"noise": [
31+
{
32+
"target": "translation",
33+
"distribution": {
34+
"binding": "normal",
35+
"mean": 0.0,
36+
"std_deviation": 0.3
37+
}
38+
}
39+
]
40+
}
41+
}
42+
}
43+
}
44+
]
45+
}

0 commit comments

Comments
 (0)