Skip to content

Commit

Permalink
Propagate exit code in test_objc (facebook#22562)
Browse files Browse the repository at this point in the history
Summary:
Any failures in `test_objc` within the objc-test.sh script have been kept hidden as `xcpretty` was swallowing the exit code from xcodebuild.

Fixes the issue TheSavior brought up in facebook#22470 where failing snapshot tests were not reflected on Circle.

Run on Circle CI and confirm `test_objc` fails (iOS tests *are* broken on master).
Pull Request resolved: facebook#22562

Differential Revision: D13406987

Pulled By: hramos

fbshipit-source-id: 3f3da01ab4c0ad87077813b06d2fdf788f32f6b8
  • Loading branch information
hramos authored and grabbou committed Dec 17, 2018
1 parent ba4bab1 commit 4f43d3c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
8 changes: 1 addition & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ aliases:
- &boot-simulator-iphone
name: Boot iPhone Simulator
command: xcrun simctl boot "iPhone 5s" || true
command: xcrun simctl boot "iPhone XS" || true

- &boot-simulator-appletv
name: Boot Apple TV Simulator
Expand Down Expand Up @@ -430,12 +430,6 @@ jobs:
- run: *run-objc-ios-tests
- run: *run-objc-tvos-tests

# TODO: Fix these failing tests.
- run: *display-broken-tests-warning
- run: *run-podspec-tests
- run: *run-objc-ios-e2e-tests
- run: *run-objc-tvos-e2e-tests

- store_test_results:
path: ~/react-native/reports/junit

Expand Down
9 changes: 3 additions & 6 deletions scripts/.tests.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ export AVD_NAME="testAVD"
export AVD_ABI=x86

## IOS ##
export IOS_TARGET_OS="11.4"
export IOS_DEVICE="iPhone 5s"

export SCHEME="RNTester"
export SDK="iphonesimulator${IOS_TARGET_OS}"
export DESTINATION="platform=iOS Simulator,OS=${IOS_TARGET_OS},name=${IOS_DEVICE}"
export IOS_TARGET_OS="12.1"
export IOS_DEVICE="iPhone XS"
export TVOS_DEVICE="Apple TV"

## CI OVERRIDES ##
# Values to override when running in CI
Expand Down
9 changes: 6 additions & 3 deletions scripts/objc-test-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree.
#
# Script used to run iOS tests.
# If not arguments are passed to the script, it will only compile
# If no arguments are passed to the script, it will only compile
# the RNTester.
# If the script is called with a single argument "test", we'll
# also run the RNTester integration test (needs JS and packager):
Expand All @@ -18,10 +18,13 @@ ROOT=$(dirname "$SCRIPTS")

cd "$ROOT"

# shellcheck disable=SC1091
source "scripts/.tests.env"

export TEST_NAME="iOS"
export SCHEME="RNTester"
export SDK="iphonesimulator"
export DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=11.4"
export DESTINATION="platform=iOS Simulator,name=${IOS_DEVICE},OS=${IOS_TARGET_OS}"

# If there's a "test" argument, pass it to the test script.
. ./scripts/objc-test.sh $1
./scripts/objc-test.sh $1
12 changes: 11 additions & 1 deletion scripts/objc-test-tvos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree.
#
# Script used to run tvOS tests.
# If not arguments are passed to the script, it will only compile
# If no arguments are passed to the script, it will only compile
# the RNTester.
# If the script is called with a single argument "test", we'll
# also run the RNTester integration test (needs JS and packager):
Expand All @@ -18,11 +18,21 @@ ROOT=$(dirname "$SCRIPTS")

cd "$ROOT"

# shellcheck disable=SC1091
source "scripts/.tests.env"

export TEST_NAME="tvOS"
export SCHEME="RNTester-tvOS"
export SDK="appletvsimulator"
<<<<<<< HEAD
export DESTINATION="platform=tvOS Simulator,name=Apple TV,OS=11.4"

# If there's a "test" argument, pass it to the test script.
. ./scripts/objc-test.sh $1

=======
export DESTINATION="platform=tvOS Simulator,name=${TVOS_DEVICE},OS=${IOS_TARGET_OS}"

# If there's a "test" argument, pass it to the test script.
./scripts/objc-test.sh $1
>>>>>>> 5194495e97... Propagate exit code in test_objc (#22562)
21 changes: 11 additions & 10 deletions scripts/objc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ set -ex
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname $SCRIPTS)

cd $ROOT
cd "$ROOT"

# Create cleanup handler
function cleanup {
EXIT_CODE=$?
EXIT=$?
set +e

if [ $EXIT_CODE -ne 0 ];
if [ $EXIT -ne 0 ];
then
WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log
[ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS
[ -f "$WATCHMAN_LOGS" ] && cat "$WATCHMAN_LOGS"
fi
# kill whatever is occupying port 8081 (packager)
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
Expand Down Expand Up @@ -61,7 +61,7 @@ function waitForPackager {
if [ "$1" = "test" ]; then

# Start the packager
npm run start --max-workers=1 || echo "Can't start packager automatically" &
yarn start --max-workers=1 || echo "Can't start packager automatically" &
# Start the WebSocket test server
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"

Expand All @@ -80,20 +80,21 @@ rm temp.bundle
# Run tests
xcodebuild \
-project "RNTester/RNTester.xcodeproj" \
-scheme $SCHEME \
-sdk $SDK \
-scheme "$SCHEME" \
-sdk "$SDK" \
-destination "$DESTINATION" \
-UseModernBuildSystem=NO \
build test \
| xcpretty --report junit --output "$HOME/react-native/reports/junit/$TEST_NAME/results.xml"
| xcpretty --report junit --output "$HOME/react-native/reports/junit/$TEST_NAME/results.xml" \
&& exit "${PIPESTATUS[0]}"

else

# Don't run tests. No need to pass -destination to xcodebuild.
xcodebuild \
-project "RNTester/RNTester.xcodeproj" \
-scheme $SCHEME \
-sdk $SDK \
-scheme "$SCHEME" \
-sdk "$SDK" \
-UseModernBuildSystem=NO \
build

Expand Down

0 comments on commit 4f43d3c

Please sign in to comment.