minitest-instrument-db 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/migrations/1_create_table.rb +19 -0
- data/lib/minitest-instrument-db.rb +59 -0
- data/lib/minitest-instrument-db/version.rb +7 -0
- data/minitest-instrument-db.gemspec +25 -0
- metadata +101 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
class CreateTable < ActiveRecord::Migration
|
3
|
+
|
4
|
+
def self.up
|
5
|
+
|
6
|
+
create_table "minitest_test_methods", :force => true do |t|
|
7
|
+
t.string "project", :null => false
|
8
|
+
t.string "machine", :null => false
|
9
|
+
t.string "test_id", :null => false
|
10
|
+
|
11
|
+
t.string "klass", :null => false
|
12
|
+
t.string "method", :null => false
|
13
|
+
t.boolean "exception", :null => false
|
14
|
+
t.time "execution_time", :null => false
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
|
6
|
+
module Instrument
|
7
|
+
|
8
|
+
module Db
|
9
|
+
|
10
|
+
class MinitestTestMethod < ActiveRecord::Base
|
11
|
+
set_table_name :minitest_test_methods
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.try_configuration_at(*params)
|
15
|
+
configuration_at(*params)
|
16
|
+
rescue
|
17
|
+
puts "Instrumenting test methods is disabled due to exception"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configuration_at(database_yml, options = {})
|
21
|
+
options[:project] ||= "Unknown"
|
22
|
+
options[:machine] ||= begin
|
23
|
+
require 'socket'
|
24
|
+
Socket.gethostname
|
25
|
+
end
|
26
|
+
|
27
|
+
connection = ActiveRecord::Base.connection rescue nil
|
28
|
+
ActiveRecord::Base.configurations.merge! YAML::load( IO.read( database_yml ) )
|
29
|
+
ActiveRecord::Base.establish_connection("minitest-instrument-db")
|
30
|
+
|
31
|
+
ActiveRecord::Migrator.migrate( File.join( File.dirname(__FILE__), 'migrations' ) )
|
32
|
+
|
33
|
+
MinitestTestMethod.establish_connection("minitest-instrument-db")
|
34
|
+
|
35
|
+
ActiveSupport::Notifications.subscribe "test.finished" do |name, start, finish, id, payload|
|
36
|
+
MinitestTestMethod.create!(
|
37
|
+
project: options[:project],
|
38
|
+
machine: options[:machine],
|
39
|
+
test_id: id,
|
40
|
+
klass: payload[:klass],
|
41
|
+
method: payload[:test],
|
42
|
+
exception: !!payload[:exception],
|
43
|
+
execution_time: finish - start
|
44
|
+
# created_at !!
|
45
|
+
)
|
46
|
+
end
|
47
|
+
ensure
|
48
|
+
if connection
|
49
|
+
config = ActiveRecord::Base.connection.instance_variable_get(:@config).stringify_keys
|
50
|
+
name, configuration = ActiveRecord::Base.configurations.find{|k,v| v == config}
|
51
|
+
ActiveRecord::Base.establish_connection(name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "minitest-instrument-db/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "minitest-instrument-db"
|
7
|
+
s.version = Minitest::Instrument::Db::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Robert Pankowecki"]
|
10
|
+
s.email = ["robert.pankowecki@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Store information about speed of test execution provided by minitest-instrument in database}
|
13
|
+
s.description = %q{Store information about speed of test execution provided by minitest-instrument in database}
|
14
|
+
|
15
|
+
s.rubyforge_project = "minitest-instrument-db"
|
16
|
+
|
17
|
+
s.required_rubygems_version = ">= 1.3.6"
|
18
|
+
s.add_dependency "activerecord", "~> 3.0"
|
19
|
+
s.add_development_dependency "bundler", "~> 1.0.0"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-instrument-db
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Robert Pankowecki
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-22 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activerecord
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
version: "3.0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: bundler
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
version: 1.0.0
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Store information about speed of test execution provided by minitest-instrument in database
|
50
|
+
email:
|
51
|
+
- robert.pankowecki@gmail.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- Rakefile
|
62
|
+
- lib/migrations/1_create_table.rb
|
63
|
+
- lib/minitest-instrument-db.rb
|
64
|
+
- lib/minitest-instrument-db/version.rb
|
65
|
+
- minitest-instrument-db.gemspec
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: ""
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 1
|
90
|
+
- 3
|
91
|
+
- 6
|
92
|
+
version: 1.3.6
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project: minitest-instrument-db
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Store information about speed of test execution provided by minitest-instrument in database
|
100
|
+
test_files: []
|
101
|
+
|