keeptesting 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in keeptesting.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+
2
+ DESCRIPTION:
3
+ ===========
4
+
5
+ The simplest way to autotest your code - no matter what language or
6
+ framework you use.
7
+
8
+ Run it from the command line. Specify 1) how tests are launched and 2)
9
+ how a failed test looks in the terminal.
10
+
11
+ The tests will run on every file change in your project - results are
12
+ fed back through a pretty html console.
13
+
14
+ USAGE:
15
+ ======
16
+
17
+ `keeptesting [options] -f REGEX_MATCHING_TEST_FAILURE -t TEST_COMMAND`
18
+
19
+ By default, launch it in the root of your project.
20
+
21
+
22
+ EXAMPLES:
23
+ ======
24
+
25
+ In ruby:
26
+
27
+ `keeptesting -f 'Failure|Error' -t 'rake test'`
28
+
29
+
30
+ PREREQUISITES:
31
+ ==============
32
+
33
+ You must have some version of Ruby and RubyGems installed first. That's it.
34
+
35
+
36
+ INSTALL:
37
+ ========
38
+
39
+ `gem install keeptesting`
40
+
41
+
42
+ TODO:
43
+ =====
44
+
45
+
46
+ LICENSE:
47
+ ========
48
+
49
+ (The MIT License)
50
+
51
+ Copyright (c) 2012 Thomas Kjeldahl Nilsson
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining
54
+ a copy of this software and associated documentation files (the
55
+ 'Software'), to deal in the Software without restriction, including
56
+ without limitation the rights to use, copy, modify, merge, publish,
57
+ distribute, sublicense, and/or sell copies of the Software, and to
58
+ permit persons to whom the Software is furnished to do so, subject to
59
+ the following conditions:
60
+
61
+ The above copyright notice and this permission notice shall be
62
+ included in all copies or substantial portions of the Software.
63
+
64
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
65
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
67
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
68
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |i|
5
+ i.test_files = FileList['test/test_*.rb']
6
+ #i.verbose = true
7
+ end
data/bin/keeptesting ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "keeptesting"
4
+ require "optparse"
5
+ require 'fssm'
6
+
7
+ def parse_options
8
+ options = {}
9
+
10
+ OptionParser.new do |o|
11
+ o.banner = "Usage: keeptesting [options] -f 'FAILURE-MATCHING-REGEX' -t 'TEST-COMMAND'\n\n"
12
+
13
+ o.on("-f F", "--failure-matching-regex", "A regex that matches failing tests") { |f| options[:failure_regex] = f }
14
+ o.on("-t T", "--test-command", "Command to start your test(s)") { |t| options[:test_command] = t }
15
+
16
+ o.on("-c", "--command-line-mode", "Get test feedback in terminal") { options[:cli_mode] = true}
17
+
18
+ o.on("-h", "--help", "Help page") { puts o; exit }
19
+ o.on("-v", "--version", "Print version number") { |b| puts Keeptesting::VERSION; exit }
20
+
21
+ o.parse!
22
+ end
23
+
24
+ return options
25
+ end
26
+
27
+
28
+ options = parse_options
29
+
30
+ if !options[:failure_regex] || !options[:test_command]
31
+ puts "ERROR: missing args!" # TODO do this in optionsparse step above
32
+ end
33
+
34
+ if options[:cli_mode]
35
+ Keeptesting::CLI::start_test_loop(options)
36
+ else
37
+ Keeptesting::BrowserConsole.new(options)
38
+ end
39
+
40
+
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "keeptesting/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "keeptesting"
7
+ s.version = Keeptesting::VERSION
8
+ s.authors = ["Thomas Kjeldahl Nilsson"]
9
+ s.email = ["thomas@kjeldahlnilsson.net"]
10
+ s.homepage = "https://github.com/thomanil/keeptesting"
11
+ s.summary = %q{A stripped down CLI utility for reading tweets}
12
+ s.description = %q{Usage: keeptesting [options] TESTCOMMAND}
13
+
14
+ s.rubyforge_project = "keeptesting"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "OptionParser"
24
+ s.add_runtime_dependency "fssm"
25
+ s.add_runtime_dependency "sinatra"
26
+ s.add_runtime_dependency "foreman"
27
+
28
+ s.add_development_dependency "mocha"
29
+ s.add_development_dependency "shoulda"
30
+ s.add_development_dependency "minitest"
31
+ s.add_development_dependency "shoulda-context"
32
+
33
+ end
@@ -0,0 +1,8 @@
1
+ require "keeptesting/version"
2
+ require "keeptesting/common"
3
+ require "keeptesting/cli"
4
+ require "keeptesting/browser_console"
5
+
6
+ module Keeptesting
7
+
8
+ end
@@ -0,0 +1,61 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Keeptesting
4
+
5
+ require "fileutils"
6
+ require "rubygems"
7
+ require "yaml"
8
+
9
+ class BrowserConsole
10
+
11
+ def initialize(options={})
12
+ #watch_tests_in_other_thread(options)
13
+ start_console
14
+ end
15
+
16
+ RESULT_FILE_PATH = "/tmp/keeptesting-state.txt"
17
+
18
+ def store_last_test_summary(result, output)
19
+ File.open RESULT_FILE_PATH, "w" do |filebody|
20
+ filebody.write("#{result.to_s}\n")
21
+ filebody.write(output)
22
+ end
23
+ end
24
+
25
+ def retrieve_last_test_summary
26
+ result = false
27
+ output = ""
28
+ File.open RESULT_FILE_PATH, "r" do |filebody|
29
+ result = filebody.lines.first
30
+ output = filebody.to_s
31
+ end
32
+ return result, output
33
+ end
34
+
35
+ def testrun(options)
36
+ cmd = options[:test_command]
37
+ test_output = `#{cmd}`
38
+ test_succeeded = Keeptesting::Common::test_success?(test_output, options[:failure_regex])
39
+ store_last_test_summary(test_succeeded, test_output)
40
+ end
41
+
42
+ def watch_tests_in_other_thread(options)
43
+ puts "Starting test loop"
44
+ #Thread.new do
45
+ console = self
46
+ FSSM.monitor('.', '**/*') do
47
+ update {|base, relative| console.testrun(options)}
48
+ delete {|base, relative| console.testrun(options)}
49
+ create {|base, relative| console.testrun(options)}
50
+ end
51
+ #end
52
+ end
53
+
54
+ def start_console
55
+ puts "keeptesting web console starting - goto http://localhost:5000"
56
+ puts "---"
57
+ puts `ruby -Ilib webconsole.rb -p 5000`
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Keeptesting
4
+ module CLI
5
+
6
+ GREEN_TEXT="\033[32m"
7
+ YELLOW_TEXT="\033[33m"
8
+ RED_TEXT="\033[31m"
9
+ RESET_TEXT="\033[0m"
10
+
11
+
12
+ def self.testrun(options)
13
+ puts `clear`
14
+ puts "#{YELLOW_TEXT}RUNNING TESTS...#{RESET_TEXT}"
15
+
16
+ cmd = options[:test_command]
17
+ test_output = `#{cmd}`
18
+ test_succeded = Keeptesting::Common::test_success?(test_output, options[:failure_regex])
19
+ puts `clear`
20
+ if test_succeded
21
+ puts "#{GREEN_TEXT}SUCCESS!#{RESET_TEXT}\n\n\n"
22
+ else
23
+ puts "#{RED_TEXT}FAILURE!#{RESET_TEXT}\n\n\n"
24
+ end
25
+
26
+ puts test_output
27
+ end
28
+
29
+ def self.start_test_loop(options)
30
+ Keeptesting::CLI::testrun(options)
31
+ FSSM.monitor('.', '**/*') do
32
+ update {|base, relative| Keeptesting::CLI::testrun(options)}
33
+ delete {|base, relative| Keeptesting::CLI::testrun(options)}
34
+ create {|base, relative| Keeptesting::CLI::testrun(options)}
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Keeptesting
4
+ module Common
5
+
6
+ def self.test_success?(test_output, failure_regex)
7
+ true unless test_output =~ /#{failure_regex}/
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Keeptesting
2
+ VERSION = "0.2.0"
3
+ end
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require 'mocha'
4
+ require 'shoulda'
5
+ require 'shoulda-context'
6
+
7
+ require File.dirname(__FILE__) + '/../lib/keeptesting'
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class CalculatorTest < Test::Unit::TestCase
4
+ context "a calculator" do
5
+ should "add two numbers for the sum" do
6
+ assert_equal 4, (2+2)
7
+ end
8
+ end
9
+ end
data/views/index.erb ADDED
@@ -0,0 +1,8 @@
1
+
2
+ Result: <%= @result %> <br/>
3
+
4
+ Output: <br/>
5
+
6
+ <pre>
7
+ <%= @output %>
8
+ </pre>
File without changes
data/views/layout.erb ADDED
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <link href="/css/keeptesting.css" media="screen" rel="stylesheet" type="text/css" />
6
+ <title>Tweetskim</title>
7
+ </head>
8
+ <body>
9
+
10
+ <h1>Test status</h1>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/webconsole.rb ADDED
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rubygems'
3
+ require 'sinatra'
4
+ require 'keeptesting'
5
+
6
+ get '/' do
7
+ console = Keeptesting::BrowserConsole.new
8
+ @result, @output = console.retrieve_last_test_summary
9
+
10
+ erb :index
11
+ end
12
+
13
+ get '/latest-test' do
14
+ erb :latest_test, :layout => false
15
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: keeptesting
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Kjeldahl Nilsson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: OptionParser
16
+ requirement: &9076720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *9076720
25
+ - !ruby/object:Gem::Dependency
26
+ name: fssm
27
+ requirement: &9076300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *9076300
36
+ - !ruby/object:Gem::Dependency
37
+ name: sinatra
38
+ requirement: &9075880 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *9075880
47
+ - !ruby/object:Gem::Dependency
48
+ name: foreman
49
+ requirement: &9075460 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *9075460
58
+ - !ruby/object:Gem::Dependency
59
+ name: mocha
60
+ requirement: &9075040 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *9075040
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: &9074620 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *9074620
80
+ - !ruby/object:Gem::Dependency
81
+ name: minitest
82
+ requirement: &9074200 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *9074200
91
+ - !ruby/object:Gem::Dependency
92
+ name: shoulda-context
93
+ requirement: &9073780 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *9073780
102
+ description: ! 'Usage: keeptesting [options] TESTCOMMAND'
103
+ email:
104
+ - thomas@kjeldahlnilsson.net
105
+ executables:
106
+ - keeptesting
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - .gitignore
111
+ - Gemfile
112
+ - README.md
113
+ - Rakefile
114
+ - bin/keeptesting
115
+ - keeptesting.gemspec
116
+ - lib/keeptesting.rb
117
+ - lib/keeptesting/browser_console.rb
118
+ - lib/keeptesting/cli.rb
119
+ - lib/keeptesting/common.rb
120
+ - lib/keeptesting/version.rb
121
+ - public/css/keeptesting.css
122
+ - public/js/keeptesting.js
123
+ - test/test_helper.rb
124
+ - test/test_keeptesting.rb
125
+ - views/index.erb
126
+ - views/latest_test.erb
127
+ - views/layout.erb
128
+ - webconsole.rb
129
+ homepage: https://github.com/thomanil/keeptesting
130
+ licenses: []
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project: keeptesting
149
+ rubygems_version: 1.8.15
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: A stripped down CLI utility for reading tweets
153
+ test_files: []