From f978d02c923b9bd53156e790ba2efb4301a26d41 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Thu, 6 Aug 2015 01:35:23 +0200 Subject: [PATCH] Bash lipstick. --- scripts/automation-tests.sh | 33 ++++++++------------ scripts/common.sh | 60 +++++++++++++++++++++++++----------- scripts/pre-release-tests.sh | 49 ++++++++++++++++++++++++----- 3 files changed, 95 insertions(+), 47 deletions(-) mode change 100644 => 100755 scripts/common.sh diff --git a/scripts/automation-tests.sh b/scripts/automation-tests.sh index c1f45e2d..a1ced3e0 100755 --- a/scripts/automation-tests.sh +++ b/scripts/automation-tests.sh @@ -1,19 +1,11 @@ #!/bin/bash - - set -e + NUM_OF_TESTS=14 CURRENT_DIR="$( dirname "${BASH_SOURCE[0]}" )" BUILD_DIRECTORY=build APP=RxExample CONFIGURATIONS="Debug Release-Tests Release" -#SIMULATORS="RxSwiftTest-iPhone4s-iOS_8.4 RxSwiftTest-iPhone5-iOS_8.4 RxSwiftTest-iPhone5s-iOS_8.4 RxSwiftTest-iPhone6-iOS_8.4 RxSwiftTest-iPhone6Plus-iOS_8.4 RxSwiftTest-iPhone4s-iOS_8.1 RxSwiftTest-iPhone5-iOS_8.1 RxSwiftTest-iPhone5s-iOS_8.1 RxSwiftTest-iPhone6-iOS_8.1 RxSwiftTest-iPhone6Plus-iOS_8.1" - -#IOS7_SIMULATORS="RxSwiftTest-iPhone4s-iOS_7.1 RxSwiftTest-iPhone5-iOS_7.1 RxSwiftTest-iPhone5s-iOS_7.1" -IOS7_SIMULATORS="" -IOS8_SIMULATORS="RxSwiftTest-iPhone4s-iOS_8.4 RxSwiftTest-iPhone5-iOS_8.4 RxSwiftTest-iPhone5s-iOS_8.4 RxSwiftTest-iPhone6-iOS_8.4 RxSwiftTest-iPhone6Plus-iOS_8.4" - -#open $TMPDIR . scripts/common.sh @@ -23,9 +15,9 @@ ROOT=`pwd` BUILD_DIRECTORY="${ROOT}/build" function runAutomation() { - SIMULATOR=$1 + SCHEME=$1 CONFIGURATION=$2 - SCHEME=$3 + SIMULATOR=$3 APP="${SCHEME}" @@ -36,8 +28,7 @@ function runAutomation() { printf "${GREEN}Building example for automation ${BOLDCYAN}${SIMULATOR} - ${CONFIGURATION}${RESET}" echo - OS=`echo $SIMULATOR| cut -d'_' -f 2` - xcodebuild -workspace Rx.xcworkspace -scheme ${SCHEME} -derivedDataPath ${BUILD_DIRECTORY} -configuration ${CONFIGURATION} -destination platform='iOS Simulator',OS="${OS}",name="${SIMULATOR}" build | xcpretty -c + rx $SCHEME $CONFIGURATION $SIMULATOR build echo printf "${GREEN}Quitting iOS Simulator ...${RESET}" @@ -83,19 +74,19 @@ function runAutomation() { } # ios 7 -for simulator in ${IOS7_SIMULATORS} -do - for configuration in ${CONFIGURATIONS} - do - runAutomation ${simulator} ${configuration} "RxExample-iOS-no-module" - done -done +#for simulator in ${IOS7_SIMULATORS} +#do +# for configuration in ${CONFIGURATIONS} +# do +# runAutomation "RxExample-iOS" ${configuration} ${simulator} +# done +#done # ios 8 for simulator in ${IOS8_SIMULATORS} do for configuration in ${CONFIGURATIONS} do - runAutomation ${simulator} ${configuration} "RxExample-iOS" + runAutomation "RxExample-iOS" ${configuration} ${simulator} done done diff --git a/scripts/common.sh b/scripts/common.sh old mode 100644 new mode 100755 index a2a4d9c0..3c91ca93 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +#set -o xtrace RESET="\033[0m" BLACK="\033[30m" @@ -21,28 +22,54 @@ BOLDWHITE="\033[1m\033[37m" # make sure all tests are passing +DEFAULT_IOS7_SIMULATOR=RxSwiftTest-iPhone4s-iOS_7.1 +DEFAULT_IOS8_SIMULATOR=RxSwiftTest-iPhone6-iOS_8.4 + +IOS7_SIMULATORS="RxSwiftTest-iPhone4s-iOS_7.1 RxSwiftTest-iPhone5-iOS_7.1 RxSwiftTest-iPhone5s-iOS_7.1" +IOS8_SIMULATORS="RxSwiftTest-iPhone4s-iOS_8.4 RxSwiftTest-iPhone5-iOS_8.4 RxSwiftTest-iPhone5s-iOS_8.4 RxSwiftTest-iPhone6-iOS_8.4 RxSwiftTest-iPhone6Plus-iOS_8.4" + BUILD_DIRECTORY=build -function runTests() { - echo - printf "${GREEN}Running tests for ${BOLDCYAN}$1 - $2${RESET}\n" - echo - - xcodebuild -workspace Rx.xcworkspace -scheme "$1" -configuration "$2" -derivedDataPath ${BUILD_DIRECTORY} test | xcpretty -c - - #if [[ $scheme == *"iOS"* ]] - #then - # SDK="-sdk iphonesimulator" - #fi - #xctool -workspace Rx.xcworkspace -scheme "$1" -configuration "$2" ${SDK} -derivedDataPath ${BUILD_DIRECTORY} test +function ios7simulator() { + A=($IOS7_SIMULATORS) + echo ${A[$1]} } -function buildExample() { +function ios8simulator() { + A=($IOS8_SIMULATORS) + echo ${A[$1]} +} + +function rx() { + SCHEME=$1 + CONFIGURATION=$2 + SIMULATOR=$3 + ACTION=$4 + echo - printf "${GREEN}Building example for ${BOLDCYAN}$1 - $2${RESET}\n" + printf "${GREEN}${ACTION} ${BOLDCYAN}$1 - $2 ($SIMULATOR)${RESET}\n" echo - xcodebuild -workspace Rx.xcworkspace -scheme "$1" -configuration "$2" build | xcpretty -c + DESTINATION="" + if [ "$SIMULATOR" != "" ]; then + OS=`echo $SIMULATOR| cut -d'_' -f 2` + DESTINATION='platform=iOS Simulator,OS='$OS',name='$SIMULATOR'' + else + DESTINATION='platform=OS X,arch=x86_64' + fi + + STATUS="" + xcodebuild -workspace Rx.xcworkspace \ + -scheme $SCHEME \ + -configuration $CONFIGURATION \ + -derivedDataPath "${BUILD_DIRECTORY}" \ + -destination "$DESTINATION" \ + $ACTION | xcpretty -c; STATUS=${PIPESTATUS[0]} + + if [ $STATUS -ne 0 ]; then + echo $STATUS + exit $STATUS + fi } # simulators @@ -50,9 +77,6 @@ function buildExample() { # xcrun simctl list devicetypes # xcrun simctl list runtimes -#IOS7_SIMULATORS="RxSwiftTest-iPhone4s-iOS_7.1 RxSwiftTest-iPhone5-iOS_7.1 RxSwiftTest-iPhone5s-iOS_7.1" -#IOS8_SIMULATORS="RxSwiftTest-iPhone4s-iOS_8.4 RxSwiftTest-iPhone5-iOS_8.4 RxSwiftTest-iPhone5s-iOS_8.4 RxSwiftTest-iPhone6-iOS_8.4 RxSwiftTest-iPhone6Plus-iOS_8.4" - function createDevices() { xcrun simctl create RxSwiftTest-iPhone4s-iOS_7.1 'iPhone 4s' 'com.apple.CoreSimulator.SimRuntime.iOS-7-1' xcrun simctl create RxSwiftTest-iPhone5-iOS_7.1 'iPhone 5' 'com.apple.CoreSimulator.SimRuntime.iOS-7-1' diff --git a/scripts/pre-release-tests.sh b/scripts/pre-release-tests.sh index 51f92431..1442b82b 100755 --- a/scripts/pre-release-tests.sh +++ b/scripts/pre-release-tests.sh @@ -4,26 +4,59 @@ IS_LOCAL=0 if [ "$#" -eq 1 ]; then echo "Local test" IS_LOCAL=1 +else + # ios 7 sim + if [ `xcrun simctl list | grep "${DEFAULT_IOS7_SIMULATOR}" | wc -l` == 0 ]; then + xcrun simctl create $DEFAULT_IOS7_SIMULATOR 'iPhone 4s' 'com.apple.CoreSimulator.SimRuntime.iOS-7-1' + else + echo "${DEFAULT_IOS7_SIMULATOR} exists" + fi + + #ios 8 sim + if [ `xcrun simctl list | grep "${DEFAULT_IOS8_SIMULATOR}" | wc -l` == 0 ]; then + xcrun simctl create $DEFAULT_IOS8_SIMULATOR 'iPhone 6' 'com.apple.CoreSimulator.SimRuntime.iOS-8-4' + else + echo "${DEFAULT_IOS8_SIMULATOR} exists" + fi fi -#runTests "RxTests-iOS" "Release-Tests" +#make sure all iOS tests pass +for configuration in "Debug" "Release-Tests" "Release" +do + rx "RxTests-iOS" ${configuration} $DEFAULT_IOS8_SIMULATOR test +done -#make sure all unit tests pass -for scheme in "RxTests-iOS" "RxTests-OSX" +#make sure all OSX tests pass +for configuration in "Debug" "Release-Tests" "Release" +do + rx "RxTests-OSX" ${configuration} "" test +done + +# make sure no module can be built +for scheme in "RxExample-iOS-no-module" do for configuration in "Debug" "Release-Tests" "Release" do - runTests ${scheme} ${configuration} + rx ${scheme} ${configuration} $DEFAULT_IOS7_SIMULATOR build + rx ${scheme} ${configuration} $DEFAULT_IOS8_SIMULATOR build done done - -# make sure it all build -for scheme in "RxExample-iOS" "RxExample-iOS-no-module" "RxExample-OSX" +# make sure with modules can be built +for scheme in "RxExample-iOS" do for configuration in "Debug" "Release-Tests" "Release" do - buildExample ${scheme} ${configuration} + rx ${scheme} ${configuration} $DEFAULT_IOS8_SIMULATOR build + done +done + +# make sure osx builds +for scheme in "RxExample-OSX" +do + for configuration in "Debug" "Release-Tests" "Release" + do + rx ${scheme} ${configuration} "" build done done