1#!/bin/bash
2#
3# This script lists the tests which are failing in the output of Robolectric
4# tests.
5# TODO: Remove this script and move the functionality into a custom JUnit runner.
6
7# Matches the line specifying which test has failed and matches the test name
8# and class name as the first and second matching group, respectively.
9readonly FAILED_TEST_RE='^[1-9][0-9]*)\s\(\w\+\)(\(\(\w\|.\)\+\))$'
10
11# Fails with a message.
12function fatal() {
13  echo 1>&2 "FATAL: $@"
14  exit 113
15}
16
17function main() {
18  test $# = 0 || fatal "Too many arguments: $@"
19
20  sed -e '1,/^There \(was 1 failure\|were [0-9]* failures\):$/d' |
21      grep "$FAILED_TEST_RE" |
22      sed -e "s/$FAILED_TEST_RE/\2.\1/" ||
23      true
24}
25
26set -e
27set -o pipefail
28main "$@"
29