Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.
Closed
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
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,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
6 changes: 3 additions & 3 deletions bin/unix_instruments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ run_instruments() {
# to make this cleaner?

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

# Cat the instruments output to tee which outputs to stdout and saves to
# $output at the same time
cat < /dev/ptyvf | tee $output
cat < /dev/ptyuf | tee $output

# Clear the process id we saved when forking instruments so the cleanup
# function called on exit knows it doesn't have to kill anything
Expand Down Expand Up @@ -87,5 +87,5 @@ function cleanup_instruments() {
if [[ $1 == "----test" ]]; then
get_error_status
else
run_instruments $@
run_instruments "$@"
fi
6 changes: 3 additions & 3 deletions bwoken.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ require File.expand_path('../lib/bwoken/version', __FILE__)

Gem::Specification.new do |gem|
gem.name = 'bwoken'
gem.version = Bwoken::VERSION
gem.version = '2.0.0.beta.2' # Bwoken::VERSION
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', 'Jaymes Waters', 'Alec Gorge']
gem.email = ['brad@bendyworks.com', 'jaymes@bendyworks.com', 'alecgorge@gmail.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= 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')
if @name && @name != ''
@name
else
File.basename(File.basename(workspace_or_project, '.xcodeproj'), '.xcworkspace')
end
end

def app_name= name
@name = name
end

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

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.', :efault => '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', :default => ''
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
25 changes: 15 additions & 10 deletions lib/bwoken/cli/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Init
class << self

def help_banner
<<BANNER
<<-BANNER
Initialize your UIAutomation project.


Expand All @@ -17,29 +17,34 @@ def help_banner
end
end

attr_accessor :options

# opts - A slop command object (acts like super-hash)
# There are currently no options available
def initialize opts
# opts = opts.to_hash if opts.is_a?(Slop)
opts = opts.to_hash if opts.is_a?(Slop)
self.options = opts.to_hash
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'
integration_dir = options[:'integration-path']
directory "#{integration_dir}/coffeescript/iphone"
directory "#{integration_dir}/coffeescript/ipad"
directory "#{integration_dir}/javascript"
directory "#{integration_dir}/tmp/results"
template "#{integration_dir}/coffeescript/iphone/example.coffee"
template "#{integration_dir}/coffeescript/ipad/example.coffee"
template "#{integration_dir}/javascript/example_vendor.js"
end

def directory dirname
FileUtils.mkdir_p dirname
end

def template filename
fixed_filename = "integration" + filename[options[:'integration-path'].length..-1]
FileUtils.cp \
File.expand_path("../templates/#{filename}", __FILE__),
File.expand_path("../templates/#{fixed_filename}", __FILE__),
filename
end

Expand Down
18 changes: 13 additions & 5 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 Down Expand Up @@ -47,6 +47,8 @@ def self.help_banner
# :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
def initialize opts
opts = opts.to_hash if opts.is_a?(Slop)
self.options = opts.to_hash.tap do |o|
Expand All @@ -55,6 +57,8 @@ def initialize opts
o[:simulator] = use_simulator?(o[:simulator])
o[:family] = o[:family]
end

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

def run
Expand All @@ -71,14 +75,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 = options[:'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 All @@ -94,6 +100,8 @@ def transpile
end

def test
Bwoken.app_name = options[:'product-name']

ScriptRunner.new do |s|
s.app_dir = Build.app_dir(options[:simulator])
s.family = options[:family]
Expand Down
12 changes: 6 additions & 6 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' => '"' + path + '"',
'UIARESULTSPATH' => '"' + Bwoken.results_path + '"'
}
end

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

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

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