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

tools/ci: correcly report flake8 version. #10252

Merged
merged 2 commits into from
Aug 14, 2019
Merged
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
26 changes: 11 additions & 15 deletions dist/tools/ci/print_toolchain_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ get_cmd_version() {
return
fi

local cmd="$1"
if command -v "$cmd" 2>&1 >/dev/null; then
ver=$("$cmd" --version 2> /dev/null | head -n 1)
# some tools (eg. openocd) print version info to stderr
if [ -z "$ver" ]; then
ver=$("$cmd" --version 2>&1 | head -n 1)
fi
if [ -z "$ver" ]; then
ver="error"
fi
else
ver="missing"
VERSION_RAW=$( ($@ --version) 2>&1)
jcarrano marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Should this be "$@" instead of $@?
(combined with removing the quotes below at the get_cmd_version call for flake8

Suggested change
VERSION_RAW=$( ($@ --version) 2>&1)
VERSION_RAW=$( ("$@" --version) 2>&1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"$@" will treat "a b" as the name of a command instead of command a with argument b.

ERR=$?
VERSION=$(echo "$VERSION_RAW" | head -n 1)
Copy link
Member

Choose a reason for hiding this comment

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

it is more reliable to use printf %s "$VERSION_RAW" instead of echo to avoid getting strange outputs in certain situations, especially since $VERSION_RAW may contain anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has the head to make sure we get the fist line in commands that have more than one.


if [ $ERR -eq 127 ] ; then # 127 means command not found
VERSION="missing"
elif [ $ERR -ne 0 ] ; then
VERSION="error: ${VERSION}"
fi

printf "%s" "$ver"
printf "%s" "$VERSION"
}

get_define() {
Expand Down Expand Up @@ -115,16 +111,16 @@ for c in \
cmake \
cppcheck \
doxygen \
flake8 \
git \
make \
openocd \
python \
python2 \
python3 \
; do
printf "%23s: %s\n" "$c" "$(get_cmd_version $c)"
printf "%23s: %s\n" "$c" "$(get_cmd_version "${c}")"
done
printf "%23s: %s\n" "flake8" "$(get_cmd_version "python3 -Wignore -m flake8")"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
printf "%23s: %s\n" "flake8" "$(get_cmd_version "python3 -Wignore -m flake8")"
printf "%23s: %s\n" "flake8" "$(get_cmd_version python3 -Wignore -m flake8)"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above for $@.

printf "%23s: %s\n" "coccinelle" "$(get_cmd_version spatch)"

exit 0