ptest-python-pytest.bbclass 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. inherit ptest
  7. # Overridable configuration for the directory within the source tree
  8. # containing the pytest files
  9. PTEST_PYTEST_DIR ?= "tests"
  10. do_install_ptest() {
  11. # Check if the recipe provides its own version of run-ptest
  12. # If nothing exists in the SRC_URI, dynamically create a
  13. # run-test script of "last resort" that has the default
  14. # pytest behavior.
  15. #
  16. # Users can override this behavior by simply including a
  17. # custom script (run-ptest) in the source file list
  18. if [ ! -f "${UNPACKDIR}/run-ptest" ]; then
  19. cat > ${D}${PTEST_PATH}/run-ptest << EOF
  20. #!/bin/sh
  21. pytest --automake
  22. EOF
  23. # Ensure the newly created script has the execute bit set
  24. chmod 755 ${D}${PTEST_PATH}/run-ptest
  25. fi
  26. if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then
  27. install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}
  28. cp -rf ${S}/${PTEST_PYTEST_DIR}/* ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}/
  29. fi
  30. }
  31. FILES:${PN}-ptest:prepend = "${PTEST_PATH}/*"
  32. RDEPENDS:${PN}-ptest:prepend = "python3-pytest python3-unittest-automake-output "