Repository: realm/realm-swift
File: build.sh (Shell)

Code before:
    ######################################
    # Testing
    ######################################
    "test")
        sh build.sh test-ios "$XCMODE"
        sh build.sh test-osx "$XCMODE"
        exit 0
        ;;

    "test-debug")
        xcrealm "-scheme iOS -configuration Debug -sdk iphonesimulator build test"
        xcrealm "-scheme OSX -configuration Debug build test"
        exit 0
        ;;

    "test-all")
        sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
        sh build.sh test "$XCMODE" || exit 1
        sh build.sh test-debug "$XCMODE" || exit 1
        sudo xcode-select -s /Applications/Xcode6-Beta2.app/Contents/Developer
        sh build.sh test "$XCMODE" || exit 1
        sh build.sh test-debug "$XCMODE" || exit 1
        exit 0
        ;;

    "test-ios")
        xcrealm "-scheme iOS -configuration Release -sdk iphonesimulator test"
        exit 0
        ;;

    "test-osx")
        xcrealm "-scheme OSX -configuration Release test"
        exit 0
        ;;

    "test-cover")
        echo "Not yet implemented"
        exit 0
        ;;

    "verify")
        sh build.sh docs || exit 1
        sh build.sh test-all "$XCMODE" || exit 1
        sh build.sh examples "$XCMODE" || exit 1
        exit 0
        ;;

    ######################################
    # Docs
    ######################################
    "docs")

Review comment (suggestion):
Now it leaves the default to Apple's default (Xcode.app) and switches to a specific beta temporarily.
It is to be noted that xcode-select only acts on the command line tools, so if you use XCode6 (GUI) but have never set xcode-select manually then this still works perfectly.
This script assumes that we want to run tests on the stable version of xcode and run additional tests on xcode6beta if esplicitly asked to.

We could easily add an xcode-select in the beginning of the script, but restoring the original state in the end would be a bit tricky because of the amount of `exit 1`. Maybe some kind of exit function could help.


Code after:
    ######################################
    # Testing
    ######################################
    "test")
        sh build.sh test-ios "$XCMODE"
        sh build.sh test-osx "$XCMODE"
        exit 0
        ;;

    "test-debug")
        xcrealm "-scheme iOS -configuration Debug -sdk iphonesimulator build test"
        xcrealm "-scheme OSX -configuration Debug build test"
        exit 0
        ;;

    "test-all")
        sudo xcode-select -s /Applications/Xcode.app/Contents/Developer || exit 1
        sh build.sh test "$XCMODE" || exit 1
        sh build.sh test-debug "$XCMODE" || exit 1
        sudo xcode-select -s /Applications/Xcode6-Beta2.app/Contents/Developer || exit 1
        fail=0
        (
            sh build.sh test "$XCMODE" || exit 1
            sh build.sh test-debug "$XCMODE" || exit 1
        ) || fail=1
        sudo xcode-select -s /Applications/Xcode.app/Contents/Developer || exit 1
        exit $fail
        ;;

    "test-ios")
        xcrealm "-scheme iOS -configuration Release -sdk iphonesimulator test"
        exit 0
        ;;

    "test-osx")
        xcrealm "-scheme OSX -configuration Release test"
        exit 0
        ;;

    "test-cover")
        echo "Not yet implemented"
        exit 0
        ;;

    "verify")
        sh build.sh docs || exit 1
        sh build.sh test-all "$XCMODE" || exit 1
        sh build.sh examples "$XCMODE" || exit 1
        exit 0
        ;;