autotest-screen 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ /pkg
data/.gvimrc ADDED
@@ -0,0 +1,24 @@
1
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2
+ " Setup tabs and vimproject
3
+
4
+ Project .vimproject
5
+
6
+ tabnew
7
+ tabnew
8
+ tabnew
9
+ tabnew
10
+ tabnew
11
+ tabnew
12
+ tabnew
13
+ tabnew
14
+ tabnew
15
+
16
+ tabdo Project
17
+ tabdo wincmd l
18
+ tabdo wincmd n
19
+
20
+ 1tabn
21
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
22
+
23
+
24
+ winpos 444 25
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2-rc1
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ project=$PWD cd=. {
2
+ }
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ vim:wfw fdl=1:
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+
2
+ source :gemcutter
3
+
4
+ group :runtime do
5
+ end
6
+
7
+ group :development do
8
+ gem 'rspec', '>= 2.0.0.beta.17'
9
+ end
10
+
11
+
12
+ # vim:ft=ruby:
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ rspec (2.0.0.beta.17)
6
+ rspec-core (= 2.0.0.beta.17)
7
+ rspec-expectations (= 2.0.0.beta.17)
8
+ rspec-mocks (= 2.0.0.beta.17)
9
+ rspec-core (2.0.0.beta.17)
10
+ rspec-expectations (2.0.0.beta.17)
11
+ diff-lcs (>= 1.1.2)
12
+ rspec-mocks (2.0.0.beta.17)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ rspec (>= 2.0.0.beta.17)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David J. Hamilton
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ = Autotest [Gnu] Screen
2
+
3
+ * Author: David J. Hamilton
4
+ * Homepage: http://github.com/hjdivad/autotest-screen
5
+ * Issues: http://github.com/hjdivad/autotest-screen/issues
6
+
7
+ Conceptually very similar to
8
+ autotest-growl<http://github.com/svoop/autotest-growl>, but notify the user via
9
+ the caption of the parent screen process.
10
+
11
+
12
+ = Requirements
13
+
14
+ * autotest >= 4.2.4
15
+
16
+
17
+ = Installation
18
+
19
+ Install the gem
20
+
21
+ gem install autotest-screen
22
+
23
+ and add the following to ~/.autotest
24
+
25
+ require 'autotest/screen'
26
+
27
+
28
+ = Usage
29
+
30
+ Autotest-screen only works when autotest is invoked from a descendent process of
31
+ gnu screen. The right pid is searched for via /proc.
32
+
33
+
34
+ = Note on Patches/Pull Requests
35
+
36
+ * Fork the project.
37
+ * Make your feature addition or bug fix.
38
+ * Add tests for it. This is important so I don't break it in a
39
+ future version unintentionally.
40
+ * Commit, do not mess with rakefile, version, or history.
41
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
42
+ * Send me a pull request. Bonus points for topic branches.
43
+
44
+
45
+ = Notes of Thanks
46
+
47
+ This project is baesd on Sven Schwyn's excellent autotest-growl.
48
+
49
+
50
+ == Copyright
51
+
52
+ Copyright (c) 2010 David J. Hamilton. See LICENSE for details.
@@ -0,0 +1,85 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ Dir[ 'lib/tasks/**/*' ].each{ |l| require l }
5
+
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "autotest-screen"
11
+ gem.summary = %Q{Update Gnu Screen caption with autotest results.}
12
+ gem.description = %Q{
13
+ Update Gnu Screen caption with autotest results.
14
+
15
+ Specifically, when autotest is running with an ancestor [Gnu] screen
16
+ process, have that screen's caption set when autotest runs tests.
17
+
18
+ Conceptually similar to autotest-growl but with a different notification system.
19
+ }
20
+ gem.email = "autotest-screen@hjdivad.com"
21
+ gem.homepage = "http://github.com/hjdivad/autotest-screen"
22
+ gem.authors = ["David J. Hamilton"]
23
+
24
+ if File.exists? 'Gemfile'
25
+ require 'bundler'
26
+ bundler = Bundler.load
27
+ bundler.dependencies_for( :runtime ).each do |dep|
28
+ gem.add_dependency dep.name, dep.requirement.to_s
29
+ end
30
+ bundler.dependencies_for( :development ).each do |dep|
31
+ gem.add_development_dependency dep.name, dep.requirement.to_s
32
+ end
33
+ end
34
+
35
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
36
+ end
37
+ Jeweler::GemcutterTasks.new
38
+ rescue LoadError
39
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
40
+ end
41
+
42
+
43
+ desc "Write out build version. You must supply BUILD."
44
+ task 'version:write:build' do
45
+ unless ENV.has_key? 'BUILD'
46
+ abort "Must supply BUILD=<build> to write out build version number."
47
+ end
48
+ y = YAML::load_file( "VERSION.yml" )
49
+ v = {
50
+ :major => 0, :minor => 0, :patch => 0, :build => 0
51
+ }
52
+ v.merge!( y ) if y.is_a? Hash
53
+ v[ :build ] = ENV['BUILD']
54
+ File.open( "VERSION.yml", "w" ){|f| f.puts YAML::dump( v )}
55
+ end
56
+
57
+ task 'version:bump:build' do
58
+ y = YAML::load_file( "VERSION.yml" )
59
+ v = {
60
+ :major => 0, :minor => 0, :patch => 0, :build => 0
61
+ }
62
+ v.merge!( y ) if y.is_a? Hash
63
+
64
+ raise "Can't bump build: not a number" unless v[:build].is_a? Numeric
65
+ v[ :build ] += 1
66
+
67
+ v.each{|k,v| ENV[ k.to_s.upcase ] = v.to_s}
68
+ Rake::Task["version:write"].invoke
69
+ end
70
+
71
+
72
+ desc "Run all specs."
73
+ task :spec do
74
+ sh "rspec spec"
75
+ end
76
+
77
+
78
+ begin
79
+ require 'yard'
80
+ YARD::Rake::YardocTask.new
81
+ rescue LoadError
82
+ task :yardoc do
83
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
84
+ end
85
+ end
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 0
5
+ :build: "1"
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{autotest-screen}
8
+ s.version = "0.1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David J. Hamilton"]
12
+ s.date = %q{2010-07-15}
13
+ s.description = %q{
14
+ Update Gnu Screen caption with autotest results.
15
+
16
+ Specifically, when autotest is running with an ancestor [Gnu] screen
17
+ process, have that screen's caption set when autotest runs tests.
18
+
19
+ Conceptually similar to autotest-growl but with a different notification system.
20
+ }
21
+ s.email = %q{autotest-screen@hjdivad.com}
22
+ s.extra_rdoc_files = [
23
+ "LICENSE",
24
+ "README.rdoc"
25
+ ]
26
+ s.files = [
27
+ ".gitignore",
28
+ ".gvimrc",
29
+ ".rspec",
30
+ ".rvmrc",
31
+ ".vim/ftplugin/.gitignore",
32
+ ".vim/plugin/.gitignore",
33
+ ".vimproject",
34
+ "Gemfile",
35
+ "Gemfile.lock",
36
+ "LICENSE",
37
+ "README.rdoc",
38
+ "Rakefile",
39
+ "VERSION.yml",
40
+ "autotest-screen.gemspec",
41
+ "autotest/discover.rb",
42
+ "lib/autotest-screen.rb",
43
+ "lib/autotest/result.rb",
44
+ "lib/autotest/screen.rb",
45
+ "spec/autotest-screen_spec.rb",
46
+ "spec/spec_helper.rb"
47
+ ]
48
+ s.homepage = %q{http://github.com/hjdivad/autotest-screen}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.3.7}
52
+ s.summary = %q{Update Gnu Screen caption with autotest results.}
53
+ s.test_files = [
54
+ "spec/spec_helper.rb",
55
+ "spec/autotest-screen_spec.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
69
+ end
70
+ end
71
+
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'autotest'
3
+ require 'autotest/result'
4
+ require 'autotest/screen'
@@ -0,0 +1,64 @@
1
+ class Autotest::Result
2
+
3
+ ##
4
+ # Analyze test result lines and return the numbers in a hash.
5
+ def initialize( autotest )
6
+ @numbers = {}
7
+ lines = autotest.results.map {|s| s.gsub(/(\e.*?m|\n)/, '') } # remove escape sequences
8
+ lines.reject! {|line| !line.match(/\d+\s+(example|test|scenario|step)s?/) } # isolate result numbers
9
+ lines.each do |line|
10
+ prefix = nil
11
+ line.scan(/([1-9]\d*)\s(\w+)/) do |number, kind|
12
+ kind.sub!(/s$/, '') # singularize
13
+ kind.sub!(/failure/, 'failed') # homogenize
14
+ if prefix
15
+ @numbers["#{prefix}-#{kind}"] = number.to_i
16
+ else
17
+ @numbers[kind] = number.to_i
18
+ prefix = kind
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ ##
25
+ # Determine the testing framework used.
26
+ def framework
27
+ case
28
+ when @numbers['test'] then 'test-unit'
29
+ when @numbers['example'] then 'rspec'
30
+ when @numbers['scenario'] then 'cucumber'
31
+ end
32
+ end
33
+
34
+ ##
35
+ # Determine whether a result exists at all.
36
+ def exists?
37
+ !@numbers.empty?
38
+ end
39
+
40
+ ##
41
+ # Check whether a specific result is present.
42
+ def has?(kind)
43
+ @numbers.has_key?(kind)
44
+ end
45
+
46
+ ##
47
+ # Get a plain result number.
48
+ def [](kind)
49
+ @numbers[kind]
50
+ end
51
+
52
+ ##
53
+ # Get a labelled result number. The prefix is removed and the label pluralized if necessary.
54
+ def get(kind)
55
+ "#{@numbers[kind]} #{kind.sub(/^.*-/, '')}#{'s' if @numbers[kind] != 1 && !kind.match(/(ed|ing)$/)}" if @numbers[kind]
56
+ end
57
+
58
+ ##
59
+ # Get the fatal error if any.
60
+ def fatal_error
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,100 @@
1
+ require 'rubygems'
2
+ require 'autotest'
3
+ require 'rbconfig'
4
+
5
+ require 'autotest/result'
6
+
7
+ module Autotest::Screen
8
+
9
+ def self.green( text )
10
+ "%{dG}#{text}"
11
+ end
12
+
13
+ def self.red( text )
14
+ "%{dR}#{text}"
15
+ end
16
+
17
+ def self.yellow( text )
18
+ "%{dy}#{text}"
19
+ end
20
+
21
+ def self.screen_pid( pid=Process.ppid )
22
+ @screen_pid ||= lambda {
23
+ status = File.read( "/proc/#{pid}/stat" )
24
+ unless status =~ /(\d+) \((.*?)\) \w (\d+)/
25
+ raise "Trouble reading status of process #{pid}"
26
+ end
27
+
28
+ pid, exe, ppid = $1, $2, $3
29
+ if exe =~ /^screen/i
30
+ pid
31
+ else
32
+ screen_pid( ppid )
33
+ end
34
+ }.call
35
+ end
36
+
37
+ def self.screen_caption=( caption )
38
+ system %Q{ screen -S #{screen_pid} -X eval 'caption always "#{caption}"' }
39
+ rescue
40
+ STDERR.puts "Unable to find parent screen process."
41
+ STDERR.puts $!.message
42
+ STDERR.puts $!.backtrace.join( "\n" )
43
+ end
44
+
45
+ def self.clear_screen_caption
46
+ system %Q{ screen -S #{screen_pid} -X eval 'caption splitonly' }
47
+ rescue
48
+ STDERR.puts "Unable to find parent screen process."
49
+ STDERR.puts $!.message
50
+ STDERR.puts $!.backtrace.join( "\n" )
51
+ end
52
+
53
+
54
+ def self.update( kind, num=nil, total=num )
55
+ case kind
56
+ when :failure
57
+ self.screen_caption = red(
58
+ " #{num} failed from #{total}."
59
+ )
60
+ when :pending
61
+ self.screen_caption = yellow(
62
+ " #{num} pending from #{total}."
63
+ )
64
+ when :success
65
+ self.screen_caption = green(
66
+ " #{num} passed."
67
+ )
68
+ when :error
69
+ self.screen_caption = red( " Error running tests." )
70
+ else
71
+ raise "Unexpected kind of update #{kind}"
72
+ end
73
+ end
74
+
75
+
76
+ ##
77
+ # Parse the RSpec and Test::Unit results and send them to Growl.
78
+ Autotest.add_hook :ran_command do |autotest|
79
+ result = Autotest::Result.new( autotest )
80
+ if result.exists?
81
+ case result.framework
82
+ when 'rspec'
83
+ if result.has?( 'example-failed' )
84
+ update :failure, result[ 'example-failed' ], result[ 'example' ]
85
+ elsif result.has?( 'example-pending' )
86
+ update :pending, result[ 'example-pending' ], result[ 'example' ]
87
+ else
88
+ update :success, result.get( 'example' )
89
+ end
90
+ end
91
+ else
92
+ update :error
93
+ end
94
+
95
+ false
96
+ end
97
+
98
+ Autotest.add_hook( :died ){ clear_screen_caption }
99
+ Autotest.add_hook( :quit ){ clear_screen_caption }
100
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe "autotest-screen" do
4
+ before do
5
+ @autotest = Autotest.new
6
+ @autotest.hook( :updated )
7
+ end
8
+
9
+ describe "handling results" do
10
+
11
+ describe "for RSpec" do
12
+ it "should show a 'passed' notification" do
13
+ Autotest::Screen.should_receive( :screen_caption= ).with(
14
+ "%{dG} 10 examples passed."
15
+ )
16
+ @autotest.results = [ "10 examples, 0 failures" ]
17
+ @autotest.hook( :ran_command )
18
+ end
19
+
20
+ it "should show a 'failed' notification" do
21
+ Autotest::Screen.should_receive( :screen_caption= ).with(
22
+ "%{dR} 1 failed from 10."
23
+ )
24
+ @autotest.results = [ "10 examples, 1 failures" ]
25
+ @autotest.hook( :ran_command )
26
+ end
27
+
28
+ it "should show a 'pending' notification" do
29
+ Autotest::Screen.should_receive( :screen_caption= ).with(
30
+ "%{dy} 1 pending from 10."
31
+ )
32
+ @autotest.results = [ "10 examples, 0 failures, 1 pending" ]
33
+ @autotest.hook( :ran_command )
34
+ end
35
+
36
+ it "should show an 'error' notification" do
37
+ Autotest::Screen.should_receive( :screen_caption= ).with(
38
+ "%{dR} Error running tests."
39
+ )
40
+ @autotest.results = []
41
+ @autotest.hook( :ran_command )
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "handling autotest exit" do
47
+ it "should clear the screen caption on quitting" do
48
+ Autotest::Screen.should_receive( :clear_screen_caption )
49
+ @autotest.hook( :quit )
50
+ end
51
+
52
+ it "should clear the screen caption on error" do
53
+ Autotest::Screen.should_receive( :clear_screen_caption )
54
+ @autotest.hook( :died )
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'autotest'
5
+ require 'autotest-screen'
6
+
7
+
8
+ # Track original $stdout, $stderr write methods so we can “unmock” them for
9
+ # debugging
10
+
11
+ class << $stdout
12
+ alias_method :real_write, :write
13
+ end
14
+ class << $stderr
15
+ alias_method :real_write, :write
16
+ end
17
+
18
+
19
+ class Object
20
+ def debug
21
+ # For debugging, restore stubbed write
22
+ class << $stdout
23
+ alias_method :write, :real_write
24
+ end
25
+ class << $stderr
26
+ alias_method :write, :real_write
27
+ end
28
+
29
+ require 'ruby-debug'
30
+ debugger
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autotest-screen
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 0.1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David J. Hamilton
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-15 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 0
32
+ - beta
33
+ - 17
34
+ version: 2.0.0.beta.17
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id001
38
+ description: "\n Update Gnu Screen caption with autotest results.\n\n Specifically, when autotest is running with an ancestor [Gnu] screen\n process, have that screen's caption set when autotest runs tests.\n\n Conceptually similar to autotest-growl but with a different notification system.\n "
39
+ email: autotest-screen@hjdivad.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - LICENSE
46
+ - README.rdoc
47
+ files:
48
+ - .gitignore
49
+ - .gvimrc
50
+ - .rspec
51
+ - .rvmrc
52
+ - .vim/ftplugin/.gitignore
53
+ - .vim/plugin/.gitignore
54
+ - .vimproject
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION.yml
61
+ - autotest-screen.gemspec
62
+ - autotest/discover.rb
63
+ - lib/autotest-screen.rb
64
+ - lib/autotest/result.rb
65
+ - lib/autotest/screen.rb
66
+ - spec/autotest-screen_spec.rb
67
+ - spec/spec_helper.rb
68
+ has_rdoc: true
69
+ homepage: http://github.com/hjdivad/autotest-screen
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project:
96
+ rubygems_version: 1.3.7
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Update Gnu Screen caption with autotest results.
100
+ test_files:
101
+ - spec/spec_helper.rb
102
+ - spec/autotest-screen_spec.rb