diff --git a/Gemfile.lock b/Gemfile.lock index d2d1279..00a86d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bwoken (2.0.0.beta.1) + bwoken (2.0.0.beta.2) coffee-script-source colorful execjs diff --git a/README.md b/README.md index 511162a..d90a056 100644 --- a/README.md +++ b/README.md @@ -103,15 +103,17 @@ Here's a list of all the switches that bwoken takes for the `test` command:

 $ 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.
 
## In Your Code @@ -187,6 +189,19 @@ Now, you can start using it! 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 diff --git a/bin/unix_instruments.sh b/bin/unix_instruments.sh index 3e4665b..00a68a2 100755 --- a/bin/unix_instruments.sh +++ b/bin/unix_instruments.sh @@ -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 @@ -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 @@ -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 @@ -87,5 +88,5 @@ function cleanup_instruments() { if [[ $1 == "----test" ]]; then get_error_status else - run_instruments $@ + run_instruments "$@" fi diff --git a/bwoken.gemspec b/bwoken.gemspec index c5f9672..0cd9b47 100644 --- a/bwoken.gemspec +++ b/bwoken.gemspec @@ -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/**/*'] diff --git a/lib/bwoken.rb b/lib/bwoken.rb index 848daaf..e9c9a67 100644 --- a/lib/bwoken.rb +++ b/lib/bwoken.rb @@ -5,7 +5,15 @@ 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 @@ -13,7 +21,11 @@ def tmp_path 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 diff --git a/lib/bwoken/cli.rb b/lib/bwoken/cli.rb index d918a0d..98fc23f 100644 --- a/lib/bwoken/cli.rb +++ b/lib/bwoken/cli.rb @@ -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 @@ -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 diff --git a/lib/bwoken/cli/init.rb b/lib/bwoken/cli/init.rb index 83ee389..b347111 100644 --- a/lib/bwoken/cli/init.rb +++ b/lib/bwoken/cli/init.rb @@ -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 diff --git a/lib/bwoken/cli/templates/integration/coffeescript/ipad/example.coffee b/lib/bwoken/cli/templates/coffeescript/ipad/example.coffee similarity index 100% rename from lib/bwoken/cli/templates/integration/coffeescript/ipad/example.coffee rename to lib/bwoken/cli/templates/coffeescript/ipad/example.coffee diff --git a/lib/bwoken/cli/templates/integration/coffeescript/iphone/example.coffee b/lib/bwoken/cli/templates/coffeescript/iphone/example.coffee similarity index 100% rename from lib/bwoken/cli/templates/integration/coffeescript/iphone/example.coffee rename to lib/bwoken/cli/templates/coffeescript/iphone/example.coffee diff --git a/lib/bwoken/cli/templates/integration/javascript/example_vendor.js b/lib/bwoken/cli/templates/javascript/example_vendor.js similarity index 100% rename from lib/bwoken/cli/templates/integration/javascript/example_vendor.js rename to lib/bwoken/cli/templates/javascript/example_vendor.js diff --git a/lib/bwoken/cli/test.rb b/lib/bwoken/cli/test.rb index b9a5c7f..78f1e5e 100644 --- a/lib/bwoken/cli/test.rb +++ b/lib/bwoken/cli/test.rb @@ -17,7 +17,7 @@ module CLI class Test def self.help_banner - < path, - 'UIARESULTSPATH' => Bwoken.results_path + 'UIASCRIPT' => %Q|"#{path}"|, + 'UIARESULTSPATH' => %Q|"#{Bwoken.results_path}"| } end @@ -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 diff --git a/lib/bwoken/simulator.rb b/lib/bwoken/simulator.rb index 56e6bbb..6f43350 100644 --- a/lib/bwoken/simulator.rb +++ b/lib/bwoken/simulator.rb @@ -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'] diff --git a/lib/bwoken/version.rb b/lib/bwoken/version.rb index 3bbab43..e4f08bc 100644 --- a/lib/bwoken/version.rb +++ b/lib/bwoken/version.rb @@ -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 diff --git a/spec/lib/bwoken/script_spec.rb b/spec/lib/bwoken/script_spec.rb index c347a71..1411b23 100644 --- a/spec/lib/bwoken/script_spec.rb +++ b/spec/lib/bwoken/script_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/lib/bwoken/simulator_spec.rb b/spec/lib/bwoken/simulator_spec.rb index 37338fe..25a1402 100644 --- a/spec/lib/bwoken/simulator_spec.rb +++ b/spec/lib/bwoken/simulator_spec.rb @@ -18,14 +18,14 @@ 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 @@ -33,22 +33,22 @@ 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