motion-specwrap 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in motion-specwrap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Keyvan Fatehi
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,18 @@
1
+ # Motion::Specwrap
2
+ You may use this gem if you are using a continuous integration server and wish that RubyMotion's `rake spec` command behaved as you would expect (e.g. return an exit status code that reflects your build condition)
3
+
4
+ ### Usage
5
+ Add `motion-specwrap` to your Gemfile, run `bundle`, add `motion-specwrap` to your project's Rakefile.
6
+ Now you may execute `bundle exec motion-specwrap` instead of `bundle exec rake spec` in order to get a proper exit value corresponding to your tests passing or failing. Woohoo!
7
+
8
+ ### The Problem
9
+ * When running "rake spec" in your RubyMotion project, you always get an exit status of 0, irrespective of the tests passing or failing. I believe this is the case because when checking the status code, we are actually getting the Simulator's status code, despite Bacon exiting (from within the context of the simulator) with a proper code.
10
+ * This is a problem when integrating your RubyMotion app into a continuous integration workflow which uses this exit status to determine if the build passed or failed. Specifically, I've created this in order to bring RubyMotion support to OctopusCI (http://octopusci.com)
11
+ * The problem was reported on 06-06-2012 here: https://groups.google.com/forum/?fromgroups#!topic/rubymotion/1unBYE0wJ-0
12
+
13
+ ### The Workaround
14
+ 1. Bacon is made to output its exit status code to standard output, such that:
15
+ 2. A wrapper script is provided which runs rake spec as normal, checks the exit status code printed by Bacon, and uses it to exit with the correct exit status code.
16
+
17
+ ### Final Remarks
18
+ I am hoping that lrz goes ahead and solves the original problem in a later patch to RubyMotion. Until then, we can use this.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ require 'tempfile'
3
+
4
+ regexp = /Specwrap captured exit status code: (\d*)/
5
+
6
+ def watch_for(file, pattern)
7
+ linebuf = ""
8
+ f = File.open(file,"r")
9
+ f.seek(0,IO::SEEK_END)
10
+ while true do
11
+ select([f])
12
+ line = f.gets
13
+ if !line.nil?
14
+ if (matches = line.match(pattern))
15
+ exit(matches[1].to_i)
16
+ else
17
+ if line.include? "\n"
18
+ puts linebuf + line
19
+ linebuf.clear
20
+ else
21
+ linebuf << line
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ file = Tempfile.new "motion-specwrap"
29
+
30
+ begin
31
+ file_watch_thread = Thread.new do
32
+ watch_for(file.path, regexp)
33
+ end
34
+ Open3.popen2e("rake spec > #{file.path}") do |stdin, out_and_err, wait_thr|
35
+ while (line = out_and_err.gets)
36
+ puts line
37
+ end
38
+ end
39
+ ensure
40
+ file_watch_thread.join unless file_watch_thread.nil?
41
+ file.close
42
+ file.unlink
43
+ end
@@ -0,0 +1,12 @@
1
+ module Motion
2
+ module Project
3
+ class Config
4
+ alias :specwrap_original_spec_files :spec_files
5
+ def spec_files
6
+ [
7
+ File.expand_path(File.dirname(__FILE__) + '/spec_setup.rb')
8
+ ] + specwrap_original_spec_files
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module Bacon
2
+ def self.context_did_finish(context)
3
+ handle_specification_end
4
+ Counter[:context_depth] -= 1
5
+ if (@current_context_index + 1) < @contexts.size
6
+ @current_context_index += 1
7
+ run
8
+ else
9
+ # DONE
10
+ handle_summary
11
+ status_code = Counter.values_at(:failed, :errors).inject(:+)
12
+ puts "Specwrap captured exit status code: #{status_code}"
13
+ exit(status_code)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ module Specwrap
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "motion-specwrap/version"
2
+ require "motion-specwrap/config"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-specwrap/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Keyvan Fatehi"]
6
+ gem.email = ["keyvanfatehi@gmail.com"]
7
+ gem.description = "Exit value support wrapper for RubyMotion's 'rake spec'"
8
+ gem.summary = "Exit value support wrapper for RubyMotion's 'rake spec'"
9
+ gem.homepage = "https://github.com/mdks/motion-specwrap"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "motion-specwrap"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Motion::Specwrap::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-specwrap
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Keyvan Fatehi
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2012-06-07 00:00:00 -07:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description: Exit value support wrapper for RubyMotion's 'rake spec'
21
+ email:
22
+ - keyvanfatehi@gmail.com
23
+ executables:
24
+ - motion-specwrap
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - .gitignore
31
+ - Gemfile
32
+ - LICENSE
33
+ - README.md
34
+ - Rakefile
35
+ - bin/motion-specwrap
36
+ - lib/motion-specwrap.rb
37
+ - lib/motion-specwrap/config.rb
38
+ - lib/motion-specwrap/spec_setup.rb
39
+ - lib/motion-specwrap/version.rb
40
+ - motion-specwrap.gemspec
41
+ has_rdoc: true
42
+ homepage: https://github.com/mdks/motion-specwrap
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.6
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Exit value support wrapper for RubyMotion's 'rake spec'
71
+ test_files: []
72
+