Skip to content

Instantly share code, notes, and snippets.

@notjosh
Last active January 25, 2016 18:38
Show Gist options
  • Save notjosh/1ef61af220d3fe15ac75 to your computer and use it in GitHub Desktop.
Save notjosh/1ef61af220d3fe15ac75 to your computer and use it in GitHub Desktop.
spacecommander build formatter, that creates JUnit-ish output from piped `format-objc-mobuild` command output for Jenkins to consume, and GitHub pull request builder to show
#!/bin/bash
files=($(grep -o "git add '.*';$" | awk -F "'" '{print $2}'))
count=${#files[@]}
timestamp=$(date +%Y-%m-%dT%H:%M:%S%z)
cat <<EOT
<testsuites>
<testsuite name="[ Space Commander]" tests="$count" failures="$count" timestamp="$timestamp">
EOT
for ((i = 0; i != count; i++)); do
file=${files[i]}
cat <<EOT
<testcase name="/$(basename $file)" classname="$(dirname $file)/">
<error message="File not formatted">File '$file' has formatting problems.</error>
</testcase>
EOT
done
if [ $count -eq 0 ]; then
cat <<EOT
<testcase name="/dummy" classname="dummy/" />
EOT
fi
cat <<EOT
</testsuite>
</testsuites>
EOT
exit $count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment