bwoken 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Runs your UIAutomation tests from the command line for both iPhone and iPad.
4
4
 
5
- Supports coffeescript.
5
+ Supports coffeescript and javascript.
6
6
 
7
7
  ![screenshot](https://raw.github.com/bendyworks/bwoken/master/doc/screenshot.png)
8
8
 
@@ -1,5 +1,27 @@
1
1
  #!/usr/bin/env bash
2
2
  #
3
+ # Copyright (c) 2012 Jonathan Penn (http://cocoamanifest.net)
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+ #
23
+
24
+
3
25
  # unix_instruments
4
26
  #
5
27
  # A wrapper around `instruments` that returns a proper unix status code
@@ -41,9 +63,12 @@ run_instruments() {
41
63
  }
42
64
 
43
65
  get_error_status() {
44
- # Catch "00-00-00 00:00:00 +000 Fail:"
45
66
  # Catch "Instruments Trace Error"
46
- ruby -e 'exit 1 if STDIN.read =~ /Instruments Trace Error|^\d+-\d+-\d+ \d+:\d+:\d+ [-+]\d+ Fail:/'
67
+ # Catch "Instruments Usage Error"
68
+ # Catch "00-00-00 00:00:00 +000 Fail:"
69
+ # Catch "00-00-00 00:00:00 +000 Error:"
70
+ # Catch "00-00-00 00:00:00 +000 None: Script threw an uncaught JavaScript error"
71
+ ruby -e 'exit 1 if STDIN.read =~ /Instruments Usage Error|Instruments Trace Error|^\d+-\d+-\d+ \d+:\d+:\d+ [-+]\d+ (Fail:|Error:|None: Script threw an uncaught JavaScript error)/'
47
72
  }
48
73
 
49
74
  trap cleanup_instruments EXIT
@@ -51,10 +76,14 @@ function cleanup_instruments() {
51
76
  # Because we fork instruments in this script, we need to clean up if it's
52
77
  # still running because of an error or the user pressed Ctrl-C
53
78
  if [[ $pid_instruments -gt 0 ]]; then
54
- kill $pid_instruments
79
+ echo "Cleaning up instruments..."
80
+ kill -9 $pid_instruments
55
81
  fi
56
82
  }
57
83
 
84
+ # Running this file with "----test" will try to parse an error out of whatever
85
+ # is handed in to it from stdin. Use this method to double check your work if
86
+ # you need a custom "get_error_status" function above.
58
87
  if [[ $1 == "----test" ]]; then
59
88
  get_error_status
60
89
  else
@@ -7,14 +7,6 @@ module Bwoken
7
7
  class Coffeescript
8
8
  class << self
9
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
10
  def coffee_script_source
19
11
  IO.read(CoffeeScript::Source.bundled_path)
20
12
  end
@@ -23,75 +15,29 @@ module Bwoken
23
15
  @context ||= ExecJS.compile(coffee_script_source)
24
16
  end
25
17
 
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
18
+ def precompile coffeescript
19
+ coffeescript.lines.partition {|line| line =~ /^#import .*$/}.map(&:join)
35
20
  end
36
21
 
37
- def compiled_javascript_path
38
- File.join(Bwoken.tmp_path, 'javascript')
39
- end
40
-
41
- end
42
-
43
- attr_accessor :import_strings
22
+ def compile source, target
23
+ import_strings, sans_imports = precompile(IO.read source)
44
24
 
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
25
+ javascript = self.context.call 'CoffeeScript.compile', sans_imports, :bare => true
53
26
 
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
27
+ write import_strings, javascript, :to => target
28
+ end
82
29
 
83
- def remove_imports raw_coffeescript
84
- raw_coffeescript.gsub(/#import .*$/,'')
85
- end
30
+ def write *args
31
+ to_hash = args.last
32
+ chunks = args[0..-2]
86
33
 
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
34
+ File.open(to_hash[:to], 'w') do |io|
35
+ chunks.each do |chunk|
36
+ io.puts chunk unless chunk.nil? || chunk == ''
37
+ end
38
+ end
93
39
  end
94
- end
95
40
 
41
+ end
96
42
  end
97
43
  end
@@ -1,42 +1,41 @@
1
1
  require 'bwoken'
2
+ require 'rake/clean'
2
3
 
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
4
+ COFFEESCRIPTS = FileList['integration/coffeescript/**/*.coffee']
5
+ COMPILED_COFFEE = COFFEESCRIPTS.pathmap('%{^integration/coffeescript,integration/tmp/javascript}d/%n.js')
6
+ JAVASCRIPTS = FileList['integration/javascript/**/*.js']
7
+ COPIED_JAVASCRIPTS = JAVASCRIPTS.pathmap('%{^integration/javascript,integration/tmp/javascript}d/%f')
16
8
 
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
9
+ IPHONE_DIR = 'integration/coffeescript/iphone'
10
+ IPAD_DIR = 'integration/coffeescript/ipad'
11
+ VENDOR_JS_DIR = 'integration/javascript'
12
+ RESULTS_DIR = 'integration/tmp/results'
13
+ EXAMPLE_COFFEE = 'integration/coffeescript/iphone/example.coffee'
14
+ EXAMPLE_VENDOR_JS = 'integration/javascript/example_js.js'
25
15
 
16
+ directory IPHONE_DIR
17
+ directory IPAD_DIR
18
+ directory VENDOR_JS_DIR
19
+ directory RESULTS_DIR
20
+
21
+ file EXAMPLE_COFFEE => IPHONE_DIR do |t|
22
+ open(t.name, 'w') do |io|
23
+ io.puts '#import ../example_js.js'
24
+ io.puts 'target = UIATarget.localTarget()'
25
+ io.puts 'window = target.frontMostApp().mainWindow()'
26
26
  end
27
27
  end
28
28
 
29
- desc 'Remove result and trace files'
30
- task :clean do
31
- print "Removing #{Bwoken.tmp_path}/* ... "
32
- system "rm -rf #{Bwoken.tmp_path}/*"
33
- puts 'done.'
29
+ file EXAMPLE_VENDOR_JS => VENDOR_JS_DIR do |t|
30
+ open(t.name, 'w') do |io|
31
+ io.puts '/* Place your javascript here */'
32
+ end
34
33
  end
35
34
 
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
35
+ namespace :bwoken do
36
+ desc 'Create bwoken skeleton folders'
37
+ task :init => [IPAD_DIR, RESULTS_DIR, EXAMPLE_COFFEE, EXAMPLE_VENDOR_JS]
38
+ end
40
39
 
41
40
  desc 'Compile the workspace'
42
41
  task :build do
@@ -44,11 +43,31 @@ task :build do
44
43
  raise unless exit_status == 0
45
44
  end
46
45
 
47
- task :coffeescript do
48
- Bwoken::Coffeescript.clean
49
- Bwoken::Coffeescript.compile_all
46
+ COMPILED_COFFEE.zip(COFFEESCRIPTS).each do |target, source|
47
+ containing_dir = target.pathmap('%d')
48
+ directory containing_dir
49
+ file target => [containing_dir, source] do
50
+ Bwoken::Coffeescript.compile source, target
51
+ end
50
52
  end
51
53
 
54
+ COPIED_JAVASCRIPTS.zip(JAVASCRIPTS).each do |target, source|
55
+ containing_dir = target.pathmap('%d')
56
+ directory containing_dir
57
+ file target => [containing_dir, source] do
58
+ sh "cp #{source} #{target}"
59
+ end
60
+ end
61
+
62
+ desc 'Compile coffeescript to javascript and copy vendor javascript'
63
+ task :coffeescript => (COMPILED_COFFEE + COPIED_JAVASCRIPTS)
64
+
65
+ CLEAN.include('integration/tmp/javascript')
66
+ CLOBBER.include('integration/tmp')
67
+
68
+
69
+
70
+
52
71
  device_families = %w(iphone ipad)
53
72
 
54
73
  device_families.each do |device_family|
@@ -1,3 +1,3 @@
1
1
  module Bwoken
2
- VERSION = "1.0.0" unless defined?(::Bwoken::VERSION)
2
+ VERSION = "1.0.1" unless defined?(::Bwoken::VERSION)
3
3
  end
data/lib/bwoken.rb CHANGED
@@ -34,7 +34,7 @@ module Bwoken
34
34
  end
35
35
 
36
36
  def test_suite_path
37
- Bwoken::Coffeescript.compiled_javascript_path
37
+ File.join(tmp_path, 'javascript')
38
38
  end
39
39
 
40
40
  def path_to_automation_template
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: 1.0.0
4
+ version: 1.0.1
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-04-12 00:00:00.000000000 Z
13
+ date: 2012-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-script-source
17
- requirement: &70255276428720 !ruby/object:Gem::Requirement
17
+ requirement: &70103534295920 !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: *70255276428720
25
+ version_requirements: *70103534295920
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: colorful
28
- requirement: &70255276427380 !ruby/object:Gem::Requirement
28
+ requirement: &70103534294320 !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: *70255276427380
36
+ version_requirements: *70103534294320
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: execjs
39
- requirement: &70255276426320 !ruby/object:Gem::Requirement
39
+ requirement: &70103534293180 !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: *70255276426320
47
+ version_requirements: *70103534293180
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &70255276425800 !ruby/object:Gem::Requirement
50
+ requirement: &70103534292080 !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: *70255276425800
58
+ version_requirements: *70103534292080
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
- requirement: &70255276424840 !ruby/object:Gem::Requirement
61
+ requirement: &70103534290800 !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: *70255276424840
69
+ version_requirements: *70103534290800
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: guard-rspec
72
- requirement: &70255276423820 !ruby/object:Gem::Requirement
72
+ requirement: &70103534289600 !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: *70255276423820
80
+ version_requirements: *70103534289600
81
81
  description: iOS UIAutomation Test Runner
82
82
  email:
83
83
  - brad@bendyworks.com
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: 1868550205244240029
117
+ hash: 4357248799734440989
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: 1868550205244240029
126
+ hash: 4357248799734440989
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 1.8.17
129
+ rubygems_version: 1.8.16
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;