# Usage: failed-plugins.sh <plugin>...
#
# Run this after `cmake -P run.cmake <plugin>...`. run.cmake keeps
# going after a plugin fails (it uses message(SEND_ERROR ...), not
# FATAL_ERROR), so a single invocation can leave a mix of built and
# failed plugins behind.
#
# Prints, space-separated, the plugins from the given list that did
# NOT end up with a package under <plugin>.build/ — i.e. the ones
# that failed to build and should be excluded from MTR's --suite
# list, since MTR aborts the entire run if any listed suite doesn't
# exist.
#
# Note: this only works on a fresh build workspace. A leftover
# package from an earlier successful build would be mistaken for a
# success even if the current build failed.

for p in "$@"; do
  b="$p.build"
  found=
  for f in "$b"/*.rpm "$b"/*.deb "$b"/*.tar.gz; do
    [ -e "$f" ] && found=1
  done
  [ -z "$found" ] && printf '%s ' "$p"
done
echo
