xcodebuild-helper 1.0.0 → 1.1.0
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 +4 -4
- data/Gemfile.lock +5 -1
- data/assets/style.css +102 -0
- data/lib/coverage_html_converter.rb +141 -0
- data/lib/coverage_plan.rb +8 -0
- data/lib/version.rb +1 -1
- data/lib/xcodebuild-helper.rb +26 -1
- data/spec/coverage_html_coverter_spec.rb +55 -0
- data/spec/coverage_plan_spec.rb +5 -0
- data/spec/xcode_dsl_actions_spec.rb +92 -1
- data/spec/xcode_spec.rb +6 -0
- data/xcodebuild-helper.gemspec +1 -0
- metadata +19 -2
- data/TODO.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13352acd9cf8b6adca60991c0633a004871712d0
|
4
|
+
data.tar.gz: fe4c7b2fb12e5d4a08cb59f5ac030b7830bef8a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f2f918fad5a452610f3650f175d1fa6ddbcca541ebdb90050af2067c4edc378cea81b46734e00a03212ffb60767a4e87c1aa49cb6c824983f72eb759df4a2ba
|
7
|
+
data.tar.gz: 20efb6da555ff792605a9df1be75b3b84967211b6c6ca7f8cdb4ac256a14bf1754a12ad46bc53c14aec06d9edcc3d469467b2f741625e2c59472636eb6f13ad2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xcodebuild-helper (1.
|
4
|
+
xcodebuild-helper (1.1.0)
|
5
|
+
nokogiri (~> 1.6)
|
5
6
|
xcodeproj (~> 0.28)
|
6
7
|
xcpretty (~> 0.2)
|
7
8
|
|
@@ -48,8 +49,11 @@ GEM
|
|
48
49
|
rb-inotify (>= 0.9.7)
|
49
50
|
lumberjack (1.0.10)
|
50
51
|
method_source (0.8.2)
|
52
|
+
mini_portile2 (2.0.0)
|
51
53
|
minitest (5.8.4)
|
52
54
|
nenv (0.3.0)
|
55
|
+
nokogiri (1.6.7.2)
|
56
|
+
mini_portile2 (~> 2.0.0.rc2)
|
53
57
|
notiffany (0.0.8)
|
54
58
|
nenv (~> 0.1)
|
55
59
|
shellany (~> 0.0)
|
data/assets/style.css
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
body{
|
2
|
+
width: 100%;
|
3
|
+
font-weight: 16px;
|
4
|
+
font-family: 'Helvetica', sans-serif;
|
5
|
+
color: rgb(68, 68, 68);
|
6
|
+
padding: 0;
|
7
|
+
margin: 0;
|
8
|
+
}
|
9
|
+
|
10
|
+
h1{
|
11
|
+
margin: 0.5em 1em;
|
12
|
+
}
|
13
|
+
|
14
|
+
.low{
|
15
|
+
color: rgb(189, 78, 62);
|
16
|
+
}
|
17
|
+
|
18
|
+
.mid{
|
19
|
+
color: rgb(212, 168, 103);
|
20
|
+
}
|
21
|
+
|
22
|
+
.high{
|
23
|
+
color: rgb(105, 173, 81);
|
24
|
+
}
|
25
|
+
|
26
|
+
a{
|
27
|
+
text-decoration: none;
|
28
|
+
color: rgb(56, 56, 56);
|
29
|
+
}
|
30
|
+
|
31
|
+
table{
|
32
|
+
border-collapse: collapse;
|
33
|
+
background-color: rgb(228, 240, 242);
|
34
|
+
width: 100%;
|
35
|
+
box-sizing: border-box;
|
36
|
+
}
|
37
|
+
|
38
|
+
table.main{
|
39
|
+
width: 100%;
|
40
|
+
}
|
41
|
+
|
42
|
+
.total_coverage{
|
43
|
+
font-weight: bold;
|
44
|
+
font-size: 2em;
|
45
|
+
margin: 0.5em 1em;
|
46
|
+
}
|
47
|
+
|
48
|
+
table.main tr{
|
49
|
+
float: left;
|
50
|
+
width: 50%;
|
51
|
+
}
|
52
|
+
|
53
|
+
tr:hover{
|
54
|
+
background-color: rgba(164, 164, 164, 0.32);
|
55
|
+
}
|
56
|
+
|
57
|
+
td{
|
58
|
+
padding: 5px;
|
59
|
+
}
|
60
|
+
|
61
|
+
tr.irrelevant{
|
62
|
+
background-color: transparent;
|
63
|
+
}
|
64
|
+
|
65
|
+
tr.covered{
|
66
|
+
background-color: rgb(153, 213, 174);
|
67
|
+
}
|
68
|
+
|
69
|
+
tr.covered:hover{
|
70
|
+
background-color: rgb(59, 196, 106);
|
71
|
+
cursor: pointer;
|
72
|
+
}
|
73
|
+
|
74
|
+
tr.uncovered{
|
75
|
+
background-color: rgb(205, 133, 123);
|
76
|
+
}
|
77
|
+
|
78
|
+
tr.uncovered:hover{
|
79
|
+
background-color: rgb(199, 76, 59);
|
80
|
+
cursor: pointer;
|
81
|
+
}
|
82
|
+
|
83
|
+
td.name, td.coverage, td.num{
|
84
|
+
font-weight: bold;
|
85
|
+
}
|
86
|
+
|
87
|
+
td.name{
|
88
|
+
width: 100%;
|
89
|
+
}
|
90
|
+
|
91
|
+
table.main td.coverage{
|
92
|
+
width: 100%;
|
93
|
+
}
|
94
|
+
|
95
|
+
td.coverage{
|
96
|
+
text-align: right;
|
97
|
+
}
|
98
|
+
|
99
|
+
td.num{
|
100
|
+
background-color: rgba(136, 136, 136, 0.52);
|
101
|
+
width: 3em;
|
102
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module XCodeBuildHelper
|
4
|
+
LINE_NUMBER_CLASS = "num"
|
5
|
+
COVERAGE_CLASS = "coverage"
|
6
|
+
SRC_CLASS = "src"
|
7
|
+
LINE_BREAK_DELIMITER = "\n"
|
8
|
+
LINE_INFO_DELIMITER = "|"
|
9
|
+
|
10
|
+
class CoverageHtmlConverter
|
11
|
+
def self.preprocess_file(lines)
|
12
|
+
relevent_lines = 0.0
|
13
|
+
covered_lines = 0.0
|
14
|
+
lines.each do |line|
|
15
|
+
elements = line.split(LINE_INFO_DELIMITER).map { |l| l.strip }
|
16
|
+
if elements[0] != ""
|
17
|
+
relevent_lines += 1.0
|
18
|
+
covered_lines += 1.0 if elements[0].to_f > 0.0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
covered_lines / relevent_lines
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.threshold_class(value)
|
26
|
+
if value > 0.85
|
27
|
+
"high"
|
28
|
+
elsif value > 0.7
|
29
|
+
"mid"
|
30
|
+
else
|
31
|
+
"low"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create_index(file_list)
|
36
|
+
total_coverage = 0.0
|
37
|
+
total = 0
|
38
|
+
file_list.each do |file|
|
39
|
+
total_coverage += file[:coverage]
|
40
|
+
total += 1.0
|
41
|
+
end
|
42
|
+
average_coverage = total_coverage / total
|
43
|
+
|
44
|
+
Nokogiri::HTML::Builder.new do |doc|
|
45
|
+
doc.html{
|
46
|
+
doc.head{
|
47
|
+
doc.link(:href => 'style.css', :media => "all", :rel => "stylesheet")
|
48
|
+
}
|
49
|
+
doc.body{
|
50
|
+
doc.h1{
|
51
|
+
doc.text "Code Coverage"
|
52
|
+
}
|
53
|
+
|
54
|
+
doc.div(:class => "total_coverage #{threshold_class(average_coverage)}"){
|
55
|
+
doc.text (average_coverage * 100).round(2).to_s + '%'
|
56
|
+
}
|
57
|
+
|
58
|
+
doc.table(:class => "main"){
|
59
|
+
file_list.each do |file|
|
60
|
+
doc.tr(:class => 'file'){
|
61
|
+
doc.td(:class => 'name'){
|
62
|
+
doc.a(:href => (file[:title] + '.html')){
|
63
|
+
doc.text file[:title]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
doc.td(:class => "coverage #{threshold_class(file[:coverage])}"){
|
67
|
+
doc.text (file[:coverage] * 100).round(2).to_s + "%"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.convert_file(input)
|
78
|
+
lines = input.split(LINE_BREAK_DELIMITER)
|
79
|
+
title = File.basename(lines.first.gsub(/:$/, ''))
|
80
|
+
lines = lines[1..-1]
|
81
|
+
|
82
|
+
total_coverage = preprocess_file(lines)
|
83
|
+
coverage_string = (total_coverage * 100).round(2).to_s + "%"
|
84
|
+
builder = Nokogiri::HTML::Builder.new do |doc|
|
85
|
+
doc.html {
|
86
|
+
doc.head {
|
87
|
+
doc.link(:href => 'style.css', :media => "all", :rel => "stylesheet")
|
88
|
+
}
|
89
|
+
|
90
|
+
doc.body {
|
91
|
+
doc.h1 {
|
92
|
+
doc.text title
|
93
|
+
}
|
94
|
+
doc.div(:class => "total_coverage #{threshold_class(total_coverage)}"){
|
95
|
+
doc.text coverage_string
|
96
|
+
}
|
97
|
+
doc.table {
|
98
|
+
lines.each do |line|
|
99
|
+
elements = line.split(LINE_INFO_DELIMITER)
|
100
|
+
if elements[0].strip == ""
|
101
|
+
additional_class = "irrelevant"
|
102
|
+
elsif elements[0].to_f > 0.0
|
103
|
+
additional_class = "covered"
|
104
|
+
else
|
105
|
+
additional_class = "uncovered"
|
106
|
+
end
|
107
|
+
doc.tr(:class => additional_class) {
|
108
|
+
doc.td(:class => LINE_NUMBER_CLASS) {
|
109
|
+
if elements[1]
|
110
|
+
doc.text elements[1].strip
|
111
|
+
end
|
112
|
+
}
|
113
|
+
doc.td(:class => SRC_CLASS) {
|
114
|
+
doc.pre {
|
115
|
+
doc.code {
|
116
|
+
doc.text elements[2]
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
doc.td(:class => COVERAGE_CLASS) {
|
123
|
+
if elements[0] && elements[0].strip != ""
|
124
|
+
if elements[0].to_f > 0.0
|
125
|
+
doc.text elements[0].strip + "x"
|
126
|
+
else
|
127
|
+
doc.text "!"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
{:content => builder, :title => title, :coverage => total_coverage}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/coverage_plan.rb
CHANGED
data/lib/version.rb
CHANGED
data/lib/xcodebuild-helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'xcode'
|
2
2
|
require 'execute'
|
3
|
+
require 'coverage_html_converter'
|
4
|
+
require 'fileutils'
|
3
5
|
|
4
6
|
module XCodeBuildHelper
|
5
7
|
@registry = {}
|
@@ -7,6 +9,10 @@ module XCodeBuildHelper
|
|
7
9
|
@registry[name]
|
8
10
|
end
|
9
11
|
|
12
|
+
def self.gem_location
|
13
|
+
File.expand_path(File.dirname(__dir__))
|
14
|
+
end
|
15
|
+
|
10
16
|
def self.define(name, &block)
|
11
17
|
xcode = @registry[name]
|
12
18
|
if xcode == nil
|
@@ -81,7 +87,26 @@ module XCodeBuildHelper
|
|
81
87
|
xcode = @registry[name]
|
82
88
|
unless xcode == nil
|
83
89
|
coverage_plan = xcode.get_coverage_plan(plan)
|
84
|
-
|
90
|
+
src_files = Dir.glob(coverage_plan.get_source_files.first).map{|file| file.gsub(/ /, "\\ ") }.join(' ')
|
91
|
+
result = XCodeBuildHelper::Execute.call("xcrun llvm-cov show -instr-profile \"#{profdata_location(xcode)}\" \"#{app_binary_location(xcode)}\" #{src_files}")
|
92
|
+
result = result.gsub(/^warning:.*\n/, '')
|
93
|
+
all_results = []
|
94
|
+
result.split("\n\n").each do |file|
|
95
|
+
converted_result = XCodeBuildHelper::CoverageHtmlConverter.convert_file file
|
96
|
+
all_results << converted_result
|
97
|
+
if converted_result
|
98
|
+
FileUtils::mkdir_p coverage_plan.get_output
|
99
|
+
basename = File.basename(converted_result[:title])
|
100
|
+
File.write(File.join(coverage_plan.get_output, basename + '.html'), converted_result[:content].to_html)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
unless all_results.empty?
|
105
|
+
index_file = XCodeBuildHelper::CoverageHtmlConverter.create_index all_results
|
106
|
+
File.write(File.join(coverage_plan.get_output, 'index.html'), index_file.to_html)
|
107
|
+
end
|
108
|
+
|
109
|
+
FileUtils::cp(File.join(gem_location, 'assets/style.css'), coverage_plan.get_output)
|
85
110
|
end
|
86
111
|
end
|
87
112
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'coverage_html_converter'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
RSpec.describe XCodeBuildHelper::CoverageHtmlConverter do
|
5
|
+
context "#convert_file" do
|
6
|
+
it "should return a table element" do
|
7
|
+
input = "TITLE:\n1 | 12|# some random code\n0 | 13|# other random code"
|
8
|
+
output = XCodeBuildHelper::CoverageHtmlConverter.convert_file input
|
9
|
+
document = Nokogiri::HTML(output[:content].to_html)
|
10
|
+
|
11
|
+
expect(output[:title]).to eq "TITLE"
|
12
|
+
expect(output[:coverage]).to eq 0.5
|
13
|
+
# assert the look of the document
|
14
|
+
expect(document.xpath('//html/head/link[@href]').first[:href]).to eq 'style.css'
|
15
|
+
expect(document.css('body h1').first.to_html).to eq "<h1>TITLE</h1>"
|
16
|
+
expect(document.css('body div.total_coverage').first.to_html).to eq "<div class=\"total_coverage low\">50.0%</div>"
|
17
|
+
expect(document.css('body table tr').length).to eq 2
|
18
|
+
expect(document.css('body table tr').first.to_html.gsub("\n", "")).to eq "<tr class=\"covered\"><td class=\"num\">12</td><td class=\"src\"><pre><code># some random code</code></pre></td><td class=\"coverage\">1x</td></tr>"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should handle rows without coverage" do
|
22
|
+
input = "TITLE\n | 12|# some random code\n 1| 13|# other random code"
|
23
|
+
output = XCodeBuildHelper::CoverageHtmlConverter.convert_file input
|
24
|
+
document = Nokogiri::HTML(output[:content].to_html)
|
25
|
+
|
26
|
+
# assert the look of the document
|
27
|
+
expect(output[:coverage]).to eq 1.0
|
28
|
+
expect(document.css('body table tr').first.to_html.gsub("\n", "")).to eq "<tr class=\"irrelevant\"><td class=\"num\">12</td><td class=\"src\"><pre><code># some random code</code></pre></td><td class=\"coverage\"></td></tr>"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should handle rows without coverage" do
|
32
|
+
input = "TITLE\n 0| 12|# some random code\n 0| 13|# other random code"
|
33
|
+
output = XCodeBuildHelper::CoverageHtmlConverter.convert_file input
|
34
|
+
document = Nokogiri::HTML(output[:content].to_html)
|
35
|
+
|
36
|
+
# assert the look of the document
|
37
|
+
expect(output[:coverage]).to eq 0.0
|
38
|
+
expect(document.css('body table tr').first.to_html.gsub("\n", "")).to eq "<tr class=\"uncovered\"><td class=\"num\">12</td><td class=\"src\"><pre><code># some random code</code></pre></td><td class=\"coverage\">!</td></tr>"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "#create_index" do
|
43
|
+
it "should create a table of all the files" do
|
44
|
+
input = [{:content => double(Nokogiri::HTML::Builder), :title => 'FILE_A', :coverage => 1.0}, {:content => double(Nokogiri::HTML::Builder), :title => 'FILE_B', :coverage => 0.5}]
|
45
|
+
|
46
|
+
output = XCodeBuildHelper::CoverageHtmlConverter.create_index input
|
47
|
+
document = Nokogiri::HTML(output.to_html)
|
48
|
+
expect(document.xpath('//html/head/link[@href]').first[:href]).to eq 'style.css'
|
49
|
+
expect(document.css('body h1').first.to_html).to eq "<h1>Code Coverage</h1>"
|
50
|
+
expect(document.css('body div.total_coverage').first.to_html).to eq "<div class=\"total_coverage mid\">75.0%</div>"
|
51
|
+
expect(document.css('body table.main tr').length).to eq 2
|
52
|
+
expect(document.css('body table.main tr').first.to_html.gsub("\n", "")).to eq "<tr class=\"file\"><td class=\"name\"><a href=\"FILE_A.html\">FILE_A</a></td><td class=\"coverage high\">100.0%</td></tr>"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/coverage_plan_spec.rb
CHANGED
@@ -14,5 +14,10 @@ RSpec.describe XCodeBuildHelper::CoveragePlan do
|
|
14
14
|
@coverage_plan.source_files ["path/tofiles/*.m"]
|
15
15
|
expect(@coverage_plan.get_source_files).to eq ["path/tofiles/*.m"]
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should set the output location" do
|
19
|
+
@coverage_plan.output "/path/to/output"
|
20
|
+
expect(@coverage_plan.get_output).to eq "/path/to/output"
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'xcodebuild-helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'fileutils'
|
2
4
|
|
3
5
|
RSpec.describe "DSL actions" do
|
6
|
+
before(:each) do
|
7
|
+
allow(XCodeBuildHelper).to receive(:gem_location).and_return('gem/location')
|
8
|
+
end
|
4
9
|
context "build" do
|
5
10
|
before(:each) do
|
6
11
|
XCodeBuildHelper.define :default do
|
@@ -75,8 +80,11 @@ RSpec.describe "DSL actions" do
|
|
75
80
|
coverage_plan :plan_a do
|
76
81
|
report_type "xml"
|
77
82
|
source_files ["path/to/files/*"]
|
83
|
+
output "/build/reports"
|
78
84
|
end
|
79
85
|
end
|
86
|
+
allow(FileUtils).to receive(:mkdir_p)
|
87
|
+
allow(FileUtils).to receive(:cp)
|
80
88
|
end
|
81
89
|
|
82
90
|
it "will find the base app directory" do
|
@@ -99,9 +107,92 @@ RSpec.describe "DSL actions" do
|
|
99
107
|
it "will return the CLI for finding code coverage" do
|
100
108
|
allow(XCodeBuildHelper).to receive(:app_binary_location).and_return("/path/to/app/bin")
|
101
109
|
allow(XCodeBuildHelper).to receive(:profdata_location).and_return("/path/to/app/prof")
|
102
|
-
|
110
|
+
allow(Dir).to receive(:glob).with('path/to/files/*').and_return(['path/to/files/file.m', 'path/to/files/supporting files/file.h'])
|
111
|
+
expect(XCodeBuildHelper::Execute).to receive(:call).with("xcrun llvm-cov show -instr-profile \"/path/to/app/prof\" \"/path/to/app/bin\" path/to/files/file.m path/to/files/supporting\\ files/file.h").and_return("")
|
103
112
|
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
104
113
|
end
|
114
|
+
|
115
|
+
context "converting results to html" do
|
116
|
+
it "will parse the results and call convert to html" do
|
117
|
+
allow(XCodeBuildHelper::Execute).to receive(:call).and_return("/path/to/file/FILE_A\n0 | 1|# some random code\n\nwarning: something went wrong here\n/path/to/file/FILE_B\n0| 2|#other random code")
|
118
|
+
|
119
|
+
mockIndex = double(Nokogiri::HTML::Builder)
|
120
|
+
allow(mockIndex).to receive(:to_html).and_return("INDEX STUFF")
|
121
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:create_index).and_return(mockIndex)
|
122
|
+
allow(File).to receive(:write)
|
123
|
+
|
124
|
+
expect(XCodeBuildHelper::CoverageHtmlConverter).to receive(:convert_file).twice
|
125
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "will save the results to a the file name header" do
|
129
|
+
mockHtml = double(Nokogiri::HTML::Builder)
|
130
|
+
allow(mockHtml).to receive(:to_html).and_return("HTML STUFF")
|
131
|
+
converted_result = { :content => mockHtml, :title => "/path/to/file/FILE_A"}
|
132
|
+
|
133
|
+
mockIndex = double(Nokogiri::HTML::Builder)
|
134
|
+
allow(mockIndex).to receive(:to_html).and_return("INDEX STUFF")
|
135
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:create_index).and_return(mockIndex)
|
136
|
+
allow(File).to receive(:write)
|
137
|
+
|
138
|
+
allow(XCodeBuildHelper::Execute).to receive(:call).and_return("warning:something went wrong\nFILE_A:\nHTML STUFF")
|
139
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:convert_file).with("FILE_A:\nHTML STUFF").and_return(converted_result)
|
140
|
+
expect(File).to receive(:write).with("/build/reports/FILE_A.html", "HTML STUFF")
|
141
|
+
|
142
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "needs to create the output directory first" do
|
146
|
+
mockHtml = double(Nokogiri::HTML::Builder)
|
147
|
+
allow(mockHtml).to receive(:to_html).and_return("HTML STUFF")
|
148
|
+
converted_result = { :content => mockHtml, :title => "/path/to/file/FILE_A"}
|
149
|
+
|
150
|
+
mockIndex = double(Nokogiri::HTML::Builder)
|
151
|
+
allow(mockIndex).to receive(:to_html).and_return("INDEX STUFF")
|
152
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:create_index).and_return(mockIndex)
|
153
|
+
|
154
|
+
allow(XCodeBuildHelper::Execute).to receive(:call).and_return("FILE_A:\nHTML STUFF")
|
155
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:convert_file).and_return(converted_result)
|
156
|
+
expect(FileUtils).to receive(:mkdir_p).with('/build/reports')
|
157
|
+
allow(File).to receive(:write)
|
158
|
+
|
159
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "will create an index page" do
|
163
|
+
mockHtml = double(Nokogiri::HTML::Builder)
|
164
|
+
allow(mockHtml).to receive(:to_html).and_return("HTML STUFF")
|
165
|
+
converted_result = { :content => mockHtml, :title => "/path/to/file/FILE_A"}
|
166
|
+
|
167
|
+
mockIndex = double(Nokogiri::HTML::Builder)
|
168
|
+
allow(mockIndex).to receive(:to_html).and_return("INDEX STUFF")
|
169
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:create_index).and_return(mockIndex)
|
170
|
+
|
171
|
+
allow(XCodeBuildHelper::Execute).to receive(:call).and_return("FILE_A:\nHTML STUFF")
|
172
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:convert_file).and_return(converted_result)
|
173
|
+
allow(File).to receive(:write).with("/build/reports/FILE_A.html", "HTML STUFF")
|
174
|
+
expect(File).to receive(:write).with("/build/reports/index.html", "INDEX STUFF")
|
175
|
+
|
176
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should copy the assets" do
|
180
|
+
mockHtml = double(Nokogiri::HTML::Builder)
|
181
|
+
allow(mockHtml).to receive(:to_html).and_return("HTML STUFF")
|
182
|
+
converted_result = { :content => mockHtml, :title => "/path/to/file/FILE_A"}
|
183
|
+
|
184
|
+
mockIndex = double(Nokogiri::HTML::Builder)
|
185
|
+
allow(mockIndex).to receive(:to_html).and_return("INDEX STUFF")
|
186
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:create_index).and_return(mockIndex)
|
187
|
+
|
188
|
+
allow(XCodeBuildHelper::Execute).to receive(:call).and_return("FILE_A:\nHTML STUFF")
|
189
|
+
allow(XCodeBuildHelper::CoverageHtmlConverter).to receive(:convert_file).and_return(converted_result)
|
190
|
+
allow(File).to receive(:write)
|
191
|
+
expect(FileUtils).to receive(:cp).with('gem/location/assets/style.css', '/build/reports')
|
192
|
+
|
193
|
+
XCodeBuildHelper.generate_coverage(:default, :plan_a)
|
194
|
+
end
|
195
|
+
end
|
105
196
|
end
|
106
197
|
|
107
198
|
context "lint" do
|
data/spec/xcode_spec.rb
CHANGED
@@ -56,12 +56,18 @@ RSpec.describe XCodeBuildHelper::XCode do
|
|
56
56
|
before(:each) do
|
57
57
|
@coverage_plan = XCodeBuildHelper::CoveragePlan.new
|
58
58
|
@coverage_plan.source_files ["path/to/files/*.m"]
|
59
|
+
@coverage_plan.output "/path/to/output"
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should set the source files" do
|
62
63
|
@xcode.coverage_plan(:plan_a, @coverage_plan)
|
63
64
|
expect(@xcode.get_coverage_plan(:plan_a).get_source_files).to eq ["path/to/files/*.m"]
|
64
65
|
end
|
66
|
+
|
67
|
+
it "should get the output directory" do
|
68
|
+
@xcode.coverage_plan(:plan_a, @coverage_plan)
|
69
|
+
expect(@xcode.get_coverage_plan(:plan_a).get_output).to eq "/path/to/output"
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
|
data/xcodebuild-helper.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcodebuild-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Rasmussen
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.28'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
83
97
|
description: Very useful when writing scripts to automate xcode development or when
|
84
98
|
creating ci scripts to automate deployment
|
85
99
|
email: xlr8runner@gmail.com
|
@@ -100,7 +114,7 @@ files:
|
|
100
114
|
- Guardfile
|
101
115
|
- README.md
|
102
116
|
- Rakefile
|
103
|
-
-
|
117
|
+
- assets/style.css
|
104
118
|
- bin/oclint
|
105
119
|
- bin/oclint-0.8
|
106
120
|
- bin/oclint-json-compilation-database
|
@@ -272,6 +286,7 @@ files:
|
|
272
286
|
- externals/oclint/lib/oclint/rules/libUnusedLocalVariableRule.dylib
|
273
287
|
- externals/oclint/lib/oclint/rules/libUnusedMethodParameterRule.dylib
|
274
288
|
- externals/oclint/lib/oclint/rules/libUselessParenthesesRule.dylib
|
289
|
+
- lib/coverage_html_converter.rb
|
275
290
|
- lib/coverage_plan.rb
|
276
291
|
- lib/device.rb
|
277
292
|
- lib/execute.rb
|
@@ -281,6 +296,7 @@ files:
|
|
281
296
|
- lib/version.rb
|
282
297
|
- lib/xcode.rb
|
283
298
|
- lib/xcodebuild-helper.rb
|
299
|
+
- spec/coverage_html_coverter_spec.rb
|
284
300
|
- spec/coverage_plan_spec.rb
|
285
301
|
- spec/device_spec.rb
|
286
302
|
- spec/lint_plan_spec.rb
|
@@ -316,6 +332,7 @@ signing_key:
|
|
316
332
|
specification_version: 4
|
317
333
|
summary: DSL to help call xcode CLI more easliy
|
318
334
|
test_files:
|
335
|
+
- spec/coverage_html_coverter_spec.rb
|
319
336
|
- spec/coverage_plan_spec.rb
|
320
337
|
- spec/device_spec.rb
|
321
338
|
- spec/lint_plan_spec.rb
|
data/TODO.md
DELETED