bwoken 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Bwoken
1
+ # Bwoken ![build status](https://secure.travis-ci.org/bendyworks/bwoken.png?branch=master)
2
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)
3
+ Runs your UIAutomation tests from the command line for both iPhone and iPad.
4
4
 
5
5
  Supports coffeescript.
6
6
 
@@ -13,6 +13,14 @@ Make sure bwoken is properly installed via one of the methods below. Then, build
13
13
 
14
14
  $ rake
15
15
 
16
+ To run a single feature, add a RUN variable with the same name as your feature, ignoring the file extension:
17
+
18
+ $ RUN=focused_test rake iphone
19
+
20
+ Or, to run the feature on both iphone and ipad
21
+
22
+ $ RUN=focused_test rake
23
+
16
24
 
17
25
  ## Installation with rvm (recommended)
18
26
 
@@ -1,10 +1,11 @@
1
1
  require 'fileutils'
2
2
 
3
- require 'bwoken/version'
4
- require 'bwoken/simulator'
5
3
  require 'bwoken/build'
6
- require 'bwoken/script'
7
4
  require 'bwoken/coffeescript'
5
+ require 'bwoken/formatters/colorful_formatter'
6
+ require 'bwoken/script'
7
+ require 'bwoken/simulator'
8
+ require 'bwoken/version'
8
9
 
9
10
  module Bwoken
10
11
  class << self
@@ -24,6 +25,10 @@ module Bwoken
24
25
  File.join(build_path, "#{app_name}.app")
25
26
  end
26
27
 
28
+ def formatter
29
+ @formatter ||= Bwoken::ColorfulFormatter.new
30
+ end
31
+
27
32
  def project_path
28
33
  Dir.pwd
29
34
  end
@@ -46,6 +51,19 @@ module Bwoken
46
51
  File.join(project_path, "#{app_name}.xcworkspace")
47
52
  end
48
53
 
54
+ def xcodeproj
55
+ File.join(project_path, "#{app_name}.xcodeproj")
56
+ end
57
+
58
+ def workspace_or_project_flag
59
+ ws = workspace
60
+ if File.exists?(ws)
61
+ "-workspace #{ws}"
62
+ else
63
+ "-project #{xcodeproj}"
64
+ end
65
+ end
66
+
49
67
  def results_path
50
68
  File.join(tmp_path, 'results').tap do |dir_name|
51
69
  FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
@@ -28,8 +28,8 @@ module Bwoken
28
28
 
29
29
  def cmd
30
30
  "xcodebuild \
31
- -workspace #{Bwoken.workspace} \
32
- -scheme #{scheme} \
31
+ #{Bwoken.workspace_or_project_flag} \
32
+ #{"-scheme #{scheme}" if Bwoken.workspace} \
33
33
  -configuration #{configuration} \
34
34
  -sdk #{sdk} \
35
35
  #{variables_for_cli} \
@@ -37,27 +37,19 @@ module Bwoken
37
37
  end
38
38
 
39
39
  def compile
40
+ Bwoken.formatter.before_build_start
41
+
40
42
  exit_status = 0
41
43
  Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
42
44
 
43
- print "Building"
44
- out_string = ""
45
-
46
- stdout.each_line do |line|
47
- out_string << line
48
- print "."
49
- end
45
+ out_string = Bwoken.formatter.format_build stdout
50
46
 
51
47
  exit_status = wait_thr.value if wait_thr
52
- puts
53
48
 
54
- if exit_status == 0
55
- puts
56
- puts "## Build Successful ##"
57
- puts
58
- else
59
- puts out_string
60
- puts 'Build failed'
49
+ if exit_status == 0 # Build Successful
50
+ Bwoken.formatter.build_successful out_string
51
+ else # Build Failed
52
+ Bwoken.formatter.build_failed out_string, stderr.read
61
53
  return exit_status
62
54
  end
63
55
  end
@@ -6,14 +6,25 @@ module Bwoken
6
6
  new.format stdout
7
7
  end
8
8
 
9
+ def format_build stdout
10
+ new.format_build stdout
11
+ end
12
+
9
13
  def on name, &block
10
- define_method "_on_#{name}_callback" do |line|
11
- block.call(line)
14
+ define_method "_on_#{name}_callback" do |*line|
15
+ block.call(*line)
12
16
  end
13
17
  end
14
18
 
15
19
  end
16
20
 
21
+ def method_missing(method_name, *args, &block)
22
+ callback_method_sig = "_on_#{method_name}_callback"
23
+ if self.respond_to? callback_method_sig.to_sym
24
+ send(callback_method_sig, *args, &block)
25
+ end
26
+ end
27
+
17
28
  def line_demuxer line, exit_status
18
29
  if line =~ /Instruments Trace Error/
19
30
  exit_status = 1
@@ -23,12 +34,18 @@ module Bwoken
23
34
 
24
35
  if tokens[3] =~ /Pass/
25
36
  _on_pass_callback(line)
37
+ elsif tokens[3] =~ /Start/
38
+ _on_start_callback(line)
26
39
  elsif tokens[3] =~ /Fail/ || line =~ /Script threw an uncaught JavaScript error/
27
40
  exit_status = 1
28
41
  _on_fail_callback(line)
42
+ elsif tokens[3] =~ /Error/
43
+ _on_error_callback(line)
29
44
  else
30
45
  _on_debug_callback(line)
31
46
  end
47
+ elsif line =~ /Instruments Trace Complete/
48
+ _on_complete_callback(line)
32
49
  else
33
50
  _on_other_callback(line)
34
51
  end
@@ -51,5 +68,38 @@ module Bwoken
51
68
  exit_status
52
69
  end
53
70
 
71
+ def format_build stdout
72
+ out_string = ''
73
+ stdout.each_line do |line|
74
+ out_string << line
75
+ if line.length > 1
76
+ _on_build_line_callback(line)
77
+ end
78
+ end
79
+ out_string
80
+ end
81
+
82
+ on :before_build_start do
83
+ puts 'Building'
84
+ end
85
+
86
+ on :build_line do |line|
87
+ print '.'
88
+ end
89
+
90
+ on :build_successful do |build_log|
91
+ puts
92
+ puts
93
+ puts "### Build Successful ###"
94
+ puts
95
+ end
96
+
97
+ on :build_failed do |build_log, error_log|
98
+ puts build_log
99
+ puts "Standard Error:"
100
+ puts error_log
101
+ puts '## Build failed ##'
102
+ end
103
+
54
104
  end
55
105
  end
@@ -5,20 +5,67 @@ require 'bwoken/formatter'
5
5
  module Bwoken
6
6
  class ColorfulFormatter < Formatter
7
7
 
8
+ on :complete do |line|
9
+ tokens = line.split(' ')
10
+ puts %Q( \n#{"Complete".send(@failed ? :red : :green)}\n Duration: #{tokens[5].sub(';','').underline.bold}\n )
11
+ end
12
+
8
13
  on :debug do |line|
14
+ filtered_line = line.sub(/(target\.frontMostApp.+)\.tap\(\)/, "#{'tap'.yellow} \\1")
15
+ filtered_line = filtered_line.gsub(/\[("[^\]]*")\]/, "[" + '\1'.magenta + "]")
16
+ filtered_line = filtered_line.gsub('()', '')
17
+ filtered_line = filtered_line.sub(/target.frontMostApp.(?:mainWindow.)?/,'')
18
+ tokens = filtered_line.split(' ')
19
+ puts "#{tokens[3].cyan}\t#{tokens[4..-1].join(' ')}"
20
+ end
21
+
22
+ on :error do |line|
23
+ @failed = true
9
24
  tokens = line.split(' ')
10
- puts "#{tokens[1]} #{tokens[3].yellow}\t#{tokens[4..-1].join(' ')}"
25
+ puts "#{tokens[3].bold.red}\t#{tokens[4..-1].join(' ').underline.bold}"
11
26
  end
12
27
 
13
28
  on :fail do |line|
29
+ @failed = true
14
30
  tokens = line.split(' ')
15
- puts "#{tokens[1]} #{tokens[3].red}\t#{tokens[4..-1].join(' ')}"
31
+ puts "#{tokens[3].bold.red}\t#{tokens[4..-1].join(' ').underline.bold}"
32
+ end
33
+
34
+ on :start do |line|
35
+ tokens = line.split(' ')
36
+ puts "#{tokens[3].cyan}\t#{tokens[4..-1].join(' ')}"
16
37
  end
17
38
 
18
39
  on :pass do |line|
19
40
  tokens = line.split(' ')
20
- puts "#{tokens[1]} #{tokens[3].green}\t#{tokens[4..-1].join(' ')}"
41
+ puts "#{tokens[3].green}\t#{tokens[4..-1].join(' ')}"
21
42
  end
22
43
 
44
+ on :before_script_run do |path|
45
+ @failed = false
46
+ tokens = path.split('/')
47
+ puts
48
+ puts "#{tokens[-2]}\t#{tokens[-1]}".cyan
49
+ end
50
+
51
+ on :before_build_start do
52
+ print "Building".blue
53
+ end
54
+
55
+ on :build_line do |line|
56
+ print '.'.blue
57
+ end
58
+
59
+ on :build_successful do |line|
60
+ puts
61
+ puts 'Build Successful!'.green
62
+ end
63
+
64
+ on :build_failed do |build_log, error_log|
65
+ puts build_log
66
+ puts 'Standard Error:'.yellow
67
+ puts error_log
68
+ puts 'Build failed!'.red
69
+ end
23
70
  end
24
71
  end
@@ -1,8 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'open3'
3
3
 
4
- require 'bwoken/formatters/colorful_formatter'
5
-
6
4
  module Bwoken
7
5
 
8
6
  class ScriptFailedError < RuntimeError; end
@@ -16,11 +14,16 @@ module Bwoken
16
14
  def run_all device_family
17
15
  Simulator.device_family = device_family
18
16
 
19
- Dir["#{Bwoken.test_suite_path}/#{device_family}/**/*.js"].each do |javascript|
17
+ test_files(device_family).each do |javascript|
20
18
  run(javascript)
21
19
  end
22
20
  end
23
21
 
22
+ def run_one feature_name, device_family
23
+ Simulator.device_family = device_family
24
+ run File.join(Bwoken.test_suite_path, device_family, "#{feature_name}.js")
25
+ end
26
+
24
27
  def run javascript_path
25
28
  script = new
26
29
  script.path = javascript_path
@@ -31,6 +34,12 @@ module Bwoken
31
34
  File.join(Bwoken.tmp_path, 'trace')
32
35
  end
33
36
 
37
+ def test_files device_family
38
+ all_files_in_test_dir = Dir["#{Bwoken.test_suite_path}/#{device_family}/**/*.js"]
39
+ helper_files = Dir["#{Bwoken.test_suite_path}/#{device_family}/**/helpers/**/*.js"]
40
+ all_files_in_test_dir - helper_files
41
+ end
42
+
34
43
  end
35
44
 
36
45
  def env_variables
@@ -52,20 +61,17 @@ module Bwoken
52
61
  #{env_variables_for_cli}"
53
62
  end
54
63
 
55
- def formatter
56
- Bwoken::ColorfulFormatter
57
- end
58
-
59
64
  def make_results_path_dir
60
65
  FileUtils.mkdir_p Bwoken.results_path
61
66
  end
62
67
 
63
68
  def run
69
+ Bwoken.formatter.before_script_run path
64
70
  make_results_path_dir
65
71
 
66
72
  exit_status = 0
67
73
  Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
68
- exit_status = formatter.format stdout
74
+ exit_status = Bwoken.formatter.format stdout
69
75
  end
70
76
  raise ScriptFailedError.new('Test Script Failed') unless exit_status == 0
71
77
  end
@@ -28,8 +28,8 @@ end
28
28
 
29
29
  desc 'Remove result and trace files'
30
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}/*"
31
+ print "Removing #{Bwoken.tmp_path}/* ... "
32
+ system "rm -rf #{Bwoken.tmp_path}/*"
33
33
  puts 'done.'
34
34
  end
35
35
 
@@ -40,7 +40,8 @@ end
40
40
 
41
41
  desc 'Compile the workspace'
42
42
  task :build do
43
- Bwoken::Build.new.compile
43
+ exit_status = Bwoken::Build.new.compile
44
+ raise unless exit_status == 0
44
45
  end
45
46
 
46
47
  task :coffeescript do
@@ -54,7 +55,11 @@ device_families.each do |device_family|
54
55
 
55
56
  namespace device_family do
56
57
  task :test => :coffeescript do
57
- Bwoken::Script.run_all device_family
58
+ if ENV['RUN']
59
+ Bwoken::Script.run_one ENV['RUN'], device_family
60
+ else
61
+ Bwoken::Script.run_all device_family
62
+ end
58
63
  end
59
64
  end
60
65
 
@@ -1,3 +1,3 @@
1
1
  module Bwoken
2
- VERSION = "0.0.1" unless defined?(::Bwoken::VERSION)
2
+ VERSION = "1.0.0" unless defined?(::Bwoken::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bwoken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-29 00:00:00.000000000 Z
13
+ date: 2012-04-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-script-source
17
- requirement: &70256891126900 !ruby/object:Gem::Requirement
17
+ requirement: &70255276428720 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70256891126900
25
+ version_requirements: *70255276428720
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: colorful
28
- requirement: &70256891126240 !ruby/object:Gem::Requirement
28
+ requirement: &70255276427380 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70256891126240
36
+ version_requirements: *70255276427380
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: execjs
39
- requirement: &70256891125660 !ruby/object:Gem::Requirement
39
+ requirement: &70255276426320 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70256891125660
47
+ version_requirements: *70255276426320
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &70256891103760 !ruby/object:Gem::Requirement
50
+ requirement: &70255276425800 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70256891103760
58
+ version_requirements: *70255276425800
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
- requirement: &70256891101500 !ruby/object:Gem::Requirement
61
+ requirement: &70255276424840 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70256891101500
69
+ version_requirements: *70255276424840
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: guard-rspec
72
- requirement: &70256891099820 !ruby/object:Gem::Requirement
72
+ requirement: &70255276423820 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70256891099820
80
+ version_requirements: *70255276423820
81
81
  description: iOS UIAutomation Test Runner
82
82
  email:
83
83
  - brad@bendyworks.com
@@ -87,20 +87,20 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - LICENSE
91
+ - README.md
90
92
  - bin/unix_instruments.sh
91
- - lib/bwoken/formatters/colorful_formatter.rb
92
- - lib/bwoken/tasks/bwoken.rake
93
93
  - lib/bwoken/build.rb
94
94
  - lib/bwoken/coffeescript.rb
95
95
  - lib/bwoken/formatter.rb
96
+ - lib/bwoken/formatters/colorful_formatter.rb
96
97
  - lib/bwoken/script.rb
97
98
  - lib/bwoken/simulator.rb
99
+ - lib/bwoken/tasks/bwoken.rake
98
100
  - lib/bwoken/tasks.rb
99
101
  - lib/bwoken/version.rb
100
102
  - lib/bwoken.rb
101
- - LICENSE
102
- - README.md
103
- homepage: https://github.com/bendyworks/bwoken
103
+ homepage: https://bendyworks.github.com/bwoken
104
104
  licenses: []
105
105
  post_install_message:
106
106
  rdoc_options: []
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: 2085165610847558799
117
+ hash: 1868550205244240029
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
@@ -123,10 +123,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: 2085165610847558799
126
+ hash: 1868550205244240029
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 1.8.10
129
+ rubygems_version: 1.8.17
130
130
  signing_key:
131
131
  specification_version: 3
132
132
  summary: Runs your UIAutomation tests from the command line for both iPhone and iPad;