bwoken 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +97 -0
- data/bin/unix_instruments.sh +62 -0
- data/lib/bwoken/build.rb +67 -0
- data/lib/bwoken/coffeescript.rb +97 -0
- data/lib/bwoken/formatter.rb +55 -0
- data/lib/bwoken/formatters/colorful_formatter.rb +24 -0
- data/lib/bwoken/script.rb +74 -0
- data/lib/bwoken/simulator.rb +36 -0
- data/lib/bwoken/tasks/bwoken.rake +77 -0
- data/lib/bwoken/tasks.rb +1 -0
- data/lib/bwoken/version.rb +3 -0
- data/lib/bwoken.rb +56 -0
- metadata +134 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Bendyworks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Bwoken
|
2
|
+
|
3
|
+
Runs your UIAutomation tests from the command line for both iPhone and iPad. ![build status](https://secure.travis-ci.org/bendyworks/bwoken.png?branch=master)
|
4
|
+
|
5
|
+
Supports coffeescript.
|
6
|
+
|
7
|
+
![screenshot](https://raw.github.com/bendyworks/bwoken/master/doc/screenshot.png)
|
8
|
+
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Make sure bwoken is properly installed via one of the methods below. Then, build your project and run all your tests via:
|
13
|
+
|
14
|
+
$ rake
|
15
|
+
|
16
|
+
|
17
|
+
## Installation with rvm (recommended)
|
18
|
+
|
19
|
+
Ensure Xcode is up-to-date.
|
20
|
+
|
21
|
+
Add an .rvmrc file to your project, such as:
|
22
|
+
|
23
|
+
$ echo 'rvm use 1.9.3@MyProject --create' >> .rvmrc
|
24
|
+
|
25
|
+
Install bundler and init:
|
26
|
+
|
27
|
+
$ gem install bundler
|
28
|
+
$ bundle init
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
gem 'bwoken'
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
$ bundle --binstubs=bundler_bin
|
37
|
+
|
38
|
+
Ensure your after_cd_bundler rvm hook is enabled:
|
39
|
+
|
40
|
+
$ chmod u+x ~/.rvm/hooks/after_cd_bundler
|
41
|
+
|
42
|
+
Then, add the following line to your `Rakefile`:
|
43
|
+
|
44
|
+
require 'bwoken/tasks'
|
45
|
+
|
46
|
+
Initialize your bwoken file structure:
|
47
|
+
|
48
|
+
$ rake bwoken:init
|
49
|
+
|
50
|
+
Ensure your project is in a workspace rather than simply a project:
|
51
|
+
|
52
|
+
* In Xcode, select File -> Save as workspace...
|
53
|
+
* Save the workspace in the same directory as your .xcodeproj file
|
54
|
+
|
55
|
+
|
56
|
+
## Installation without rvm (not recommended)
|
57
|
+
|
58
|
+
Ensure Xcode is up-to-date.
|
59
|
+
|
60
|
+
Install bundler and init:
|
61
|
+
|
62
|
+
$ gem install bundler
|
63
|
+
$ bundle init
|
64
|
+
|
65
|
+
Add this line to your application's Gemfile:
|
66
|
+
|
67
|
+
gem 'bwoken'
|
68
|
+
|
69
|
+
And then execute:
|
70
|
+
|
71
|
+
$ bundle --binstubs=bundler_bin
|
72
|
+
|
73
|
+
Ensure your $PATH variable has bundler_bin at the front. This is usually done with .bash_profile:
|
74
|
+
|
75
|
+
$ echo 'export PATH=bundler_bin:$PATH' >> ~/.bash_profile
|
76
|
+
|
77
|
+
Then, add the following line to your `Rakefile`:
|
78
|
+
|
79
|
+
require 'bwoken/tasks'
|
80
|
+
|
81
|
+
Initialize your bwoken file structure:
|
82
|
+
|
83
|
+
$ rake bwoken:init
|
84
|
+
|
85
|
+
Ensure your project is in a workspace rather than simply a project:
|
86
|
+
|
87
|
+
* In Xcode, select File -> Save as workspace...
|
88
|
+
* Save the workspace in the same directory as your .xcodeproj file
|
89
|
+
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
1. Fork it
|
94
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
95
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
96
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
97
|
+
5. Create new Pull Request
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
#
|
3
|
+
# unix_instruments
|
4
|
+
#
|
5
|
+
# A wrapper around `instruments` that returns a proper unix status code
|
6
|
+
# depending on whether the run failed or not. Alas, Apple's instruments tool
|
7
|
+
# doesn't care about unix status codes, so I must grep for the "Fail:" string
|
8
|
+
# and figure it out myself. As long as the command doesn't output that string
|
9
|
+
# anywhere else inside it, then it should work.
|
10
|
+
#
|
11
|
+
# I use a tee pipe to capture the output and deliver it to stdout
|
12
|
+
#
|
13
|
+
# Author: Jonathan Penn (jonathan@cocoamanifest.net)
|
14
|
+
#
|
15
|
+
|
16
|
+
set -e # Bomb on any script errors
|
17
|
+
|
18
|
+
run_instruments() {
|
19
|
+
# Because instruments buffers it's output if it determines that it is being
|
20
|
+
# piped to another process, we have to use ptys to get around that so that we
|
21
|
+
# can use `tee` to save the output for grepping and print to stdout in real
|
22
|
+
# time at the same time.
|
23
|
+
#
|
24
|
+
# I don't like this because I'm hard coding a tty/pty pair in here. Suggestions
|
25
|
+
# to make this cleaner?
|
26
|
+
|
27
|
+
output=$(mktemp -t unix-instruments)
|
28
|
+
instruments $@ &> /dev/ttyvf & pid_instruments=$!
|
29
|
+
|
30
|
+
# Cat the instruments output to tee which outputs to stdout and saves to
|
31
|
+
# $output at the same time
|
32
|
+
cat < /dev/ptyvf | tee $output
|
33
|
+
|
34
|
+
# Clear the process id we saved when forking instruments so the cleanup
|
35
|
+
# function called on exit knows it doesn't have to kill anything
|
36
|
+
pid_instruments=0
|
37
|
+
|
38
|
+
# Process the instruments output looking for anything that resembles a fail
|
39
|
+
# message
|
40
|
+
cat $output | get_error_status
|
41
|
+
}
|
42
|
+
|
43
|
+
get_error_status() {
|
44
|
+
# Catch "00-00-00 00:00:00 +000 Fail:"
|
45
|
+
# Catch "Instruments Trace Error"
|
46
|
+
ruby -e 'exit 1 if STDIN.read =~ /Instruments Trace Error|^\d+-\d+-\d+ \d+:\d+:\d+ [-+]\d+ Fail:/'
|
47
|
+
}
|
48
|
+
|
49
|
+
trap cleanup_instruments EXIT
|
50
|
+
function cleanup_instruments() {
|
51
|
+
# Because we fork instruments in this script, we need to clean up if it's
|
52
|
+
# still running because of an error or the user pressed Ctrl-C
|
53
|
+
if [[ $pid_instruments -gt 0 ]]; then
|
54
|
+
kill $pid_instruments
|
55
|
+
fi
|
56
|
+
}
|
57
|
+
|
58
|
+
if [[ $1 == "----test" ]]; then
|
59
|
+
get_error_status
|
60
|
+
else
|
61
|
+
run_instruments $@
|
62
|
+
fi
|
data/lib/bwoken/build.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Bwoken
|
4
|
+
class Build
|
5
|
+
|
6
|
+
def scheme
|
7
|
+
Bwoken.app_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def configuration
|
11
|
+
'Debug'
|
12
|
+
end
|
13
|
+
|
14
|
+
def sdk
|
15
|
+
'iphonesimulator5.1'
|
16
|
+
end
|
17
|
+
|
18
|
+
def env_variables
|
19
|
+
{
|
20
|
+
'GCC_PREPROCESSOR_DEFINITIONS' => 'TEST_MODE=1',
|
21
|
+
'CONFIGURATION_BUILD_DIR' => Bwoken.build_path
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def variables_for_cli
|
26
|
+
env_variables.map{|key,val| "#{key}=#{val}"}.join(' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def cmd
|
30
|
+
"xcodebuild \
|
31
|
+
-workspace #{Bwoken.workspace} \
|
32
|
+
-scheme #{scheme} \
|
33
|
+
-configuration #{configuration} \
|
34
|
+
-sdk #{sdk} \
|
35
|
+
#{variables_for_cli} \
|
36
|
+
clean build"
|
37
|
+
end
|
38
|
+
|
39
|
+
def compile
|
40
|
+
exit_status = 0
|
41
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
42
|
+
|
43
|
+
print "Building"
|
44
|
+
out_string = ""
|
45
|
+
|
46
|
+
stdout.each_line do |line|
|
47
|
+
out_string << line
|
48
|
+
print "."
|
49
|
+
end
|
50
|
+
|
51
|
+
exit_status = wait_thr.value if wait_thr
|
52
|
+
puts
|
53
|
+
|
54
|
+
if exit_status == 0
|
55
|
+
puts
|
56
|
+
puts "## Build Successful ##"
|
57
|
+
puts
|
58
|
+
else
|
59
|
+
puts out_string
|
60
|
+
puts 'Build failed'
|
61
|
+
return exit_status
|
62
|
+
end
|
63
|
+
end
|
64
|
+
exit_status
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'coffee_script/source'
|
3
|
+
require 'json' if RUBY_VERSION =~ /^1\.8\./
|
4
|
+
require 'execjs'
|
5
|
+
|
6
|
+
module Bwoken
|
7
|
+
class Coffeescript
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def source_folder
|
11
|
+
File.join(Bwoken.path, 'coffeescript')
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_files
|
15
|
+
"#{source_folder}/**/*.coffee"
|
16
|
+
end
|
17
|
+
|
18
|
+
def coffee_script_source
|
19
|
+
IO.read(CoffeeScript::Source.bundled_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def context
|
23
|
+
@context ||= ExecJS.compile(coffee_script_source)
|
24
|
+
end
|
25
|
+
|
26
|
+
def compile_all
|
27
|
+
|
28
|
+
Dir[test_files].each do |filename|
|
29
|
+
new(filename).make
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def clean
|
34
|
+
FileUtils.rm_rf compiled_javascript_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def compiled_javascript_path
|
38
|
+
File.join(Bwoken.tmp_path, 'javascript')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_accessor :import_strings
|
44
|
+
|
45
|
+
def initialize path
|
46
|
+
@source_file = path
|
47
|
+
end
|
48
|
+
|
49
|
+
def destination_folder
|
50
|
+
subpath = File.dirname(@source_file.sub(Regexp.new(self.class.source_folder + '/'), '')).sub('.','')
|
51
|
+
File.join(self.class.compiled_javascript_path, subpath)
|
52
|
+
end
|
53
|
+
|
54
|
+
def destination_file
|
55
|
+
basename = File.basename(@source_file, '.coffee')
|
56
|
+
"#{self.destination_folder}/#{basename}.js"
|
57
|
+
end
|
58
|
+
|
59
|
+
def make
|
60
|
+
FileUtils.mkdir_p(destination_folder)
|
61
|
+
javascript = compile
|
62
|
+
save javascript
|
63
|
+
end
|
64
|
+
|
65
|
+
def source_contents
|
66
|
+
IO.read(@source_file)
|
67
|
+
end
|
68
|
+
|
69
|
+
def compile
|
70
|
+
source = precompile(source_contents)
|
71
|
+
self.class.context.call('CoffeeScript.compile', source, :bare => true)
|
72
|
+
end
|
73
|
+
|
74
|
+
def precompile coffeescript
|
75
|
+
capture_imports coffeescript
|
76
|
+
remove_imports coffeescript
|
77
|
+
end
|
78
|
+
|
79
|
+
def capture_imports raw_coffeescript
|
80
|
+
self.import_strings = raw_coffeescript.scan(/#import .*$/)
|
81
|
+
end
|
82
|
+
|
83
|
+
def remove_imports raw_coffeescript
|
84
|
+
raw_coffeescript.gsub(/#import .*$/,'')
|
85
|
+
end
|
86
|
+
|
87
|
+
def save javascript
|
88
|
+
File.open(destination_file, 'w') do |io|
|
89
|
+
import_strings.each do |import_string|
|
90
|
+
io.puts import_string
|
91
|
+
end unless import_strings.nil?
|
92
|
+
io.puts javascript
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Bwoken
|
2
|
+
class Formatter
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def format stdout
|
6
|
+
new.format stdout
|
7
|
+
end
|
8
|
+
|
9
|
+
def on name, &block
|
10
|
+
define_method "_on_#{name}_callback" do |line|
|
11
|
+
block.call(line)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def line_demuxer line, exit_status
|
18
|
+
if line =~ /Instruments Trace Error/
|
19
|
+
exit_status = 1
|
20
|
+
_on_fail_callback(line)
|
21
|
+
elsif line =~ /^\d{4}/
|
22
|
+
tokens = line.split(' ')
|
23
|
+
|
24
|
+
if tokens[3] =~ /Pass/
|
25
|
+
_on_pass_callback(line)
|
26
|
+
elsif tokens[3] =~ /Fail/ || line =~ /Script threw an uncaught JavaScript error/
|
27
|
+
exit_status = 1
|
28
|
+
_on_fail_callback(line)
|
29
|
+
else
|
30
|
+
_on_debug_callback(line)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
_on_other_callback(line)
|
34
|
+
end
|
35
|
+
exit_status
|
36
|
+
end
|
37
|
+
|
38
|
+
%w(pass fail debug other).each do |log_level|
|
39
|
+
on log_level.to_sym do |line|
|
40
|
+
puts line
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def format stdout
|
45
|
+
exit_status = 0
|
46
|
+
|
47
|
+
stdout.each_line do |line|
|
48
|
+
exit_status = line_demuxer line, exit_status
|
49
|
+
end
|
50
|
+
|
51
|
+
exit_status
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'colorful'
|
2
|
+
|
3
|
+
require 'bwoken/formatter'
|
4
|
+
|
5
|
+
module Bwoken
|
6
|
+
class ColorfulFormatter < Formatter
|
7
|
+
|
8
|
+
on :debug do |line|
|
9
|
+
tokens = line.split(' ')
|
10
|
+
puts "#{tokens[1]} #{tokens[3].yellow}\t#{tokens[4..-1].join(' ')}"
|
11
|
+
end
|
12
|
+
|
13
|
+
on :fail do |line|
|
14
|
+
tokens = line.split(' ')
|
15
|
+
puts "#{tokens[1]} #{tokens[3].red}\t#{tokens[4..-1].join(' ')}"
|
16
|
+
end
|
17
|
+
|
18
|
+
on :pass do |line|
|
19
|
+
tokens = line.split(' ')
|
20
|
+
puts "#{tokens[1]} #{tokens[3].green}\t#{tokens[4..-1].join(' ')}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
require 'bwoken/formatters/colorful_formatter'
|
5
|
+
|
6
|
+
module Bwoken
|
7
|
+
|
8
|
+
class ScriptFailedError < RuntimeError; end
|
9
|
+
|
10
|
+
class Script
|
11
|
+
|
12
|
+
attr_accessor :path
|
13
|
+
|
14
|
+
class << self
|
15
|
+
|
16
|
+
def run_all device_family
|
17
|
+
Simulator.device_family = device_family
|
18
|
+
|
19
|
+
Dir["#{Bwoken.test_suite_path}/#{device_family}/**/*.js"].each do |javascript|
|
20
|
+
run(javascript)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def run javascript_path
|
25
|
+
script = new
|
26
|
+
script.path = javascript_path
|
27
|
+
script.run
|
28
|
+
end
|
29
|
+
|
30
|
+
def trace_file_path
|
31
|
+
File.join(Bwoken.tmp_path, 'trace')
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def env_variables
|
37
|
+
{
|
38
|
+
'UIASCRIPT' => path,
|
39
|
+
'UIARESULTSPATH' => Bwoken.results_path
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def env_variables_for_cli
|
44
|
+
env_variables.map{|key,val| "-e #{key} #{val}"}.join(' ')
|
45
|
+
end
|
46
|
+
|
47
|
+
def cmd
|
48
|
+
"#{File.expand_path('../../../bin', __FILE__)}/unix_instruments.sh \
|
49
|
+
-D #{self.class.trace_file_path} \
|
50
|
+
-t #{Bwoken.path_to_automation_template} \
|
51
|
+
#{Bwoken.app_dir} \
|
52
|
+
#{env_variables_for_cli}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def formatter
|
56
|
+
Bwoken::ColorfulFormatter
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_results_path_dir
|
60
|
+
FileUtils.mkdir_p Bwoken.results_path
|
61
|
+
end
|
62
|
+
|
63
|
+
def run
|
64
|
+
make_results_path_dir
|
65
|
+
|
66
|
+
exit_status = 0
|
67
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
68
|
+
exit_status = formatter.format stdout
|
69
|
+
end
|
70
|
+
raise ScriptFailedError.new('Test Script Failed') unless exit_status == 0
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Bwoken
|
2
|
+
class Simulator
|
3
|
+
|
4
|
+
def self.plist_buddy; '/usr/libexec/PlistBuddy'; end
|
5
|
+
def self.plist_file; "#{Bwoken.app_dir}/Info.plist"; end
|
6
|
+
|
7
|
+
def self.device_family= device_family
|
8
|
+
update_device_family_in_plist :delete_array
|
9
|
+
update_device_family_in_plist :add_array
|
10
|
+
update_device_family_in_plist :add_scalar, device_family
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.update_device_family_in_plist action, args = nil
|
14
|
+
system_cmd = lambda {|command| Kernel.system "#{plist_buddy} -c '#{command}' #{plist_file}" }
|
15
|
+
|
16
|
+
case action
|
17
|
+
when :delete_array then system_cmd['Delete :UIDeviceFamily']
|
18
|
+
when :add_array then system_cmd['Add :UIDeviceFamily array']
|
19
|
+
when :add_scalar
|
20
|
+
command = lambda {|scalar| "Add :UIDeviceFamily:0 integer #{scalar == 'iphone' ? 1 : 2}"}
|
21
|
+
|
22
|
+
case args
|
23
|
+
when /iphone/i
|
24
|
+
system_cmd[command['iphone']]
|
25
|
+
when /ipad/i
|
26
|
+
system_cmd[command['ipad']]
|
27
|
+
when /universal/i
|
28
|
+
system_cmd[command['ipad']]
|
29
|
+
system_cmd[command['iphone']]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'bwoken'
|
2
|
+
|
3
|
+
namespace :bwoken do
|
4
|
+
desc 'Create bwoken skeleton folders'
|
5
|
+
task :init do
|
6
|
+
paths = []
|
7
|
+
paths << Bwoken.results_path
|
8
|
+
paths << Bwoken.test_suite_path
|
9
|
+
paths << "#{Bwoken::Coffeescript.source_folder}/iphone"
|
10
|
+
paths << "#{Bwoken::Coffeescript.source_folder}/ipad"
|
11
|
+
|
12
|
+
paths.each do |path|
|
13
|
+
puts "Creating #{path}"
|
14
|
+
FileUtils.mkdir_p path
|
15
|
+
end
|
16
|
+
|
17
|
+
example = "#{Bwoken::Coffeescript.source_folder}/iphone/example.coffee"
|
18
|
+
unless File.file?(example)
|
19
|
+
puts "Creating #{example}"
|
20
|
+
open(example, 'w') do |io|
|
21
|
+
io.puts 'target = UIATarget.localTarget()'
|
22
|
+
io.puts 'window = target.frontMostApp().mainWindow()'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Remove result and trace files'
|
30
|
+
task :clean do
|
31
|
+
print "Removing #{Bwoken.results_path}/* & #{Bwoken::Script.trace_file_path}/* ... "
|
32
|
+
system "rm -rf #{Bwoken.results_path}/* #{Bwoken::Script.trace_file_path}/*"
|
33
|
+
puts 'done.'
|
34
|
+
end
|
35
|
+
|
36
|
+
# task :clean_db do
|
37
|
+
# puts "Cleaning the application's sqlite cache database"
|
38
|
+
# system 'rm -rf ls -1d ~/Library/Application\ Support/iPhone\ Simulator/**/Applications/**/Library/Caches/TravisCI*.sqlite'
|
39
|
+
# end
|
40
|
+
|
41
|
+
desc 'Compile the workspace'
|
42
|
+
task :build do
|
43
|
+
Bwoken::Build.new.compile
|
44
|
+
end
|
45
|
+
|
46
|
+
task :coffeescript do
|
47
|
+
Bwoken::Coffeescript.clean
|
48
|
+
Bwoken::Coffeescript.compile_all
|
49
|
+
end
|
50
|
+
|
51
|
+
device_families = %w(iphone ipad)
|
52
|
+
|
53
|
+
device_families.each do |device_family|
|
54
|
+
|
55
|
+
namespace device_family do
|
56
|
+
task :test => :coffeescript do
|
57
|
+
Bwoken::Script.run_all device_family
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Run tests for #{device_family}"
|
62
|
+
task device_family => "#{device_family}:test"
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'Run all tests without compiling first'
|
67
|
+
task :test do
|
68
|
+
if ENV['FAMILY']
|
69
|
+
Rake::Task[ENV['FAMILY']].invoke
|
70
|
+
else
|
71
|
+
device_families.each do |device_family|
|
72
|
+
Rake::Task[device_family].invoke
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
task :default => [:build, :test]
|
data/lib/bwoken/tasks.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load 'bwoken/tasks/bwoken.rake'
|
data/lib/bwoken.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
require 'bwoken/version'
|
4
|
+
require 'bwoken/simulator'
|
5
|
+
require 'bwoken/build'
|
6
|
+
require 'bwoken/script'
|
7
|
+
require 'bwoken/coffeescript'
|
8
|
+
|
9
|
+
module Bwoken
|
10
|
+
class << self
|
11
|
+
def path
|
12
|
+
File.join(project_path, 'integration')
|
13
|
+
end
|
14
|
+
|
15
|
+
def tmp_path
|
16
|
+
File.join(path, 'tmp')
|
17
|
+
end
|
18
|
+
|
19
|
+
def app_name
|
20
|
+
File.basename(project_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def app_dir
|
24
|
+
File.join(build_path, "#{app_name}.app")
|
25
|
+
end
|
26
|
+
|
27
|
+
def project_path
|
28
|
+
Dir.pwd
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_suite_path
|
32
|
+
Bwoken::Coffeescript.compiled_javascript_path
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_to_automation_template
|
36
|
+
'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate'
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_path
|
40
|
+
File.join(project_path, 'build').tap do |dir_name|
|
41
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def workspace
|
46
|
+
File.join(project_path, "#{app_name}.xcworkspace")
|
47
|
+
end
|
48
|
+
|
49
|
+
def results_path
|
50
|
+
File.join(tmp_path, 'results').tap do |dir_name|
|
51
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bwoken
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brad Grzesiak
|
9
|
+
- Jaymes Waters
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: coffee-script-source
|
17
|
+
requirement: &70256891126900 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70256891126900
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: colorful
|
28
|
+
requirement: &70256891126240 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70256891126240
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: execjs
|
39
|
+
requirement: &70256891125660 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *70256891125660
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
requirement: &70256891103760 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *70256891103760
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
requirement: &70256891101500 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *70256891101500
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: guard-rspec
|
72
|
+
requirement: &70256891099820 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *70256891099820
|
81
|
+
description: iOS UIAutomation Test Runner
|
82
|
+
email:
|
83
|
+
- brad@bendyworks.com
|
84
|
+
- jaymes@bendyworks.com
|
85
|
+
executables:
|
86
|
+
- unix_instruments.sh
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- bin/unix_instruments.sh
|
91
|
+
- lib/bwoken/formatters/colorful_formatter.rb
|
92
|
+
- lib/bwoken/tasks/bwoken.rake
|
93
|
+
- lib/bwoken/build.rb
|
94
|
+
- lib/bwoken/coffeescript.rb
|
95
|
+
- lib/bwoken/formatter.rb
|
96
|
+
- lib/bwoken/script.rb
|
97
|
+
- lib/bwoken/simulator.rb
|
98
|
+
- lib/bwoken/tasks.rb
|
99
|
+
- lib/bwoken/version.rb
|
100
|
+
- lib/bwoken.rb
|
101
|
+
- LICENSE
|
102
|
+
- README.md
|
103
|
+
homepage: https://github.com/bendyworks/bwoken
|
104
|
+
licenses: []
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
hash: 2085165610847558799
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
hash: 2085165610847558799
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 1.8.10
|
130
|
+
signing_key:
|
131
|
+
specification_version: 3
|
132
|
+
summary: Runs your UIAutomation tests from the command line for both iPhone and iPad;
|
133
|
+
supports coffeescript
|
134
|
+
test_files: []
|