From e98fc1f7a09ea321fa78c499d546a86ebd71f95d Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Tue, 8 Apr 2014 15:42:17 -0700 Subject: [PATCH] Deprecate the `--live` and `-login` password options of `subliminal-test`. (refs #176) `instruments` may (and should) be "pre-authorized" using the instructions at https://github.com/inkling/Subliminal/wiki/Continuous-Integration#faq. --- .travis.yml | 4 --- Rakefile | 38 +++++--------------- Supporting Files/CI/subliminal-test | 55 +++++++++++++++-------------- 3 files changed, 36 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4dd63a5..aaeb154 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,6 @@ install: ## Test matrix env: - global: - # To work around http://openradar.appspot.com/radar?id=1544403, - # the tests need the Travis user's password. - - LOGIN_PASSWORD="j4K7CK4oM49ZA27y532b" matrix: - TEST_COMMAND=test:unit TEST_SDK=6.1 - TEST_COMMAND=test:unit TEST_SDK=7.1 diff --git a/Rakefile b/Rakefile index 9b9c28d..6545390 100644 --- a/Rakefile +++ b/Rakefile @@ -84,7 +84,7 @@ rake test\tRuns Subliminal's tests rake test rake test:unit rake test:CI_unit -rake test:integration (LIVE=yes | LOGIN_PASSWORD=) +rake test:integration rake test:integration[:iphone, :ipad] rake test:integration:device UDID= @@ -100,6 +100,9 @@ Sub-tasks: \`test:integration\` invokes \`test:integration:iphone\` and \`test:integration:ipad\`. \`test:integration:device\` must be explicitly invoked. +To run the integration tests un-attended, you must have \"pre-authorized\" \`instruments\` +as described here: https://github.com/inkling/Subliminal/wiki/Continuous-Integration#faq. + To run the integration tests on a device, you will need a valid developer identity and provisioning profile. If you have a wildcard profile you will be able to run the tests without creating a profile specifically for the \"Subliminal Integration Tests\" app. @@ -112,19 +115,6 @@ by Xcode. TEST_SDK= Selects the iPhone Simulator SDK version against which to run the tests. Supported values are '5.1', '6.1', and '7.0'. If not specified, the tests will be run against all supported SDKs. - -\`test:integration\` options: - LIVE=yes Indicates that the tests are being attended by a developer who can - enter their password if instruments asks for authorization. For the tests - to run un-attended, the current user's login password must be specified - by \`LOGIN_PASSWORD\`. - - LOGIN_PASSWORD= Your login password. When instruments is launched, - it may ask for permission to take control of your application - (http://openradar.appspot.com/radar?id=1544403). - To authorize instruments during an un-attended run, the tests - require the current user's password. When running the tests live, - \`LIVE=yes\` may be specified instead. \`test:integration:device\` options: UDID= The UDID of the device to target.\n\n""" @@ -462,22 +452,10 @@ namespace :test do namespace :integration do def base_test_command - command = "\"#{SCRIPT_DIR}/subliminal-test\"\ - -project Subliminal.xcodeproj\ - -scheme 'Subliminal Integration Tests'\ - --quiet_build" - - if ENV["LIVE"] == "yes" - command << " --live" - else - login_password = ENV["LOGIN_PASSWORD"] - if !login_password || login_password.length == 0 - fail "Neither \`LIVE=yes\` nor \`LOGIN_PASSWORD\` specified. See 'rake usage[test]`.\n\n" - end - command << " -login_password \"#{login_password}\"" - end - - command + "\"#{SCRIPT_DIR}/subliminal-test\"\ + -project Subliminal.xcodeproj\ + -scheme 'Subliminal Integration Tests'\ + --quiet_build" end # ! because this clears old results diff --git a/Supporting Files/CI/subliminal-test b/Supporting Files/CI/subliminal-test index 3a0664b..c4b4326 100755 --- a/Supporting Files/CI/subliminal-test +++ b/Supporting Files/CI/subliminal-test @@ -29,7 +29,6 @@ print_usage_and_fail () { echo """ subliminal-test (-project | -workspace ) ( -sim_device | -hw_id ) - (-login_password | --live) [-build_tool ] [-scheme ] [-sdk ] [-replacement_bundle_id ] [--quiet_build] [-sim_version ] [-timeout ] [-output ] [-e ] @@ -51,10 +50,8 @@ Otherwise, \`subliminal-test\` returns success (0). * alongside the other scripts that were originally in \`/Supporting Files/CI\`; * with Subliminal having been installed on the test machine, using \`rake install DOCS=no\`; - * and with GUI scripting enabled: if the test machine runs Mac OS X 10.8 Mountain Lion, open System Preferences and check - \"Enable access for assistive devices\" in the Accessibility preference pane. If the test machine runs Mac OS X 10.9 Mavericks, - open System Preferences and click on \"Security & Privacy\". Select \"Accessibility\" and drag Terminal.app from Applications/Utilities - into the list. Do not forget to check the box. + * and with \`instruments\` having been \"pre-authorized\" to take control of the application, + as described here: https://github.com/inkling/Subliminal/wiki/Continuous-Integration#faq. Also make sure that your \"Integration Tests\" scheme is shared (in Xcode, click \`Product -> Schemes -> Manage Schemes…\` and then click the \"Shared\" checkbox next to the scheme) and checked into source control: @@ -83,19 +80,6 @@ Required arguments: -hw_id The UDID of the hardware to target. Either this or \`-sim_device\` must be specified. - -login_password The current user's login password. This permits - this script to authorize \`instruments\` to take control - of your application if it asks for such permission when - launched: http://openradar.appspot.com/radar?id=1544403. - - If a developer will be attending the tests as they execute, - they may specify \`--live\` rather than provide their password. - - --live Indicates that this script is being attended by a developer - who can enter their password to authorize instruments. - For this script to run un-attended, the current user's - login password must be specified using \`-login_password\`. - Optional build arguments: -build_tool The tool to use to build the scheme. Should be either \"xcrun xcodebuild\" or \"xctool\". Defaults to \"xcrun xcodebuild\". @@ -170,12 +154,22 @@ BUILD_TOOL="xcrun xcodebuild" SCHEME="Integration Tests" CONFIGURATION="Release" +LOGIN_PASSWORD_DEPRECATION_MESSAGE="""\n +WARNING: The \`--live\` and \`-login_password\` options have been deprecated\n +as of Subliminal 1.1. https://github.com/inkling/Subliminal/wiki/Continuous-Integration#faq\n +describes how to \"pre-authorize\" \`instruments\` so that \`subliminal-test\`\n +may run un-attended without the current user's login password.\n +\n +In an upcoming release, \`subliminal-instrument\` will reject the \`--live\` and\n +\`-login_password\` options and require that \`instruments\` be pre-authorized. +""" + while : do case $1 in # Must check these before the single dash options (because -* would match them) --live) - LIVE=true + echo $LOGIN_PASSWORD_DEPRECATION_MESSAGE shift 1;; --quiet_build) @@ -187,7 +181,7 @@ case $1 in shift 1;; # Set argument, wait for value - -project|-workspace|-sim_device|-hw_id|-login_password|-build_tool|-scheme|-configuration|-sdk|-replacement_bundle_id|-sim_version|-timeout|-output|-e) + -project|-workspace|-sim_device|-hw_id|-build_tool|-scheme|-configuration|-sdk|-replacement_bundle_id|-sim_version|-timeout|-output|-e) if [[ -n "$CURRENT_ARG" ]]; then echo "Missing value for argument: $CURRENT_ARG" print_usage_and_fail @@ -200,6 +194,13 @@ case $1 in esac shift 1;; + -login_password) + echo $LOGIN_PASSWORD_DEPRECATION_MESSAGE + # While `-login_password` is deprecated, we still need to use it (if present) + # to try to authorize `instruments` in case the user has not yet pre-authorized `instruments` + CURRENT_ARG=LOGIN_PASSWORD + shift 1;; + -*) echo "Unrecognized argument: $1" print_usage_and_fail;; @@ -233,8 +234,7 @@ fi # Enforce required args if [[ ( -z "$PROJECT" && -z "$WORKSPACE" ) || - ( -z "$SIM_DEVICE" && -z "$HW_ID" ) || - ( -z "$LOGIN_PASSWORD" && -z "$LIVE" ) ]]; then + ( -z "$SIM_DEVICE" && -z "$HW_ID" ) ]]; then echo "Missing required arguments" print_usage_and_fail fi @@ -490,10 +490,10 @@ if [[ -z $VERBOSE_LOGGING ]] || ! $VERBOSE_LOGGING; then defaults write com.apple.dt.InstrumentsCLI UIAVerboseLogging 4096 fi -# Attempt to authorize instruments to take control of the application -# Unless the user indicated otherwise -if [[ -z $LIVE ]] || ! $LIVE; then - # First attempt to authorize instruments when it is launched: +# If `-login_password` was specified (i.e. the user has not yet pre-authorized `instruments`) +# attempt to authorize instruments using the password +if [[ -n "$LOGIN_PASSWORD" ]]; then + # First attempt to authorize `instruments` when it is launched: # in the background, monitor for, and dismiss, the dialog it shows osascript "$SCRIPT_DIR/authorize_instruments.scpt" "$LOGIN_PASSWORD" & # Track pid to be killed when the parent script ends @@ -501,7 +501,8 @@ if [[ -z $LIVE ]] || ! $LIVE; then fi launch_instruments () { - # Second attempt (in case the dialog does not show, as in certain CI environments + # Second attempt to authorize `instruments` ourselves + # (in case the dialog does not show, as in certain CI environments # like Travis): enter the login password on the command line, # by piping the password, followed by a newline, to instruments # (If the user did not supply a login password, this will just print a newline)