app-tools 1.3.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gencov +132 -0
- data/lib/app_tools/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6cd014f46a7658d6c7a790bdf02869c77acc428
|
4
|
+
data.tar.gz: 9f480c93affe10fa98a6ba6257667aed69928507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10f4012b90750f384e8cbd58d4e832d1c523313a80d766d945e811991b0079e7a845937a623602dcfa135f298e98187c2e9d01e8004fb151798e1547ee2d4b4
|
7
|
+
data.tar.gz: ae31bd4356c6dc2a995164ce7f7930dd56da163674228ab7f8fb221667d30d0333b101492be20d629f09438806d0cf19e8ffeecf6e6ad2650ca645e869035eed
|
data/bin/gencov
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'methadone'
|
5
|
+
require 'app_tools/version'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module AppTools
|
10
|
+
module GenCov
|
11
|
+
include Methadone::Main
|
12
|
+
include Methadone::CLILogging
|
13
|
+
include Methadone::ExitNow
|
14
|
+
|
15
|
+
class CovData
|
16
|
+
attr_accessor :total_files
|
17
|
+
attr_accessor :total_regions
|
18
|
+
attr_accessor :missed_regions
|
19
|
+
attr_accessor :total_lines
|
20
|
+
attr_accessor :missed_lines
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@total_files = 0
|
24
|
+
@total_regions = 0
|
25
|
+
@missed_regions = 0
|
26
|
+
@total_lines = 0
|
27
|
+
@missed_lines = 0
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_h
|
31
|
+
{
|
32
|
+
:total_files => @total_files,
|
33
|
+
:total_regions => @total_regions,
|
34
|
+
:missed_regions => @missed_regions,
|
35
|
+
:total_lines => @total_lines,
|
36
|
+
:missed_lines => @missed_lines
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
main do |xcfile, directory|
|
42
|
+
if xcfile.end_with?(".xcodeproj")
|
43
|
+
xcflag = "-project"
|
44
|
+
elsif xcfile.end_with?(".xcworkspace")
|
45
|
+
xcflag = "-workspace"
|
46
|
+
end
|
47
|
+
|
48
|
+
scheme = options[:s]
|
49
|
+
|
50
|
+
build_settings_file = Tempfile.new('gencov')
|
51
|
+
pid = Process.spawn("xcodebuild #{xcflag} #{xcfile} -scheme #{scheme} -sdk iphonesimulator -showBuildSettings",
|
52
|
+
[:out, :err] => build_settings_file)
|
53
|
+
Process.wait(pid)
|
54
|
+
build_settings_file.close
|
55
|
+
build_settings = {}
|
56
|
+
|
57
|
+
File.open(build_settings_file.path).each_line do |line|
|
58
|
+
if /^ *([A-Z_0-9]*) *= *(.*)$/.match(line)
|
59
|
+
build_settings[$1] = $2
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
coverage_root = File.join(build_settings['PROJECT_TEMP_ROOT'], "CodeCoverage/#{scheme}")
|
64
|
+
app_name = build_settings['EXECUTABLE_NAME']
|
65
|
+
profdata_path = File.join(coverage_root, "Coverage.profdata")
|
66
|
+
binary_path = `find #{coverage_root} -path *#{app_name}.app/#{app_name}`.chomp
|
67
|
+
|
68
|
+
directory = File.expand_path(directory)
|
69
|
+
source_files = `find #{directory} -type f \\( -name "*.m" -or -name "*.h" -or -name "*.swift" \\)`.lines
|
70
|
+
|
71
|
+
m_cov = CovData.new
|
72
|
+
total_h_files = 0
|
73
|
+
swift_cov = CovData.new
|
74
|
+
n = 0
|
75
|
+
|
76
|
+
source_files.each do |source_file|
|
77
|
+
source_file.chomp!
|
78
|
+
|
79
|
+
if source_file.end_with?('.h')
|
80
|
+
total_h_files += 1
|
81
|
+
next
|
82
|
+
end
|
83
|
+
|
84
|
+
file_coverage = `xcrun llvm-cov report -instr-profile #{profdata_path} #{binary_path} "#{source_file}"`
|
85
|
+
|
86
|
+
file_coverage.each_line do |line|
|
87
|
+
if /^TOTAL *(.*)$/.match(line)
|
88
|
+
fields = $1.split
|
89
|
+
|
90
|
+
total_regions = fields[0].to_i
|
91
|
+
missed_regions = fields[1].to_i
|
92
|
+
total_lines = fields[3].to_i
|
93
|
+
missed_lines = fields[4].to_i
|
94
|
+
|
95
|
+
if source_file.end_with?('.swift')
|
96
|
+
swift_cov.total_files += 1
|
97
|
+
swift_cov.total_regions += total_regions
|
98
|
+
swift_cov.missed_regions += missed_regions
|
99
|
+
swift_cov.total_lines += total_lines
|
100
|
+
swift_cov.missed_lines += missed_lines
|
101
|
+
else
|
102
|
+
m_cov.total_files += 1
|
103
|
+
m_cov.total_regions += total_regions
|
104
|
+
m_cov.missed_regions += missed_regions
|
105
|
+
m_cov.total_lines += total_lines
|
106
|
+
m_cov.missed_lines += missed_lines
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
n += 1
|
112
|
+
if n % 100 == 0
|
113
|
+
STDERR.puts n
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
puts(JSON.generate("coverage" => { ".swift" => swift_cov.to_h, ".m" => m_cov.to_h, ".h" => { "total_files" => total_h_files } }))
|
118
|
+
end
|
119
|
+
|
120
|
+
description 'gencov - Generates formatted coverage data for a project'
|
121
|
+
version AppTools::VERSION
|
122
|
+
|
123
|
+
on("-s", "--scheme SCHEME", "Schema to use for the project or workspace")
|
124
|
+
|
125
|
+
arg :xcfile, "The .xcodeproj or .xcworkspace file", :require
|
126
|
+
arg :directory, "The directory to generate coverage for", :require
|
127
|
+
|
128
|
+
use_log_level_option :toggle_debug_on_signal => 'USR1'
|
129
|
+
|
130
|
+
go!
|
131
|
+
end
|
132
|
+
end
|
data/lib/app_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Lyon-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,6 +129,7 @@ email:
|
|
129
129
|
- john@jamoki.com
|
130
130
|
executables:
|
131
131
|
- app-tools
|
132
|
+
- gencov
|
132
133
|
- kcpass
|
133
134
|
- resignipa
|
134
135
|
- setsimkbd
|
@@ -140,6 +141,7 @@ extra_rdoc_files: []
|
|
140
141
|
files:
|
141
142
|
- lib/app_tools/version.rb
|
142
143
|
- bin/app-tools
|
144
|
+
- bin/gencov
|
143
145
|
- bin/kcpass
|
144
146
|
- bin/resignipa
|
145
147
|
- bin/setsimkbd
|
@@ -171,3 +173,4 @@ signing_key:
|
|
171
173
|
specification_version: 4
|
172
174
|
summary: Tools for creating iPhone apps
|
173
175
|
test_files: []
|
176
|
+
has_rdoc:
|