build_log_parser 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +83 -0
- data/Rakefile +19 -0
- data/build_log_parser.gemspec +27 -0
- data/lib/build_log_parser/coverage_matcher.rb +32 -0
- data/lib/build_log_parser/duration_matcher.rb +27 -0
- data/lib/build_log_parser/parser.rb +35 -0
- data/lib/build_log_parser/phpunit_matcher.rb +22 -0
- data/lib/build_log_parser/rspec_matcher.rb +20 -0
- data/lib/build_log_parser/test_unit_matcher.rb +15 -0
- data/lib/build_log_parser/version.rb +3 -0
- data/lib/build_log_parser.rb +17 -0
- data/spec/fixtures/js.txt +1 -0
- data/spec/fixtures/phpunit.txt +11 -0
- data/spec/fixtures/phpunit_failure.txt +2 -0
- data/spec/fixtures/rspec.txt +10 -0
- data/spec/fixtures/rspec_multiple.txt +12 -0
- data/spec/fixtures/rspec_multiple_duration.txt +14 -0
- data/spec/fixtures/simplecov.txt +3 -0
- data/spec/fixtures/test_unit.txt +7 -0
- data/spec/fixtures/test_unit_2.txt +3 -0
- data/spec/lib/build_log_parser_spec.rb +30 -0
- data/spec/lib/parser_spec.rb +173 -0
- data/spec/spec_helper.rb +15 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7bc3c47b1f6e7bf65547ab0542c9a1295153043
|
4
|
+
data.tar.gz: 106338d3a1c8481784f0c4b869978920c3a45710
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a762bf3aefffba2089e8c69a34f121e9d80daffddd62f73b84aa8b3843daf541439141e38878cfbb74b0097daaa3789b2998122f2a7805c15623b5e1affda382
|
7
|
+
data.tar.gz: 70e5cc9525a37138e17c0567f4376afdac2e91ee6d693655271c35dc72548cda5121397352c3bdd3c8ea2852775cd0bab845265f85b881239dedd36a3e59b00a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Magnum CI
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# build_log_parser
|
2
|
+
|
3
|
+
Fetch metrics from build logs: tests, duration, coverage, etc.
|
4
|
+
|
5
|
+
[](https://magnum-ci.com/public/71629b4f296ef091fc02/builds)
|
6
|
+
[](https://codeclimate.com/github/magnumci/build_log_parser)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Install via rubygems:
|
11
|
+
|
12
|
+
```
|
13
|
+
gem install build_log_parser
|
14
|
+
```
|
15
|
+
|
16
|
+
Or with bundler:
|
17
|
+
|
18
|
+
```
|
19
|
+
gem "build_log_parser"
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Build log parser library provides an ability to fetch various metrics from build
|
25
|
+
logs. Supports tests, coverage and duration metrics from frameworks:
|
26
|
+
|
27
|
+
- RSpec (Ruby)
|
28
|
+
- Test::Unit (Ruby)
|
29
|
+
- NPM (Node.js)
|
30
|
+
- PHPUnit (PHP)
|
31
|
+
|
32
|
+
Example log output:
|
33
|
+
|
34
|
+
```
|
35
|
+
Finished in 2 minutes 23.4 seconds
|
36
|
+
1169 examples, 0 failures, 17 pending
|
37
|
+
Coverage report generated for RSpec to /app/coverage. 3816 / 4835 LOC (78.92%) covered.
|
38
|
+
```
|
39
|
+
|
40
|
+
Example usage:
|
41
|
+
|
42
|
+
``` ruby
|
43
|
+
require "build_log_parser"
|
44
|
+
|
45
|
+
# Initialize parser
|
46
|
+
parser = BuildLogParser::Parser.new(str)
|
47
|
+
|
48
|
+
# Get tests metrics
|
49
|
+
parser.tests
|
50
|
+
# => {:count=>1169, :failures=>0, :pending=>17}
|
51
|
+
|
52
|
+
# Get coverage metrics
|
53
|
+
parser.coverage
|
54
|
+
# => {:lines_covered=>3816, :lines_total=>4835, :coverage_percent=>78.92}
|
55
|
+
|
56
|
+
# Get duration
|
57
|
+
parser.duration
|
58
|
+
# => 143.4 (in seconds)
|
59
|
+
```
|
60
|
+
|
61
|
+
Alternative usage:
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
str = "your build log"
|
65
|
+
|
66
|
+
BuildLogParser.tests(str)
|
67
|
+
BuildLogParser.coverage(str)
|
68
|
+
BuildLogParser.duration(str)
|
69
|
+
```
|
70
|
+
|
71
|
+
## Tests
|
72
|
+
|
73
|
+
Execute test suite by running the following command:
|
74
|
+
|
75
|
+
```
|
76
|
+
bundle exec rake test
|
77
|
+
```
|
78
|
+
|
79
|
+
## License
|
80
|
+
|
81
|
+
The MIT License
|
82
|
+
|
83
|
+
Copyright (c) 2014 Magnum CI
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:test) do |t|
|
6
|
+
t.pattern = "spec/**/*_spec.rb"
|
7
|
+
t.verbose = false
|
8
|
+
end
|
9
|
+
|
10
|
+
task :console do
|
11
|
+
require "irb"
|
12
|
+
require "irb/completion"
|
13
|
+
require "build_log_parser"
|
14
|
+
|
15
|
+
ARGV.clear
|
16
|
+
IRB.start
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :test
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require "build_log_parser/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "build_log_parser"
|
9
|
+
spec.version = BuildLogParser::VERSION
|
10
|
+
spec.summary = "Parse build metrics from logs"
|
11
|
+
spec.description = "Parses various build metrics from builds logs (Rspec, Test::Unit, etc)"
|
12
|
+
spec.homepage = "https://github.com/magnumci/build_log_parser"
|
13
|
+
spec.authors = ["Dan Sosedoff"]
|
14
|
+
spec.email = ["dan.sosedoff@gmail.com"]
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.add_development_dependency "rake", "~> 10"
|
18
|
+
spec.add_development_dependency "rspec", "~> 2.13"
|
19
|
+
spec.add_development_dependency "simplecov", "~> 0.8"
|
20
|
+
|
21
|
+
spec.add_dependency "chronic_duration", "~> 0.10"
|
22
|
+
|
23
|
+
spec.files = `git ls-files`.split("\n")
|
24
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BuildLogParser
|
2
|
+
module CoverageMatcher
|
3
|
+
PATTERN = /\s([\d]+) \/ ([\d]+) LOC \(([\d]+\.[\d]+)%\) covered\./
|
4
|
+
|
5
|
+
def fetch_coverage(str)
|
6
|
+
fetch_rspec_coverage(str) ||
|
7
|
+
fetch_phpunit_coverage(str)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def fetch_rspec_coverage(str)
|
13
|
+
if body =~ PATTERN
|
14
|
+
{
|
15
|
+
lines_covered: $1.to_i,
|
16
|
+
lines_total: $2.to_i,
|
17
|
+
coverage_percent: $3.to_f
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def fetch_phpunit_coverage(str)
|
23
|
+
if body =~ /Lines:\s+([\d.]+)% \(([\d]+)\/([\d]+)\)/
|
24
|
+
{
|
25
|
+
lines_covered: $2.to_i,
|
26
|
+
lines_total: $3.to_i,
|
27
|
+
coverage_percent: $1.to_f
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BuildLogParser
|
2
|
+
module DurationMatcher
|
3
|
+
DURATION_PATTERNS = [
|
4
|
+
/^finished in (.*)/i,
|
5
|
+
/^finished tests in ([\d]\.[\d]+s),/i,
|
6
|
+
/ran [\d]+ tests in (.*)\n?/i,
|
7
|
+
/time: (.*), memory:/i,
|
8
|
+
/[\d]+ passing (.*)/
|
9
|
+
]
|
10
|
+
|
11
|
+
def fetch_duration(str)
|
12
|
+
DURATION_PATTERNS.map { |p| scan_duration(str, p) }.compact.reduce(:+)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def scan_duration(str, pattern)
|
18
|
+
str.
|
19
|
+
gsub(/(seconds|minutes|hours)\s\((.*)\)/, "").
|
20
|
+
gsub(/(([\d]+)\s?ms)/) { |m| "0.#{$2}s" }.
|
21
|
+
scan(pattern).
|
22
|
+
flatten.
|
23
|
+
map { |m| ChronicDuration.parse(m) }.
|
24
|
+
reduce(:+)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "build_log_parser/duration_matcher"
|
2
|
+
require "build_log_parser/coverage_matcher"
|
3
|
+
require "build_log_parser/rspec_matcher"
|
4
|
+
require "build_log_parser/test_unit_matcher"
|
5
|
+
require "build_log_parser/phpunit_matcher"
|
6
|
+
|
7
|
+
module BuildLogParser
|
8
|
+
class Parser
|
9
|
+
include DurationMatcher
|
10
|
+
include CoverageMatcher
|
11
|
+
include RspecMatcher
|
12
|
+
include TestUnitMatcher
|
13
|
+
include PHPUnitMatcher
|
14
|
+
|
15
|
+
attr_reader :body
|
16
|
+
|
17
|
+
def initialize(body)
|
18
|
+
@body = body
|
19
|
+
end
|
20
|
+
|
21
|
+
def duration
|
22
|
+
fetch_duration(body)
|
23
|
+
end
|
24
|
+
|
25
|
+
def tests
|
26
|
+
fetch_rspec_stats(body) ||
|
27
|
+
fetch_test_unit_stats(body) ||
|
28
|
+
fetch_phpunit_stats(body)
|
29
|
+
end
|
30
|
+
|
31
|
+
def coverage
|
32
|
+
fetch_coverage(body)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BuildLogParser
|
2
|
+
module PHPUnitMatcher
|
3
|
+
PHPUNIT_PATTERN = /^(OK|FAIL) \(([\d]+) tests/
|
4
|
+
PHPUNIT_PATTERN_ERROR = /Tests: ([\d]+), Assertions: [\d]+, Errors: ([\d]+)/
|
5
|
+
|
6
|
+
def fetch_phpunit_stats(str)
|
7
|
+
if str =~ PHPUNIT_PATTERN
|
8
|
+
{
|
9
|
+
count: $2.to_i,
|
10
|
+
failures: nil,
|
11
|
+
pending: nil
|
12
|
+
}
|
13
|
+
elsif str =~ PHPUNIT_PATTERN_ERROR
|
14
|
+
{
|
15
|
+
count: $1.to_i,
|
16
|
+
failures: $2.to_i,
|
17
|
+
pending: nil
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BuildLogParser
|
2
|
+
module RspecMatcher
|
3
|
+
RSPEC_PATTERN = /^([\d]+) examples, ([\d]+) failures(, ([\d]+) pending)?/m
|
4
|
+
|
5
|
+
def fetch_rspec_stats(str)
|
6
|
+
matches = str.scan(RSPEC_PATTERN)
|
7
|
+
return if matches.empty?
|
8
|
+
|
9
|
+
result = { count: 0, failures: 0, pending: 0 }
|
10
|
+
|
11
|
+
matches.each do |m|
|
12
|
+
result[:count] += m[0].to_i if m[0] # examples
|
13
|
+
result[:failures] += m[1].to_i if m[1] # failures
|
14
|
+
result[:pending] += m[3].to_i if m[3] # pending
|
15
|
+
end
|
16
|
+
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BuildLogParser
|
2
|
+
module TestUnitMatcher
|
3
|
+
TEST_UNIT_PATTERN = /^([\d]+) (tests|runs), ([\d]+) assertions, ([\d]+) failures, ?([\d]+) errors(, ([\d]+) skips)?$/m
|
4
|
+
|
5
|
+
def fetch_test_unit_stats(str)
|
6
|
+
if str =~ TEST_UNIT_PATTERN
|
7
|
+
{
|
8
|
+
count: $1.to_i,
|
9
|
+
failures: $4.to_i,
|
10
|
+
pending: $7 ? $7.to_i : nil
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "build_log_parser/version"
|
2
|
+
require "build_log_parser/parser"
|
3
|
+
require "chronic_duration"
|
4
|
+
|
5
|
+
module BuildLogParser
|
6
|
+
def self.tests(str)
|
7
|
+
Parser.new(str).tests
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.coverage(str)
|
11
|
+
Parser.new(str).coverage
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.duration(str)
|
15
|
+
Parser.new(str).duration
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
JS 1.9.7 (Linux): Executed 202 of 202 SUCCESS (12.156 secs / 11.47 secs)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Pending:
|
2
|
+
BaseMailer
|
3
|
+
# No reason given
|
4
|
+
# ./spec/mailers/base_mailer_spec.rb:4
|
5
|
+
OrderMailer#on_complete sends order notification to buyer
|
6
|
+
# No reason given
|
7
|
+
# ./spec/mailers/build_mailer_spec.rb:5
|
8
|
+
|
9
|
+
Finished in 4.8 seconds
|
10
|
+
71 examples, 0 failures, 2 pending
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Finished in 58.09 seconds
|
2
|
+
1017 examples, 0 failures
|
3
|
+
|
4
|
+
Finished in 57.53 seconds
|
5
|
+
499 examples, 27 failures
|
6
|
+
|
7
|
+
Finished in 13 minutes 42 seconds
|
8
|
+
1126 examples, 377 failures
|
9
|
+
|
10
|
+
Finished in 3.93 seconds
|
11
|
+
615 examples, 0 failures
|
12
|
+
|
13
|
+
Finished in 0.54247 seconds
|
14
|
+
54 examples, 0 failures
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BuildLogParser do
|
4
|
+
before do
|
5
|
+
[:tests, :coverage, :duration].each do |method_name|
|
6
|
+
BuildLogParser::Parser.any_instance.stub(method_name)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".tests" do
|
11
|
+
it "returns tests metrics" do
|
12
|
+
expect_any_instance_of(BuildLogParser::Parser).to receive(:tests)
|
13
|
+
described_class.tests("foo")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".coverage" do
|
18
|
+
it "returns coverage metrics" do
|
19
|
+
expect_any_instance_of(BuildLogParser::Parser).to receive(:coverage)
|
20
|
+
described_class.coverage("foo")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".duration" do
|
25
|
+
it "returns duration metrics" do
|
26
|
+
expect_any_instance_of(BuildLogParser::Parser).to receive(:duration)
|
27
|
+
described_class.duration("foo")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BuildLogParser::Parser do
|
4
|
+
let(:parser) { described_class.new(log) }
|
5
|
+
|
6
|
+
describe "#tests" do
|
7
|
+
let(:result) { parser.tests }
|
8
|
+
|
9
|
+
context "when no test data" do
|
10
|
+
let(:log) { "foobar" }
|
11
|
+
|
12
|
+
it "returns nil" do
|
13
|
+
expect(result).to be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "on test unit data" do
|
18
|
+
let(:log) { fixture "test_unit.txt" }
|
19
|
+
|
20
|
+
it "returns test metrics" do
|
21
|
+
expect(result).to eq Hash(
|
22
|
+
count: 11,
|
23
|
+
failures: 4,
|
24
|
+
pending: nil
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "on alternative syntax" do
|
29
|
+
let(:log) { fixture "test_unit_2.txt" }
|
30
|
+
|
31
|
+
it "returns tests metrics" do
|
32
|
+
expect(result).to eq Hash(
|
33
|
+
count: 3971,
|
34
|
+
failures: 11,
|
35
|
+
pending: 1
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "on rspec data" do
|
42
|
+
let(:log) { fixture "rspec.txt" }
|
43
|
+
|
44
|
+
it "returns rspec test metrics" do
|
45
|
+
expect(result).to eq Hash(
|
46
|
+
count: 71,
|
47
|
+
failures: 0,
|
48
|
+
pending: 2
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "on rspec with multiple runs" do
|
54
|
+
let(:log) { fixture "rspec_multiple.txt" }
|
55
|
+
|
56
|
+
it "returns summarized test metrics" do
|
57
|
+
expect(result).to eq Hash(
|
58
|
+
count: 1686,
|
59
|
+
failures: 15,
|
60
|
+
pending: 3
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with phpunit data" do
|
66
|
+
let(:log) { fixture "phpunit.txt" }
|
67
|
+
|
68
|
+
it "returns test metrics" do
|
69
|
+
expect(result).to eq Hash(
|
70
|
+
count: 5,
|
71
|
+
failures: nil,
|
72
|
+
pending: nil
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
context "on failure" do
|
77
|
+
let(:log) { fixture "phpunit_failure.txt" }
|
78
|
+
|
79
|
+
it "returns test metrics" do
|
80
|
+
expect(result).to eq Hash(
|
81
|
+
count: 158,
|
82
|
+
failures: 3,
|
83
|
+
pending: nil
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#coverage" do
|
91
|
+
let(:log) { "Coverage report generated for RSpec to /tmp/coverage. 3354 / 5045 LOC (66.48%) covered." }
|
92
|
+
let(:result) { parser.coverage }
|
93
|
+
|
94
|
+
it "returns a hash" do
|
95
|
+
expect(result).to be_a Hash
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns coverage metrics hash" do
|
99
|
+
expect(result).to eq Hash(
|
100
|
+
coverage_percent: 66.48,
|
101
|
+
lines_covered: 3354,
|
102
|
+
lines_total: 5045
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with no coverage data" do
|
107
|
+
let(:log) { "Foobar" }
|
108
|
+
|
109
|
+
it "returns nil" do
|
110
|
+
expect(result).to be_nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "with phpunit data" do
|
115
|
+
let(:log) { fixture "phpunit.txt" }
|
116
|
+
|
117
|
+
it "returns coverage metrics" do
|
118
|
+
expect(result).to eq Hash(
|
119
|
+
coverage_percent: 81.16,
|
120
|
+
lines_covered: 1034,
|
121
|
+
lines_total: 1274
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#duration" do
|
128
|
+
let(:result) { parser.duration }
|
129
|
+
|
130
|
+
context "with no duration data" do
|
131
|
+
let(:log) { "no duration entries here..." }
|
132
|
+
|
133
|
+
it "returns nil" do
|
134
|
+
expect(result).to be_nil
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with duration entry" do
|
139
|
+
let(:formats) do
|
140
|
+
[
|
141
|
+
[ "Finished in 5 seconds", 5.00 ],
|
142
|
+
[ "Ran 1234 tests in 14.855s", 14.855 ],
|
143
|
+
[ "Time: 01:50, Memory: 113.00Mb", 110.00 ],
|
144
|
+
[ "Finished tests in 8.071688s, 3.8406 tests/s, 9.4156 assertions/s.", 8.071688 ],
|
145
|
+
[ "Finished in 10.8 seconds (3.1s on load, 7.7s on tests)", 10.8 ],
|
146
|
+
[ "80 passing (347ms)", 0.347 ]
|
147
|
+
]
|
148
|
+
end
|
149
|
+
|
150
|
+
it "parses multiple formats" do
|
151
|
+
formats.each do |f|
|
152
|
+
expect(described_class.new(f[0]).duration).to eq f[1]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context "with multiple duration entries" do
|
158
|
+
let(:log) { fixture "rspec_multiple_duration.txt" }
|
159
|
+
|
160
|
+
it "returns total duration" do
|
161
|
+
expect(result).to eq 942.0924699999999
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context "with phpunit data" do
|
166
|
+
let(:log) { fixture "phpunit.txt" }
|
167
|
+
|
168
|
+
it "returns total duration" do
|
169
|
+
expect(result).to eq 0.176
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
$:.unshift File.expand_path("../..", __FILE__)
|
5
|
+
|
6
|
+
require "build_log_parser"
|
7
|
+
|
8
|
+
def fixture_path(filename = nil)
|
9
|
+
path = File.expand_path("../fixtures", __FILE__)
|
10
|
+
filename.nil? ? path : File.join(path, filename)
|
11
|
+
end
|
12
|
+
|
13
|
+
def fixture(file)
|
14
|
+
File.read(File.join(fixture_path, file))
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: build_log_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan Sosedoff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: chronic_duration
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
description: Parses various build metrics from builds logs (Rspec, Test::Unit, etc)
|
70
|
+
email:
|
71
|
+
- dan.sosedoff@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- build_log_parser.gemspec
|
83
|
+
- lib/build_log_parser.rb
|
84
|
+
- lib/build_log_parser/coverage_matcher.rb
|
85
|
+
- lib/build_log_parser/duration_matcher.rb
|
86
|
+
- lib/build_log_parser/parser.rb
|
87
|
+
- lib/build_log_parser/phpunit_matcher.rb
|
88
|
+
- lib/build_log_parser/rspec_matcher.rb
|
89
|
+
- lib/build_log_parser/test_unit_matcher.rb
|
90
|
+
- lib/build_log_parser/version.rb
|
91
|
+
- spec/fixtures/js.txt
|
92
|
+
- spec/fixtures/phpunit.txt
|
93
|
+
- spec/fixtures/phpunit_failure.txt
|
94
|
+
- spec/fixtures/rspec.txt
|
95
|
+
- spec/fixtures/rspec_multiple.txt
|
96
|
+
- spec/fixtures/rspec_multiple_duration.txt
|
97
|
+
- spec/fixtures/simplecov.txt
|
98
|
+
- spec/fixtures/test_unit.txt
|
99
|
+
- spec/fixtures/test_unit_2.txt
|
100
|
+
- spec/lib/build_log_parser_spec.rb
|
101
|
+
- spec/lib/parser_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/magnumci/build_log_parser
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.1.11
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Parse build metrics from logs
|
127
|
+
test_files:
|
128
|
+
- spec/fixtures/js.txt
|
129
|
+
- spec/fixtures/phpunit.txt
|
130
|
+
- spec/fixtures/phpunit_failure.txt
|
131
|
+
- spec/fixtures/rspec.txt
|
132
|
+
- spec/fixtures/rspec_multiple.txt
|
133
|
+
- spec/fixtures/rspec_multiple_duration.txt
|
134
|
+
- spec/fixtures/simplecov.txt
|
135
|
+
- spec/fixtures/test_unit.txt
|
136
|
+
- spec/fixtures/test_unit_2.txt
|
137
|
+
- spec/lib/build_log_parser_spec.rb
|
138
|
+
- spec/lib/parser_spec.rb
|
139
|
+
- spec/spec_helper.rb
|