Skip to content

Commit

Permalink
Deprecate the --live and -login password options of `subliminal-t…
Browse files Browse the repository at this point in the history
…est`. (refs #176)

`instruments` may (and should) be "pre-authorized" using the instructions
at https://github.com/inkling/Subliminal/wiki/Continuous-Integration#faq.
  • Loading branch information
Jeff Wear committed Apr 17, 2014
1 parent 03491af commit e98fc1f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 61 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 8 additions & 30 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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=<password>)
rake test:integration
rake test:integration[:iphone, :ipad]
rake test:integration:device UDID=<udid>
Expand All @@ -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.
Expand All @@ -112,19 +115,6 @@ by Xcode.
TEST_SDK=<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=<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=<udid> The UDID of the device to target.\n\n"""
Expand Down Expand Up @@ -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
Expand Down
55 changes: 28 additions & 27 deletions Supporting Files/CI/subliminal-test
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ print_usage_and_fail () {
echo """
subliminal-test (-project <project_path> | -workspace <workspace_path>)
( -sim_device <device_type> | -hw_id <udid> )
(-login_password <password> | --live)
[-build_tool <tool_name>] [-scheme <scheme_name>] [-sdk <sdk>] [-replacement_bundle_id <id>] [--quiet_build]
[-sim_version <version>] [-timeout <timeout>] [-output <output_dir>]
[-e <variable> <value>]
Expand All @@ -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:
Expand Down Expand Up @@ -83,19 +80,6 @@ Required arguments:
-hw_id <udid> The UDID of the hardware to target.
Either this or \`-sim_device\` must be specified.
-login_password <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 <tool_name> The tool to use to build the scheme. Should be either \"xcrun xcodebuild\"
or \"xctool\". Defaults to \"xcrun xcodebuild\".
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -490,18 +490,19 @@ 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
AUTHORIZE_INSTRUMENTS_PID=$!
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)
Expand Down

0 comments on commit e98fc1f

Please sign in to comment.