use pytest for cpp tests (#29833)

* add pytest-cpp package (#29828)

* add pytest-cpp package

* disable for now

* use in ci

* use pytest cpp

* use my branch

* add missing tests

* that doesn't make sense

* it was merged upstream

* replace TEST_RLOG_URL with a publicly accessible url

* PR Cleanup

* assert instead

* update poetry lock

* add comment about  pytest-cpp

---------

Co-authored-by: Justin Newberry <jnewberry0502@gmail.com>
Co-authored-by: Justin Newberry <justin@comma.ai>
Co-authored-by: deanlee <deanlee3@gmail.com>
old-commit-hash: 2c1dfc2f341b09381af2cc7872c4092df28dc9d5
This commit is contained in:
Adeeb Shihadeh
2023-09-11 14:01:50 -07:00
committed by GitHub
parent 5bac1f771c
commit 1f8459d285
6 changed files with 11 additions and 15 deletions

View File

@@ -263,18 +263,11 @@ jobs:
timeout-minutes: 40
run: |
${{ env.RUN }} "export SKIP_LONG_TESTS=1 && \
$PYTEST -n auto --dist=loadscope --timeout 30 && \
$PYTEST -n auto --dist=loadscope --timeout 30 -o cpp_files=test_* && \
selfdrive/locationd/test/_test_locationd_lib.py && \
./system/ubloxd/tests/test_glonass_runner && \
./selfdrive/ui/tests/create_test_translations.sh && \
QT_QPA_PLATFORM=offscreen ./selfdrive/ui/tests/test_translations && \
./selfdrive/ui/tests/test_translations.py && \
./common/tests/test_common && \
./selfdrive/boardd/tests/test_boardd_usbprotocol && \
./system/loggerd/tests/test_logger &&\
./system/proclogd/tests/test_proclog && \
./tools/replay/tests/test_replay && \
./tools/cabana/tests/test_cabana && \
./system/camerad/test/ae_gray_test && \
./selfdrive/test/process_replay/test_fuzzy.py"
- name: "Upload coverage to Codecov"

BIN
poetry.lock LFS generated

Binary file not shown.

View File

@@ -1,6 +1,7 @@
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--ignore=openpilot/ --ignore=cereal/ --ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=laika_repo/ -Werror --strict-config --strict-markers --durations=10"
#cpp_files = "test_*" # uncomment when agnos has pytest-cpp and remove from CI
python_files = "test_*.py"
#timeout = "30" # you get this long by default
markers = [
@@ -18,9 +19,12 @@ testpaths = [
"selfdrive/test/longitudinal_maneuvers",
"system/hardware/tici",
"system/loggerd",
"system/proclogd",
"system/tests",
"system/ubloxd",
"tools/lib/tests"
"tools/lib/tests",
"tools/replay",
"tools/cabana"
]
[tool.mypy]
@@ -142,6 +146,7 @@ pygame = "*"
pyprof2calltree = "*"
pytest = "*"
pytest-cov = "*"
pytest-cpp = "*"
pytest-subtests = "*"
pytest-xdist = "*"
pytest-timeout = "*"

View File

@@ -97,7 +97,7 @@ TEST_CASE("logger") {
auto logging_thread = [&]() -> void {
LoggerHandle *lh = logger_get_handle(&logger);
REQUIRE(lh != nullptr);
assert(lh != nullptr);
int segment = main_segment;
int delayed_cnt = 0;
while (!do_exit) {

View File

@@ -140,7 +140,6 @@ TEST_CASE("buildProcLogerMessage") {
REQUIRE(p.getName() == "test_proclog");
REQUIRE(p.getState() == 'R');
REQUIRE_THAT(p.getExe().cStr(), Catch::Matchers::Contains("test_proclog"));
REQUIRE(p.getCmdline().size() == 1);
REQUIRE_THAT(p.getCmdline()[0], Catch::Matchers::Contains("test_proclog"));
} else {
std::string cmd_path = "/proc/" + std::to_string(p.getPid()) + "/cmdline";

View File

@@ -6,8 +6,7 @@
#include "tools/cabana/dbc/dbcmanager.h"
#include "tools/cabana/streams/abstractstream.h"
// demo route, first segment
const std::string TEST_RLOG_URL = "https://commadata2.blob.core.windows.net/commadata2/a2a0ccea32023010/2023-07-27--13-01-19/0/rlog.bz2";
const std::string TEST_RLOG_URL = "https://commadataci.blob.core.windows.net/openpilotci/0c94aa1e1296d7c6/2021-05-05--19-48-37/0/rlog.bz2";
TEST_CASE("DBCFile::generateDBC") {
QString fn = QString("%1/%2.dbc").arg(OPENDBC_FILE_PATH, "tesla_can");