Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tue-make-test and tue-make-test-result #682

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0
1.12.0
115 changes: 114 additions & 1 deletion setup/tue-functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -479,6 +591,7 @@ function _tue-make
}

complete -F _tue-make tue-make
complete -F _tue-make tue-make-test

# ----------------------------------------------------------------------------------------------------
# TUE-STATUS
Expand Down