Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
8e5e668e
Commit
8e5e668e
authored
Jul 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch SimpleCov to reuse code for coverage merger
parent
be3ad008
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
53 deletions
+21
-53
scripts/merge-simplecov
scripts/merge-simplecov
+21
-53
No files found.
scripts/merge-simplecov
View file @
8e5e668e
#!/usr/bin/env ruby
#!/usr/bin/env ruby
begin
load
File
.
expand_path
(
'../spring'
,
__FILE__
)
rescue
LoadError
=>
e
raise
unless
e
.
message
.
include?
(
'spring'
)
end
require
'simplecov'
require
'simplecov'
def
read
(
file
)
module
SimpleCov
return
unless
File
.
exist?
(
file
)
module
ResultMerger
data
=
File
.
read
(
file
)
class
<<
self
return
if
data
.
nil?
||
data
.
length
<
2
def
resultset_files
data
Dir
.
glob
(
File
.
join
(
SimpleCov
.
coverage_path
,
'*'
,
'.resultset.json'
))
end
end
def
load
(
file
)
def
resultset_hashes
begin
resultset_files
.
map
do
|
path
|
JSON
.
parse
(
read
(
file
))
begin
rescue
JSON
.
parse
(
File
.
read
(
path
))
{}
rescue
end
{}
end
end
end
def
files
end
Dir
.
glob
(
File
.
join
(
SimpleCov
.
coverage_path
,
'*'
,
'.resultset.json'
))
end
def
resultset
resultset_hashes
.
reduce
({},
:merge
)
def
resultsfiles
end
files
.
map
{
|
file
|
load
(
file
)
}
end
def
resultsets
resultsfiles
.
reduce
({},
:merge
)
end
def
all_results
results
=
[]
resultsets
.
each
do
|
command_name
,
data
|
result
=
SimpleCov
::
Result
.
from_hash
(
command_name
=>
data
)
# Only add result if the timeout is above the configured threshold
if
(
Time
.
now
-
result
.
created_at
)
<
SimpleCov
.
merge_timeout
results
<<
result
end
end
end
end
results
end
def
merged_result
merged
=
{}
results
=
all_results
results
.
each
do
|
result
|
merged
=
result
.
original_result
.
merge_resultset
(
merged
)
end
result
=
SimpleCov
::
Result
.
new
(
merged
)
# Specify the command name
result
.
command_name
=
results
.
map
(
&
:command_name
).
sort
.
join
(
", "
)
result
end
end
# Ignore CI environment
# Ignore CI environment
...
@@ -64,4 +32,4 @@ ENV['CI_BUILD_NAME'] = nil
...
@@ -64,4 +32,4 @@ ENV['CI_BUILD_NAME'] = nil
require_relative
'../spec/simplecov_env'
require_relative
'../spec/simplecov_env'
merged_result
.
format!
SimpleCov
::
ResultMerger
.
merged_result
.
format!
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment