Skip to content

Commit

Permalink
added support for EXPECT_EXIT_CODE
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias-luedtke committed Jan 16, 2017
1 parent 0aaac72 commit 3daabfa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ env:
- ROS_DISTRO=indigo USE_DEB=true # Checking backup compatibility with UPSTREAM_WORKSPACE
- ROS_DISTRO=indigo USE_DEB=false # Checking backup compatibility with UPSTREAM_WORKSPACE
- ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-indigo-opencv3" VERBOSE_OUTPUT='false'
- ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' # This should fail (trying from a wrong distro).
- ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' EXPECT_EXIT_CODE=1 # This should fail (trying from a wrong distro).
- ROS_DISTRO=jade APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass.
- ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall # Testing arbitrary file name without ROS_DISTRO suffix. As of 6/3/2016 this fails due to https://github.com/ros-industrial/industrial_core/pull/144#issuecomment-223186764
- ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=warehouse_ros PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail (as of Apr 2016), to test the capability of capturing Prerelease Test failure.
Expand All @@ -50,7 +50,6 @@ matrix:
- env: ROS_DISTRO=indigo NOT_TEST_BUILD='true' NOT_TEST_INSTALL='true' POST_PROCESS='I_am_supposed_to_fail'
- env: ROS_DISTRO=indigo PRERELEASE=true PRERELEASE_REPONAME=industrial_core PRERELEASE_DOWNSTREAM_DEPTH=0
- env: ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file USE_DEB=true # Expected to fail. See https://github.com/ros-industrial/industrial_ci/pull/74
- env: ROS_DISTRO=indigo ADDITIONAL_DEBS="ros-hydro-opencv3" DEBUG_BASH='false' # This should fail (trying from a wrong distro).
- env: ROS_DISTRO=jade PRERELEASE=true PRERELEASE_REPONAME=warehouse_ros PRERELEASE_DOWNSTREAM_DEPTH=1 # Intended to fail (as of Apr 2016), to test the capability of capturing Prerelease Test failure.
- env: ROS_DISTRO=jade UPSTREAM_WORKSPACE=file ROSINSTALL_FILENAME=.ci.rosinstall

Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Note that some of these currently tied only to a single option, but we still lea
* `CATKIN_PARALLEL_JOBS` (default: -p4): Maximum number of packages to be built in parallel that is passed to underlining build tool. As of Jan 2016, this is only enabled with `catkin_tools`. See for more detail about `number of build jobs <http://catkin-tools.readthedocs.org/en/latest/verbs/catkin_build.html#controlling-the-number-of-build-jobs>`_ and `documentation of catkin_tools <https://catkin-tools.readthedocs.org/en/latest/verbs/catkin_build.html#full-command-line-interface>`_ that this env variable is passed to internally in `catkin-tools`.
* `CATKIN_PARALLEL_TEST_JOBS` (default: -p4): Maximum number of packages which could be examined in parallel during the test run. If not set it's filled by `ROS_PARALLEL_JOBS`.
* `CI_PARENT_DIR` (default: .ci_config): (NOT recommended to specify) This is the folder name that is used in downstream repositories in order to point to this repo.
* `EXPECT_EXIT_CODE` (default: 0): exit code must match this value for test to succeed
* `NOT_TEST_BUILD` (default: not set): If true, tests in `build` space won't be run.
* `NOT_TEST_INSTALL` (default: not set): If true, tests in `install` space won't be run.
* `PRERELEASE` (default: false): If `true`, run `Prerelease Test on docker that emulates ROS buildfarm <http://wiki.ros.org/bloom/Tutorials/PrereleaseTest/>`_. The usage of Prerelease Test feature is `explained more in this section <https://github.com/ros-industrial/industrial_ci/blob/add/dockerbased_prerelease/README.rst#optional-run-ros-prerelease-test>`_.
Expand Down
2 changes: 1 addition & 1 deletion industrial_ci/ci_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ ici_time_end # after_script

cd $TARGET_REPO_PATH # cd back to the repository's home directory with travis

# exit with code 0
ici_exit 0
26 changes: 24 additions & 2 deletions industrial_ci/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ function _end_fold_script {
echo "Previous Travis fold name not found. It might be either successful termination of the script, or wrong call. Skipping 'ici_time_end' anyway."
fi

if [ $exit_code -eq "1" ]; then trap - ERR; fi # Reset signal handler since the shell is about to exit.
if [ "$DEBUG_BASH" ] && [ "$DEBUG_BASH" == true ]; then set -x; fi
if [ $exit_code -ne "-1" ]; then exit $exit_code; fi
if [ $exit_code -ne "-1" ]; then ici_exit $exit_code; fi
}

#######################################
Expand Down Expand Up @@ -141,3 +140,26 @@ function success {
if [ $_exit_code -ne "-1" ] && [ $_exit_code -ne "0" ]; then echo "${_FUNC_MSG_PREFIX} error: arg _exit_code must be either empty, -1 or 0. Returning."; return; fi
_end_fold_script $_exit_code
}

#######################################
# exit function with handling for EXPECT_EXIT_CODE
#
# Globals:
# (None)
# Arguments:
# _exit_code (default: $?)
# Returns:
# (None)
#######################################
function ici_exit {
trap - ERR # Reset signal handler since the shell is about to exit.
_exit_code=${1:-$?} # If 1st arg is not passed, set last error code.
_exptected = ${EXPECT_EXIT_CODE:-0}
if [ "$_exit_code" == "${EXPECT_EXIT_CODE:-0}" ]; then
exit 0
elif [ "$_exit_code" == "0" ]; then # 0 was not expected
exit 1
fi

exit _exit_code
}

0 comments on commit 3daabfa

Please sign in to comment.