From a4f691b88a1e43dce8812b82dd479b2f62f4aaad Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 16 Apr 2024 14:11:31 +0200 Subject: [PATCH] ci: always cleanup idf copy in ci --- .gitlab/ci/build.yml | 8 ++++++-- tools/test_build_system/conftest.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index 1bea0af01d..0844f420b2 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -194,8 +194,12 @@ build_clang_test_apps_esp32c6: - ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh - cd ${IDF_PATH}/tools/test_build_system - python ${IDF_PATH}/tools/ci/get_known_failure_cases_file.py - - pytest --parallel-count ${CI_NODE_TOTAL:-1} --parallel-index ${CI_NODE_INDEX:-1} - --work-dir ${CI_PROJECT_DIR}/test_build_system --junitxml=${CI_PROJECT_DIR}/XUNIT_RESULT.xml + - pytest + --cleanup-idf-copy + --parallel-count ${CI_NODE_TOTAL:-1} + --parallel-index ${CI_NODE_INDEX:-1} + --work-dir ${CI_PROJECT_DIR}/test_build_system + --junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml --ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME} pytest_build_system: diff --git a/tools/test_build_system/conftest.py b/tools/test_build_system/conftest.py index 16fe7cd75a..fbfc97c053 100644 --- a/tools/test_build_system/conftest.py +++ b/tools/test_build_system/conftest.py @@ -31,7 +31,7 @@ def pytest_runtest_makereport(item: typing.Any, call: typing.Any) -> typing.Gene def should_clean_test_dir(request: FixtureRequest) -> bool: # Only remove the test directory if the test has passed - return getattr(request.node, 'passed', False) + return getattr(request.node, 'passed', False) or request.config.getoption('cleanup_idf_copy', False) def pytest_addoption(parser: pytest.Parser) -> None: @@ -40,6 +40,10 @@ def pytest_addoption(parser: pytest.Parser) -> None: help='Directory for temporary files. If not specified, an OS-specific ' 'temporary directory will be used.' ) + parser.addoption( + '--cleanup-idf-copy', action='store_true', + help='Always clean up the IDF copy after the test. By default, the copy is cleaned up only if the test passes.' + ) @pytest.fixture(scope='session')