Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bwoken (2.0.0.beta.1)
bwoken (2.0.0.beta.2)
coffee-script-source
colorful
execjs
Expand Down
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ Here's a list of all the switches that bwoken takes for the `test` command:
<pre><code>
$ bwoken test -h
[...]
--simulator Use simulator, even when an iDevice is connected
--family Test only one device type, either ipad or iphone. Default is to test on both
--scheme Specify a custom scheme
--formatter Specify a custom formatter (e.g., --formatter=passthru)
--focus Specify particular tests to run
--clobber Remove any generated file
--skip-build Do not build the iOS binary
--verbose Be verbose
-h, --help Display this help message.
--simulator Use simulator, even when an iDevice is connected
--family Test only one device type, either ipad or iphone. Default is to test on both
--scheme Specify a custom scheme
--product-name Specify a custom product name (e.g. --product-name="My Product"). Default is the name of of the xcodeproj file
--integration-path Specify a custom directory to store your test scripts in (e.g. --integration-path=uiautomation/path/dir). Note that this folder still expects the same directory structure as the one create by `bwoken init`.
--formatter Specify a custom formatter (e.g., --formatter=passthru)
--focus Specify particular tests to run
--clobber Remove any generated file
--skip-build Do not build the iOS binary
--verbose Be verbose
-h, --help Display this help message.
</code></pre>

## In Your Code
Expand Down Expand Up @@ -187,6 +189,19 @@ Now, you can start <a href="#usage">using it!</a>

Technically, you can skip this entire Installation section and just run `sudo gem install bwoken && bwoken init`. This is listed here for completeness, but you really shouldn't install gems this way.

## Contributors

Special thank you goes out to everyone who's helped with bwoken. Here's a (probably incomplete) list of those folks:

* Brad Grzesiak ([listrophy](https://github.com/listrophy))
* Jaymes Waters ([jaym3s](https://github.com/jaym3s))
* Jonathan Penn ([jonathanpenn](https://github.com/jonathanpenn))
* Ryland Herrick ([rylnd](https://github.com/rylnd))
* Whitney Young ([wbyoung](https://github.com/wbyoung))
* David Gagnon ([mrdavidgagnon](https://github.com/mrdavidgagnon))
* [otusweb](https://github.com/otusweb)
* Alec Gorge ([alecgorge](https://github.com/alecgorge))

## Contributing

1. Fork it
Expand Down
9 changes: 5 additions & 4 deletions bin/unix_instruments.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright (c) 2012 Jonathan Penn (http://cocoamanifest.net)
# Copyright (c) 2013 Jonathan Penn (http://cocoamanifest.net)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -47,7 +47,8 @@ run_instruments() {
# to make this cleaner?

output=$(mktemp -t unix-instruments)
instruments $@ &> /dev/ttyvf & pid_instruments=$!
instruments "$@" &> /dev/ttyvf &
pid_instruments=$!

# Cat the instruments output to tee which outputs to stdout and saves to
# $output at the same time
Expand All @@ -72,7 +73,7 @@ get_error_status() {
}

trap cleanup_instruments EXIT
function cleanup_instruments() {
cleanup_instruments() {
# Because we fork instruments in this script, we need to clean up if it's
# still running because of an error or the user pressed Ctrl-C
if [[ $pid_instruments -gt 0 ]]; then
Expand All @@ -87,5 +88,5 @@ function cleanup_instruments() {
if [[ $1 == "----test" ]]; then
get_error_status
else
run_instruments $@
run_instruments "$@"
fi
4 changes: 2 additions & 2 deletions bwoken.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
gem.description = %q{iOS UIAutomation Test Runner}
gem.summary = %q{Runs your UIAutomation tests from the command line for both iPhone and iPad; supports coffeescript}

gem.authors = ['Brad Grzesiak', 'Jaymes Waters']
gem.email = ['brad@bendyworks.com', 'jaymes@bendyworks.com']
gem.authors = ['Brad Grzesiak']
gem.email = ['brad@bendyworks.com']
gem.homepage = 'https://bendyworks.github.com/bwoken'

gem.files = Dir['LICENSE', 'README.md', 'bin/**/*', 'lib/**/*']
Expand Down
16 changes: 14 additions & 2 deletions lib/bwoken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@ class << self
DEVICE_FAMILIES = %w(iphone ipad)

def path
File.join(project_path, 'integration')
File.join(project_path, integration_path)
end

def integration_path
@integration_path || 'integration'
end

def integration_path= new_integration_path
@integration_path = new_integration_path
end

def tmp_path
File.join(path, 'tmp')
end

def app_name
File.basename(File.basename(workspace_or_project, '.xcodeproj'), '.xcworkspace')
@name || File.basename(File.basename(workspace_or_project, '.xcodeproj'), '.xcworkspace')
end

def app_name= name
@name = name
end

def project_path
Expand Down
4 changes: 4 additions & 0 deletions lib/bwoken/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

command 'init' do
banner Bwoken::CLI::Init.help_banner
on :'integration-path=', 'Specify a custom directory to store your test scripts in (e.g. --integration-path=uiautomation/path/dir). Default: integration. If you use the non-default value here, you will need to always run bwoken with the `--integration-path=your/integration/dir` option.', :default => 'integration'

run { ran_command = 'init' }
end
Expand All @@ -26,12 +27,15 @@
on :family=, 'Test only one device type, either ipad or iphone. Default is to test on both',
:match => /\A(?:ipad|iphone|all)\Z/i, :default => 'all'
on :scheme=, 'Specify a custom scheme'
on :'product-name=', 'Specify a custom product name (e.g. --product-name="My Product"). Default is the name of of the xcodeproj file'
on :'integration-path=', 'Specify a custom directory to store your test scripts in (e.g. --integration-path=uiautomation/path/dir). Note that this folder still expects the same directory structure as the one create by `bwoken init`.', :default => 'integration'
#on :flags=, 'Specify custom build flags (e.g., --flags="-arch=i386,foo=bar")', :as => Array, :default => [] # TODO: implement
on :formatter=, 'Specify a custom formatter (e.g., --formatter=passthru)', :default => 'colorful'
on :focus=, 'Specify particular tests to run', :as => Array, :default => []
on :clobber, 'Remove any generated file'
on :'skip-build', 'Do not build the iOS binary'
on :verbose, 'Be verbose'
on :configuration=, 'The build configruation to use (e.g., --configuration=Release)', :default => 'Debug'

run { ran_command = 'test' }
end
Expand Down
28 changes: 15 additions & 13 deletions lib/bwoken/cli/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,31 @@ def help_banner
end

# opts - A slop command object (acts like super-hash)
# There are currently no options available
# Only allowed option is 'integration-path' which should
# have defaulted to 'integration'
def initialize opts
# opts = opts.to_hash if opts.is_a?(Slop)
opts = opts.to_hash if opts.is_a?(Slop)
Bwoken.integration_path = opts[:'integration-path']
end

def run
directory 'integration/coffeescript/iphone'
directory 'integration/coffeescript/ipad'
directory 'integration/javascript'
directory 'integration/tmp/results'
template 'integration/coffeescript/iphone/example.coffee'
template 'integration/coffeescript/ipad/example.coffee'
template 'integration/javascript/example_vendor.js'
directory "coffeescript/iphone"
directory "coffeescript/ipad"
directory "javascript"
directory "tmp/results"
template "coffeescript/iphone/example.coffee"
template "coffeescript/ipad/example.coffee"
template "javascript/example_vendor.js"
end

def directory dirname
FileUtils.mkdir_p dirname
FileUtils.mkdir_p "#{Bwoken.integration_path}/#{dirname}"
end

def template filename
FileUtils.cp \
File.expand_path("../templates/#{filename}", __FILE__),
filename
source = File.expand_path("../templates/#{filename}", __FILE__)
destination = "#{Bwoken.integration_path}/#{filename}"
FileUtils.cp source, destination
end

end
Expand Down
36 changes: 22 additions & 14 deletions lib/bwoken/cli/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module CLI
class Test

def self.help_banner
<<BANNER
<<-BANNER
Run your tests. If you don't specify which tests, bwoken will run them all

bwoken test --simulator # runs all tests in the simulator
Expand All @@ -38,15 +38,18 @@ def self.help_banner
attr_accessor :options

# opts - A slop command object (acts like super-hash)
# :clobber - remove all generated files, including iOS build
# :family - enum of [nil, 'iphone', 'ipad'] (case-insensitive)
# :flags - custom build flag array (default: []) TODO: not yet implmented
# :focus - which tests to run (default: [], meaning "all")
# :formatter - custom formatter (default: 'colorful')
# :scheme - custom scheme (default: nil)
# :simulator - should force simulator use (default: nil)
# :skip-build - do not build the iOS binary
# :verbose - be verbose
# :clobber - remove all generated files, including iOS build
# :family - enum of [nil, 'iphone', 'ipad'] (case-insensitive)
# :flags - custom build flag array (default: []) TODO: not yet implmented
# :focus - which tests to run (default: [], meaning "all")
# :formatter - custom formatter (default: 'colorful')
# :scheme - custom scheme (default: nil)
# :simulator - should force simulator use (default: nil)
# :skip-build - do not build the iOS binary
# :verbose - be verbose
# :integration-path - the base directory for all the integration files
# :product-name - the name of the generated .app file if it is different from the name of the project/workspace
# :configuration - typically "Debug" or "Release"
def initialize opts
opts = opts.to_hash if opts.is_a?(Slop)
self.options = opts.to_hash.tap do |o|
Expand All @@ -55,6 +58,9 @@ def initialize opts
o[:simulator] = use_simulator?(o[:simulator])
o[:family] = o[:family]
end

Bwoken.integration_path = options[:'integration-path']
Bwoken.app_name = options[:'product-name']
end

def run
Expand All @@ -71,14 +77,16 @@ def compile
b.formatter = options[:formatter]
b.scheme = options[:scheme] if options[:scheme]
b.simulator = options[:simulator]
b.configuration = options[:configuration]
end.compile
end

def transpile
coffeescripts = Rake::FileList['integration/coffeescript/**/*.coffee']
compiled_coffee = coffeescripts.pathmap('%{^integration/coffeescript,integration/tmp/javascript}d/%n.js')
javascripts = Rake::FileList['integration/javascript/**/*.js']
copied_javascripts = javascripts.pathmap('%{^integration/javascript,integration/tmp/javascript}d/%f')
integration_dir = Bwoken.integration_path
coffeescripts = Rake::FileList["#{integration_dir}/coffeescript/**/*.coffee"]
compiled_coffee = coffeescripts.pathmap("%{^#{integration_dir}/coffeescript,#{integration_dir}/tmp/javascript}d/%n.js")
javascripts = Rake::FileList["#{integration_dir}/javascript/**/*.js"]
copied_javascripts = javascripts.pathmap("%{^#{integration_dir}/javascript,#{integration_dir}/tmp/javascript}d/%f")

compiled_coffee.zip(coffeescripts).each do |target, source|
containing_dir = target.pathmap('%d')
Expand Down
14 changes: 7 additions & 7 deletions lib/bwoken/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def initialize

def env_variables
{
'UIASCRIPT' => path,
'UIARESULTSPATH' => Bwoken.results_path
'UIASCRIPT' => %Q|"#{path}"|,
'UIARESULTSPATH' => %Q|"#{Bwoken.results_path}"|
}
end

Expand All @@ -35,12 +35,12 @@ def env_variables_for_cli
end

def cmd
"#{File.expand_path('../../../bin', __FILE__)}/unix_instruments.sh \
%Q|"#{File.expand_path('../../../bin', __FILE__)}/unix_instruments.sh" \
#{device_flag} \
-D #{self.class.trace_file_path} \
-t #{Bwoken.path_to_automation_template} \
#{app_dir} \
#{env_variables_for_cli}"
-D "#{self.class.trace_file_path}" \
-t "#{Bwoken.path_to_automation_template}" \
"#{app_dir}" \
#{env_variables_for_cli}|
end

def device_flag
Expand Down
2 changes: 1 addition & 1 deletion lib/bwoken/simulator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.device_family= device_family
end

def self.update_device_family_in_plist action, args = nil
system_cmd = lambda {|command| Kernel.system "#{plist_buddy} -c '#{command}' #{plist_file}" }
system_cmd = lambda {|command| Kernel.system "#{plist_buddy} -c '#{command}' \"#{plist_file}\"" }

case action
when :delete_array then system_cmd['Delete :UIDeviceFamily']
Expand Down
2 changes: 1 addition & 1 deletion lib/bwoken/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bwoken
VERSION = "2.0.0.beta.1" unless defined?(::Bwoken::VERSION)
VERSION = "2.0.0.beta.2" unless defined?(::Bwoken::VERSION)
end
15 changes: 8 additions & 7 deletions spec/lib/bwoken/script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ class Simulator; end
it 'returns a hash with UIASCRIPT set to #path' do
Bwoken.stub(:results_path => 'foo')
subject.path = 'bar'
subject.env_variables['UIASCRIPT'].should == 'bar'
subject.env_variables['UIASCRIPT'].should == '"bar"'
end

it 'returns a hash with UIARESULTSPATH set to Bwoken.results_path' do
Bwoken.stub(:results_path => 'foo')
subject.env_variables['UIARESULTSPATH'].should == 'foo'
subject.path = 'bar'
subject.env_variables['UIARESULTSPATH'].should == '"foo"'
end

end
Expand All @@ -80,7 +81,7 @@ class Simulator; end
subject.path = 'foo'
Bwoken.stub(:results_path => 'bar')

allowed = ['-e UIASCRIPT foo -e UIARESULTSPATH bar', '-e UIARESULTSPATH bar -e UIASCRIPT foo']
allowed = ['-e UIASCRIPT "foo" -e UIARESULTSPATH "bar"', '-e UIARESULTSPATH "bar" -e UIASCRIPT "foo"']
subject.env_variables_for_cli.should be_in(allowed)
end
end
Expand All @@ -103,11 +104,11 @@ class Simulator; end
let(:want_simulator) { true }
let(:regexp) do
/
unix_instruments\.sh\s+
unix_instruments\.sh"\s+
#{expected_device_flag_regexp}
-D\s#{trace_file_path}\s+
-t\s#{path_to_automation_template}\s+
#{app_dir}\s+
-D\s"#{trace_file_path}"\s+
-t\s"#{path_to_automation_template}"\s+
"#{app_dir}"\s+
#{env_variables_for_cli}/x
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/bwoken/simulator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@

context 'when deleting the device family array' do
it 'calls PlistBuddy with the correct args' do
Kernel.should_receive(:system).with("plistbuddy -c 'Delete :UIDeviceFamily' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Delete :UIDeviceFamily' \"plist_file\"")
Bwoken::Simulator.update_device_family_in_plist :delete_array
end
end

context 'when creating the device family array' do
it 'calls PlistBuddy with the correct args' do
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily array' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily array' \"plist_file\"")
Bwoken::Simulator.update_device_family_in_plist :add_array
end
end

context 'when adding to the device family array' do
context 'for iPhone' do
it 'calls PlistBuddy with the correct args' do
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 1' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 1' \"plist_file\"")
Bwoken::Simulator.update_device_family_in_plist :add_scalar, 'iphone'
end
end

context 'for iPad' do
it 'calls PlistBuddy with the correct args' do
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 2' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 2' \"plist_file\"")
Bwoken::Simulator.update_device_family_in_plist :add_scalar, 'ipad'
end
end

context 'for universal' do
it 'calls PlistBuddy with the correct args' do
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 1' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 2' plist_file")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 1' \"plist_file\"")
Kernel.should_receive(:system).with("plistbuddy -c 'Add :UIDeviceFamily:0 integer 2' \"plist_file\"")
Bwoken::Simulator.update_device_family_in_plist :add_scalar, 'universal'
end
end
Expand Down