-
Notifications
You must be signed in to change notification settings - Fork 27
Log build steps in the outcome file #129
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
base: main
Are you sure you want to change the base?
Changes from all commits
0560e56
ef8d12d
a5a28ed
4ce986e
a11f2eb
e71d3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,90 @@ NO_SILENCE=" --version | test " | |
TOOL="make" | ||
|
||
. "$(dirname "$0")/quiet.sh" | ||
EXIT_STATUS=$? | ||
|
||
log_outcome () { | ||
# Options passed to make indicating that a different makefile is used | ||
modifier= | ||
# Space-separated list of targets | ||
targets= | ||
# Temporary variable used in the loop after an option that takes an argument | ||
skip= | ||
|
||
for arg in "$@"; do | ||
if [ -n "$skip" ]; then | ||
if [ "$skip" = "modifier" ]; then | ||
modifier="$modifier$arg " | ||
fi | ||
skip= | ||
continue | ||
fi | ||
|
||
case $arg in | ||
--dry-run|--help|--just-print|--question|--recon|--version|-n|-q|-v) | ||
# do-nothing option | ||
return;; | ||
--directory=*|--file=*|-C?*|-f?*) # Modifier option with its argument | ||
modifier="$modifier$arg ";; | ||
--directory|--file|-C|-f) # Modifier option with separate argument | ||
skip=modifier | ||
modifier="$modifier$arg ";; | ||
--assume-new|--assume-old| \ | ||
--include-dir|--makefile|--new-file|--old-file|--what-if| \ | ||
-I|-W|-k|-o) # Boring option with separate argument | ||
skip=1; continue;; | ||
-*) continue;; # Other option (assumed boring) | ||
*=*) continue;; # Variable assignment | ||
*[!-+./0-9@A-Z_a-z]*) # Target with problematic character | ||
targets="$targets ${arg%%[!-+./0-9@A-Z_a-z]*}...";; | ||
*) # Normal target | ||
targets="$targets $arg";; | ||
esac | ||
done | ||
|
||
if [ -n "$MBEDTLS_TEST_ROOT" ] && [ "$MBEDTLS_TEST_ROOT" != "$PWD" ]; then | ||
# Record that `make` was run in a different directory. | ||
# This is only accurate when run by all.sh (or more generally | ||
# if $MBEDTLS_TEST_ROOT is set in the environment). | ||
case "$PWD" in | ||
"$MBEDTLS_TEST_ROOT/"*) modifier="-C ${PWD#"${MBEDTLS_TEST_ROOT}/"} $modifier";; | ||
*) modifier="-C $PWD $modifier";; | ||
esac | ||
fi | ||
|
||
if [ -n "$targets" ]; then | ||
targets=${targets# } | ||
else | ||
# Assume that the default target is "all". This is true for | ||
# the toplevel Makefile and when using CMake, but might not be | ||
# true when using a different makefile. | ||
targets=all | ||
fi | ||
|
||
# We have a single pass/fail status. This is not accurate when there are | ||
# multiple targets: it's possible that some passed and some failed. | ||
# To figure out which targets passed when the overall result is a failure, | ||
# we'd have to do some complex parsing of logs. | ||
if [ $EXIT_STATUS -eq 0 ]; then | ||
result=PASS | ||
else | ||
result=FAIL | ||
fi | ||
cause= # Identifying failure causes would be nice, but difficult | ||
|
||
for target in $targets; do | ||
case "$target" in | ||
"clean"|"neat") continue;; # Boring | ||
cmTC_*) continue;; # Weirdness from CMake | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are temporary target files that will be cleaned up. So the logic is sound. It is not obscure but standard even though unfortunately undocumented behavior from cmake. ;( |
||
esac | ||
echo >>"${MBEDTLS_TEST_OUTCOME_FILE}" \ | ||
"${MBEDTLS_TEST_PLATFORM};${MBEDTLS_TEST_CONFIGURATION};${TOOL};${target};${result};${cause}" | ||
done | ||
} | ||
|
||
if [ -n "${MBEDTLS_TEST_OUTCOME_FILE}" ] && | ||
[ -n "${MBEDTLS_TEST_CONFIGURATION}" ]; then | ||
log_outcome "$@" | ||
fi | ||
|
||
exit $EXIT_STATUS |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ fi | |
|
||
if [[ " $@ " =~ $NO_SILENCE || -n "${VERBOSE_LOGS}" ]]; then | ||
# Run original command with no output supression | ||
exec "${ORIGINAL_TOOL}" "$@" | ||
"${ORIGINAL_TOOL}" "$@" | ||
else | ||
# Run original command and capture output & exit status | ||
TMPFILE=$(mktemp "quiet-${TOOL}.XXXXXX") | ||
|
@@ -75,5 +75,6 @@ else | |
rm "${TMPFILE}" | ||
|
||
# Propagate the exit status | ||
exit $EXIT_STATUS | ||
set_status () { return $1; } | ||
set_status $EXIT_STATUS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the indirection? If we want to preserve the status, could't we just return "EXIT_STATUS" ? What am I missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note that in sh, there is no language feature to return early from a sub-script sourced with the |
||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are both "--directory=somedir" and "--directory somedir" required?
For example would passing "--directory" and nothing else assert
skip=1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
--directory=...
, we want to remember the option and move on to the next argument which is another option or a non-option argument. With--directory
, we want to skip the next argument, which is the argument of the--directory
option.make --directory
is invalid. I don't know what the code here does in this case, but I don't think this wrapper needs to care about invalid usage ofmake
.