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

simplify ccache integration #182

Merged
merged 3 commits into from
Jun 29, 2017
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ env:
- ROS_DISTRO=indigo PRERELEASE=true USE_MOCKUP='industrial_ci/mockups/failing_test' EXPECT_EXIT_CODE=1
- ROS_DISTRO=kinetic PRERELEASE=true PRERELEASE_REPONAME=industrial_ci
- ROS_DISTRO=indigo APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass.
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=debian
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file # Using default file name for ROSINSTALL_FILENAME
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=debian AFTER_SCRIPT='ccache 2> /dev/null && exit 1; [ "$?" = "127" ]'
# Using default file name for ROSINSTALL_FILENAME, test CCACHE, verify cache was filled
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file CCACHE_DIR=$HOME/.ccache AFTER_SCRIPT='num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand what the commands in AFTER_SCRIPT are doing.
Locally I get this, which seems not good..:

$ num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $num
files

Copy link
Member Author

@mathias-luedtke mathias-luedtke Jun 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally I get this, which seems not good..:

actually, that's correct behaviour ;)

$(ccache -s | grep "files in cache") -> select line from ccache stats
num=($(ccache -s | grep "files in cache")) -> define an array with the data (separated by whitespace), e.g. ["files", "in", "cache", 42] (python-syntax)
num[-1] -> selects the last entry of this array
(( num[-1] > 0 )) evaluates an arithmetic expression, the exit code is used as the actual test result

echo $num just prints the first item of the array. To print all you have to use echo "${num[@]}".
echo $? will print the exit code:

$ num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $?
0 # okay
$ num=($(CCACHE_DIR=/tmp ccache -s | grep "files in cache")) && (( num[-1] > 0 ))
$ echo $?
1 # error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My very bad...man (ba)sh is/will never be my friend...
Sounds good.

- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file USE_DEB=true # Expected to fail. See https://github.com/ros-industrial/industrial_ci/pull/74
- ROS_DISTRO=indigo UPSTREAM_WORKSPACE=https://raw.githubusercontent.com/ros-industrial/industrial_ci/master/.travis.rosinstall
- ROS_DISTRO=indigo USE_DEB=true # Checking backup compatibility with UPSTREAM_WORKSPACE
Expand Down