Skip to content

Commit 69d6ee7

Browse files
authored
Add a travis output filter (#4866)
* Use a travis-optimized output filter with xcpretty * Capture and show raw xcodebuild log on failure
1 parent d70d113 commit 69d6ee7

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

scripts/build.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,23 @@ fi
108108
function RunXcodebuild() {
109109
echo xcodebuild "$@"
110110

111-
xcodebuild "$@" | xcpretty; result=$?
111+
xcpretty_cmd=(xcpretty)
112+
if [[ -n "${TRAVIS:-}" ]]; then
113+
# The formatter argument takes a file location of a formatter.
114+
# The xcpretty-travis-formatter binary prints its location on stdout.
115+
xcpretty_cmd+=(-f $(xcpretty-travis-formatter))
116+
fi
117+
118+
xcodebuild "$@" | tee xcodebuild.log | "${xcpretty_cmd[@]}"; result=$?
112119
if [[ $result == 65 ]]; then
113120
echo "xcodebuild exited with 65, retrying" 1>&2
114121
sleep 5
115122

116-
xcodebuild "$@" | xcpretty; result=$?
123+
xcodebuild "$@" | tee xcodebuild.log | "${xcpretty_cmd[@]}"; result=$?
117124
fi
118125
if [[ $result != 0 ]]; then
126+
echo "xcodebuild exited with $result; raw log follows" 1>&2
127+
cat xcodebuild.log
119128
exit $result
120129
fi
121130
}

scripts/install_prereqs.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ function apt_install() {
6868
which "$program" >& /dev/null || sudo apt-get install "$package"
6969
}
7070

71+
function install_xcpretty() {
72+
gem install xcpretty
73+
if [[ -n "${TRAVIS:-}" ]]; then
74+
gem install xcpretty-travis-formatter
75+
fi
76+
}
77+
7178
secrets_installed=false
7279

7380
# Default values, if not supplied on the command line or environment
@@ -106,13 +113,13 @@ fi
106113
case "$project-$platform-$method" in
107114

108115
FirebasePod-iOS-xcodebuild)
109-
gem install xcpretty
116+
install_xcpretty
110117
bundle exec pod install --project-directory=CoreOnly/Tests/FirebasePodTest --repo-update
111118
;;
112119

113120
Auth-*)
114121
# Install the workspace for integration testing.
115-
gem install xcpretty
122+
install_xcpretty
116123
bundle exec pod install --project-directory=Example/Auth/AuthSample --repo-update
117124
;;
118125

@@ -139,12 +146,12 @@ case "$project-$platform-$method" in
139146
;;
140147

141148
InAppMessaging-*-xcodebuild)
142-
gem install xcpretty
149+
install_xcpretty
143150
bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
144151
;;
145152

146153
Firestore-*-xcodebuild | Firestore-*-fuzz)
147-
gem install xcpretty
154+
install_xcpretty
148155

149156
# The Firestore Podfile is multi-platform by default, but this doesn't work
150157
# with command-line builds using xcodebuild. The PLATFORM environment
@@ -174,7 +181,7 @@ case "$project-$platform-$method" in
174181
;;
175182

176183
SymbolCollision-*-xcodebuild)
177-
gem install xcpretty
184+
install_xcpretty
178185
bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
179186
;;
180187

0 commit comments

Comments
 (0)