Skip to content

Commit e59497d

Browse files
committed
Added files for Travis+Coveralls
1 parent 5c3222a commit e59497d

File tree

5 files changed

+233
-0
lines changed

5 files changed

+233
-0
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
language: objective-c
3+
4+
before_script:
5+
- sudo easy_install cpp-coveralls
6+
7+
script:
8+
- ./build.sh
9+
10+
after_success:
11+
- ./coveralls.rb --extension m --exclude-folder Demo --exclude-folder Test --exclude-folder Externals

Test/Resources/Multiple_Tables.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Tests if tokens properly end up in multiple strings tables */
2+
3+
#define CONTACT_NAME_MENU_TITLE NSLocalizedString(@"Contact Name Format",nil)
4+
5+
6+
7+
8+
if ([[menuItem title] isEqualToString:NSLocalizedStringFromTableInBundle(@"Open Link", @"Third Table", [NSBundle bundleForClass:[WebView class]], nil)])
9+
[webViewMenuItems removeObjectIdenticalTo:menuItem];
10+
}
11+
12+
13+

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e
3+
xctool -project genstrings2.xcodeproj -scheme "Static Library" test -arch x86_64 ONLY_ACTIVE_ARCH=NO
4+
xctool -project genstrings2.xcodeproj -scheme "Documentation"

coveralls.rb

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'etc'
4+
require 'fileutils'
5+
require 'find'
6+
require 'optparse'
7+
8+
# arraw of source subfolders to exclude
9+
excludedFolders = []
10+
extensionsToProcess = []
11+
coveralls_cmd = "coveralls"
12+
13+
excludeHeaders = false
14+
15+
# create option parser
16+
opts = OptionParser.new
17+
opts.banner = "Usage: coveralls.rb [options]"
18+
19+
opts.on('-e', '--exclude-folder FOLDER', 'Folder to exclude') do |v|
20+
excludedFolders << v
21+
coveralls_cmd.concat(" -e #{v}")
22+
end
23+
24+
opts.on('-h', '--exclude-headers', 'Ignores headers') do |v|
25+
excludeHeaders = true
26+
end
27+
28+
opts.on('-x', '--extension EXT', 'Source file extension to process') do |v|
29+
extensionsToProcess << v
30+
coveralls_cmd.concat(" -x #{v}")
31+
end
32+
33+
opts.on_tail("-?", "--help", "Show this message") do
34+
puts opts
35+
exit
36+
end
37+
38+
# parse the options
39+
begin
40+
opts.parse!(ARGV)
41+
rescue OptionParser::InvalidOption => e
42+
puts e
43+
puts opts
44+
exit(1)
45+
end
46+
47+
# the folders
48+
workingDir = Dir.getwd
49+
derivedDataDir = "#{Etc.getpwuid.dir}/Library/Developer/Xcode/DerivedData/"
50+
outputDir = workingDir + "/gcov"
51+
52+
# create gcov output folder
53+
FileUtils.mkdir outputDir
54+
55+
# pattern to get source file from first line of gcov file
56+
GCOV_SOURCE_PATTERN = Regexp.new(/Source:(.*)/)
57+
58+
# enumerate all gcda files underneath derivedData
59+
Find.find(derivedDataDir) do |gcda_file|
60+
61+
if gcda_file.match(/\.gcda\Z/)
62+
63+
#get just the folder name
64+
gcov_dir = File.dirname(gcda_file)
65+
66+
# cut off absolute working dir to get relative source path
67+
relative_input_path = gcda_file.slice(derivedDataDir.length, gcda_file.length)
68+
puts "\nINPUT: #{relative_input_path}"
69+
70+
#process the file
71+
result = %x( gcov '#{gcda_file}' -o '#{gcov_dir}' )
72+
73+
# filter the resulting output
74+
Dir.glob("*.gcov") do |gcov_file|
75+
76+
firstLine = File.open(gcov_file).readline
77+
match = GCOV_SOURCE_PATTERN.match(firstLine)
78+
79+
if (match)
80+
81+
source_path = match[1]
82+
83+
puts "source: #{source_path} - #{workingDir}"
84+
85+
if (source_path.start_with? workingDir)
86+
87+
# cut off absolute working dir to get relative source path
88+
relative_path = source_path.slice(workingDir.length+1, source_path.length)
89+
90+
extension = File.extname(relative_path)
91+
extension = extension.slice(1, extension.length-1)
92+
93+
puts "#{extension}"
94+
95+
# get the path components
96+
path_comps = relative_path.split(File::SEPARATOR)
97+
98+
shouldProcess = false
99+
exclusionMsg =""
100+
101+
if (excludedFolders.include?(path_comps[0]))
102+
exclusionMsg = "excluded via option"
103+
else
104+
if (excludeHeaders == true && extension == 'h')
105+
exclusionMsg = "excluded header"
106+
else
107+
if (extensionsToProcess.count == 0 || extensionsToProcess.include?(extension))
108+
shouldProcess = true
109+
else
110+
exclusionMsg = "excluded extension"
111+
shouldProcess = false
112+
end
113+
end
114+
end
115+
116+
if (shouldProcess)
117+
puts " - process: #{relative_path}"
118+
FileUtils.mv(gcov_file, outputDir)
119+
else
120+
puts " - ignore: #{relative_path} (#{exclusionMsg})"
121+
FileUtils.rm gcov_file
122+
end
123+
else
124+
puts " - ignore: #{gcov_file} (outside source folder)"
125+
FileUtils.rm gcov_file
126+
end
127+
end
128+
end
129+
end
130+
end
131+
132+
#call the coveralls, exclude some files
133+
system coveralls_cmd
134+
135+
#clean up
136+
FileUtils.rm_rf outputDir
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0460"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "A79AC08714B1A51800489FA3"
18+
BuildableName = "libDTLocalizableStringScanner.a"
19+
BlueprintName = "Static Library"
20+
ReferencedContainer = "container:genstrings2.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
27+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28+
shouldUseLaunchSchemeArgsEnv = "YES"
29+
buildConfiguration = "Debug">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "A7F65DBD14C03E980092E2EE"
36+
BuildableName = "UnitTest.octest"
37+
BlueprintName = "UnitTest"
38+
ReferencedContainer = "container:genstrings2.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
</TestAction>
43+
<LaunchAction
44+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
45+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
46+
launchStyle = "0"
47+
useCustomWorkingDirectory = "NO"
48+
buildConfiguration = "Debug"
49+
ignoresPersistentStateOnLaunch = "NO"
50+
debugDocumentVersioning = "YES"
51+
allowLocationSimulation = "YES">
52+
<AdditionalOptions>
53+
</AdditionalOptions>
54+
</LaunchAction>
55+
<ProfileAction
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
buildConfiguration = "Release"
60+
debugDocumentVersioning = "YES">
61+
</ProfileAction>
62+
<AnalyzeAction
63+
buildConfiguration = "Debug">
64+
</AnalyzeAction>
65+
<ArchiveAction
66+
buildConfiguration = "Release"
67+
revealArchiveInOrganizer = "YES">
68+
</ArchiveAction>
69+
</Scheme>

0 commit comments

Comments
 (0)