diff --git a/VERSION b/VERSION index 1cac385c6..0eed1a29e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.0 +1.12.0 diff --git a/setup/tue-functions.bash b/setup/tue-functions.bash index 894b0329e..065a39ac7 100644 --- a/setup/tue-functions.bash +++ b/setup/tue-functions.bash @@ -446,7 +446,7 @@ function tue-make touch "$TUE_SYSTEM_DIR"/devel/.catkin # hack to allow overlaying to this ws while being empty ;; *) - echo -e "\e$build_tool is not supported (anymore), use catkin tools\e[0m" + echo -e "\e[31;1mError! ${build_tool} is not supported (anymore), use catkin tools\e[0m" return 1 ;; esac @@ -470,6 +470,118 @@ function tue-make } export -f tue-make +function tue-make-test +{ + [[ -z "${TUE_ROS_DISTRO}" ]] && { echo -e "\e[31;1mError! tue-env variable TUE_ROS_DISTRO not set.\e[0m"; return 1; } + + [[ -z "${TUE_ROS_VERSION}" ]] && { echo -e "\e[31;1mError! TUE_ROS_VERSION is not set.\nSet TUE_ROS_VERSION before executing this function.\e[0m"; return 1; } + + [[ ! -d "${TUE_SYSTEM_DIR}" ]] && { echo -e "\e[31;1mError! The workspace '${TUE_SYSTEM_DIR}' does not exist. Run 'tue-get install ros${TUE_ROS_VERSION}' first.\e[0m"; return 1; } + + if [ "${TUE_ROS_VERSION}" == "1" ] + then + local build_tool + build_tool="" + if [ -f "${TUE_SYSTEM_DIR}"/build/.built_by ] + then + build_tool=$(cat "${TUE_SYSTEM_DIR}"/build/.built_by) + fi + case ${build_tool} in + 'catkin build') + catkin test --workspace "${TUE_SYSTEM_DIR}" "$@" + return $? + ;; + '') + echo -e "\e[31;1mError! First initialize the workspace and build it, i.e. using tue-make, before running tests\e[0m" + return 1 + ;; + *) + echo -e "\e[31;1mError! ${build_tool} is not supported (anymore), use catkin tools\e[0m" + return 1 + ;; + esac + elif [ "${TUE_ROS_VERSION}" == "2" ] + then + if [[ ! -d "${TUE_SYSTEM_DIR}"/src ]] + then + echo -e "\e[31;1mError! No 'src' directory exists in the workspace '${TUE_SYSTEM_DIR}'\e[0m" + return 1 + fi + + if [[ ! -d "${TUE_SYSTEM_DIR}"/build ]] + then + echo -e "\e[31;1mError! No 'build' directory exists in the workspace '${TUE_SYSTEM_DIR}'. Build the workspace before running tests\e[0m" + return 1 + fi + + # Disable symlink install for production + if [ "${CI_INSTALL}" == "true" ] + then + colcon --log-base "${TUE_SYSTEM_DIR}"/log test --base-paths "${TUE_SYSTEM_DIR}"/src --build-base "${TUE_SYSTEM_DIR}"/build --install-base "${TUE_SYSTEM_DIR}"/install --executor sequential --event-handlers console_cohesion+ "$@" + else + colcon --log-base "${TUE_SYSTEM_DIR}"/log test --merge-install --base-paths "${TUE_SYSTEM_DIR}"/src --build-base "${TUE_SYSTEM_DIR}"/build --install-base "${TUE_SYSTEM_DIR}"/install --executor sequential --event-handlers console_cohesion+ "$@" + fi + return $? + else + echo -e "\e[31;1mError! ROS_VERSION '${TUE_ROS_VERSION}' is not supported by tue-env.\e[0m" + return 1 + fi +} +export -f tue-make-test + +function tue-make-test-result +{ + [[ -z "${TUE_ROS_DISTRO}" ]] && { echo -e "\e[31;1mError! tue-env variable TUE_ROS_DISTRO not set.\e[0m"; return 1; } + + [[ -z "${TUE_ROS_VERSION}" ]] && { echo -e "\e[31;1mError! TUE_ROS_VERSION is not set.\nSet TUE_ROS_VERSION before executing this function.\e[0m"; return 1; } + + [[ ! -d "${TUE_SYSTEM_DIR}" ]] && { echo -e "\e[31;1mError! The workspace '${TUE_SYSTEM_DIR}' does not exist. Run 'tue-get install ros${TUE_ROS_VERSION}' first.\e[0m"; return 1; } + + if [ "${TUE_ROS_VERSION}" == "1" ] + then + local build_tool + build_tool="" + if [ -f "$TUE_SYSTEM_DIR"/build/.built_by ] + then + build_tool=$(cat "$TUE_SYSTEM_DIR"/build/.built_by) + fi + case $build_tool in + 'catkin build') + catkin test_results "${TUE_SYSTEM_DIR}"/build "$@" + return $? + ;; + '') + echo -e "\e[31;1mError! First initialize the workspace and build it, i.e. using tue-make, before running tests and checking the test results\e[0m" + return 1 + ;; + *) + echo -e "\e[31;1mError! ${build_tool} is not supported (anymore), use catkin tools\e[0m" + return 1 + ;; + esac + elif [ "${TUE_ROS_VERSION}" == "2" ] + then + if [[ ! -d "${TUE_SYSTEM_DIR}"/src ]] + then + echo -e "\e[31;1mError! No 'src' directory exists in the workspace '${TUE_SYSTEM_DIR}'\e[0m" + return 1 + fi + + if [[ ! -d "${TUE_SYSTEM_DIR}"/build ]] + then + echo -e "\e[31;1mError! No 'build' directory exists in the workspace '${TUE_SYSTEM_DIR}'. Build the workspace, run tests before checking test results\e[0m" + return 1 + fi + + colcon --log-base "${TUE_SYSTEM_DIR}"/log test-result --test-result-base "${TUE_SYSTEM_DIR}"/build "$@" + return $? + else + echo -e "\e[31;1mError! ROS_VERSION '${TUE_ROS_VERSION}' is not supported by tue-env.\e[0m" + return 1 + fi +} +export -f tue-make-test-result + function _tue-make { local cur @@ -479,6 +591,7 @@ function _tue-make } complete -F _tue-make tue-make +complete -F _tue-make tue-make-test # ---------------------------------------------------------------------------------------------------- # TUE-STATUS