| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 # | |
| 3 # Helper to run the pods tests. | |
| 4 | |
| 5 set -eu | |
| 6 | |
| 7 readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")") | |
| 8 | |
| 9 printUsage() { | |
| 10 NAME=$(basename "${0}") | |
| 11 cat << EOF | |
| 12 usage: ${NAME} [OPTIONS] | |
| 13 | |
| 14 This script runs some test to check the CocoaPods integration. | |
| 15 | |
| 16 OPTIONS: | |
| 17 | |
| 18 General: | |
| 19 | |
| 20 -h, --help | |
| 21 Show this message | |
| 22 --skip-static | |
| 23 Skip the static based pods tests. | |
| 24 --skip-framework | |
| 25 Skip the framework based pods tests. | |
| 26 --skip-ios | |
| 27 Skip the iOS pods tests. | |
| 28 --skip-osx | |
| 29 Skip the OS X pods tests. | |
| 30 | |
| 31 EOF | |
| 32 } | |
| 33 | |
| 34 TEST_MODES=( "static" "framework" ) | |
| 35 TEST_NAMES=( "iOSCocoaPodsTester" "OSXCocoaPodsTester" ) | |
| 36 while [[ $# != 0 ]]; do | |
| 37 case "${1}" in | |
| 38 -h | --help ) | |
| 39 printUsage | |
| 40 exit 0 | |
| 41 ;; | |
| 42 --skip-static ) | |
| 43 TEST_MODES=(${TEST_MODES[@]/static}) | |
| 44 ;; | |
| 45 --skip-framework ) | |
| 46 TEST_MODES=(${TEST_MODES[@]/framework}) | |
| 47 ;; | |
| 48 --skip-ios ) | |
| 49 TEST_NAMES=(${TEST_NAMES[@]/iOSCocoaPodsTester}) | |
| 50 ;; | |
| 51 --skip-osx ) | |
| 52 TEST_NAMES=(${TEST_NAMES[@]/OSXCocoaPodsTester}) | |
| 53 ;; | |
| 54 -*) | |
| 55 echo "ERROR: Unknown option: ${1}" 1>&2 | |
| 56 printUsage | |
| 57 exit 1 | |
| 58 ;; | |
| 59 *) | |
| 60 echo "ERROR: Unknown argument: ${1}" 1>&2 | |
| 61 printUsage | |
| 62 exit 1 | |
| 63 ;; | |
| 64 esac | |
| 65 shift | |
| 66 done | |
| 67 | |
| 68 # Sanity check. | |
| 69 if [[ "${#TEST_NAMES[@]}" == 0 ]] ; then | |
| 70 echo "ERROR: Need to run at least iOS or OS X tests." 1>&2 | |
| 71 exit 2 | |
| 72 fi | |
| 73 if [[ "${#TEST_MODES[@]}" == 0 ]] ; then | |
| 74 echo "ERROR: Need to run at least static or frameworks tests." 1>&2 | |
| 75 exit 2 | |
| 76 fi | |
| 77 | |
| 78 header() { | |
| 79 echo "" | |
| 80 echo "========================================================================
" | |
| 81 echo " ${@}" | |
| 82 echo "========================================================================
" | |
| 83 echo "" | |
| 84 } | |
| 85 | |
| 86 # Cleanup hook for do_test, assumes directory is correct. | |
| 87 cleanup() { | |
| 88 local TEST_NAME="$1" | |
| 89 | |
| 90 echo "Cleaning up..." | |
| 91 | |
| 92 # Generally don't let things fail, and eat common stdout, but let stderr show | |
| 93 # incase something does hiccup. | |
| 94 xcodebuild -workspace "${TEST_NAME}.xcworkspace" -scheme "${TEST_NAME}" clean
> /dev/null || true | |
| 95 pod deintegrate > /dev/null || true | |
| 96 # Flush the cache so nothing is left behind. | |
| 97 pod cache clean --all || true | |
| 98 # Delete the files left after pod deintegrate. | |
| 99 rm -f Podfile.lock || true | |
| 100 rm -rf "${TEST_NAME}.xcworkspace" || true | |
| 101 git checkout -- "${TEST_NAME}.xcodeproj" || true | |
| 102 # Remove the Podfile that was put in place. | |
| 103 rm -f Podfile || true | |
| 104 } | |
| 105 | |
| 106 do_test() { | |
| 107 local TEST_NAME="$1" | |
| 108 local TEST_MODE="$2" | |
| 109 | |
| 110 header "${TEST_NAME}" - Mode: "${TEST_MODE}" | |
| 111 cd "${ScriptDir}/${TEST_NAME}" | |
| 112 | |
| 113 # Hook in cleanup for any failures. | |
| 114 trap "cleanup ${TEST_NAME}" EXIT | |
| 115 | |
| 116 # Ensure nothing is cached by pods to start with that could throw things off. | |
| 117 pod cache clean --all | |
| 118 | |
| 119 # Put the right Podfile in place. | |
| 120 cp -f "Podfile-${TEST_MODE}" "Podfile" | |
| 121 | |
| 122 xcodebuild_args=( "-workspace" "${TEST_NAME}.xcworkspace" "-scheme" "${TEST_NA
ME}" ) | |
| 123 | |
| 124 # For iOS, if the SDK is not provided it tries to use iphoneos, and the test | |
| 125 # fail on Travis since those machines don't have a Code Signing identity. | |
| 126 if [[ "${TEST_NAME}" == iOS* ]] ; then | |
| 127 # Apparently the destination flag is required to avoid "Unsupported architec
ture" | |
| 128 # errors. | |
| 129 xcodebuild_args+=( | |
| 130 -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | |
| 131 -destination "platform=iOS Simulator,name=iPad 2,OS=9.3" | |
| 132 ) | |
| 133 fi | |
| 134 | |
| 135 # Do the work! | |
| 136 pod install --verbose | |
| 137 | |
| 138 xcodebuild "${xcodebuild_args[@]}" build | |
| 139 | |
| 140 # Clear the hook and manually run cleanup. | |
| 141 trap - EXIT | |
| 142 cleanup "${TEST_NAME}" | |
| 143 } | |
| 144 | |
| 145 # Run the tests. | |
| 146 for TEST_NAME in "${TEST_NAMES[@]}" ; do | |
| 147 for TEST_MODE in "${TEST_MODES[@]}" ; do | |
| 148 do_test "${TEST_NAME}" "${TEST_MODE}" | |
| 149 done | |
| 150 done | |
| OLD | NEW |