Skip to content

Commit a92ab33

Browse files
committed
Merge branch 'od/travis_coveralls' into develop
2 parents 37ce605 + 0419085 commit a92ab33

6 files changed

Lines changed: 325 additions & 1 deletion

File tree

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
language: objective-c
3+
4+
before_script:
5+
- sudo easy_install cpp-coveralls
6+
7+
script:
8+
- xctool -project genstrings2.xcodeproj -scheme "Static Library" test -arch x86_64 ONLY_ACTIVE_ARCH=NO
9+
### disabled until Travis-CI fixes missing appledoc install on 10.9 machines
10+
# - appledoc -o /tmp .
11+
12+
after_success:
13+
- ./coveralls.rb --extension m --exclude-folder Demo --exclude-folder Test --exclude-folder Externals

Readme.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
DTLocalizableStringScanner
22
==========================
33

4+
[![Build Status](https://travis-ci.org/Cocoanetics/DTLocalizableStringScanner.png?branch=develop)](https://travis-ci.org/Cocoanetics/DTLocalizableStringScanner) [![Coverage Status](https://coveralls.io/repos/Cocoanetics/DTLocalizableStringScanner/badge.png?branch=develop)](https://coveralls.io/r/Cocoanetics/DTLocalizableStringScanner?branch=develop)
5+
46
This project aims to duplicate and enhance the functionality found in the `genstrings` utility provided by Apple. The Demo builds a command line utility `genstrings2` which works like the original but using more modern techniques. The Core contains classes and categories to add this scanning functionality to [Linguan](http://www.cocoanetics.com/apps/linguan/).
57

68
Documentation

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+

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

genstrings2.xcodeproj/project.pbxproj

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
);
429429
runOnlyForDeploymentPostprocessing = 0;
430430
shellPath = /bin/sh;
431-
shellScript = "/usr/local/bin/appledoc --print-settings --output \"${BUILD_DIR}/Documentation/\" \"${PROJECT_DIR}\"\necho \"Documentation Output directory: ${BUILD_DIR}/Documentation/\"";
431+
shellScript = "echo \"Documentation Output directory: ${BUILD_DIR}/Documentation/\"\n/usr/local/bin/appledoc --print-settings --output \"${BUILD_DIR}/Documentation/\" \"${PROJECT_DIR}\"\nexit $?";
432432
showEnvVarsInLog = 0;
433433
};
434434
A7F65DBC14C03E980092E2EE /* ShellScript */ = {
@@ -488,6 +488,92 @@
488488
/* End PBXTargetDependency section */
489489

490490
/* Begin XCBuildConfiguration section */
491+
A7313BDA190A619A007E130F /* Coverage */ = {
492+
isa = XCBuildConfiguration;
493+
buildSettings = {
494+
ALWAYS_SEARCH_USER_PATHS = NO;
495+
CLANG_ENABLE_OBJC_ARC = YES;
496+
CLANG_WARN_BOOL_CONVERSION = YES;
497+
CLANG_WARN_CONSTANT_CONVERSION = YES;
498+
CLANG_WARN_EMPTY_BODY = YES;
499+
CLANG_WARN_ENUM_CONVERSION = YES;
500+
CLANG_WARN_INT_CONVERSION = YES;
501+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
502+
COPY_PHASE_STRIP = NO;
503+
GCC_C_LANGUAGE_STANDARD = gnu99;
504+
GCC_DYNAMIC_NO_PIC = NO;
505+
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
506+
GCC_OPTIMIZATION_LEVEL = 0;
507+
GCC_PREPROCESSOR_DEFINITIONS = (
508+
"COVERAGE=1",
509+
"$(inherited)",
510+
);
511+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
512+
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
513+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
514+
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
515+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
516+
GCC_WARN_UNDECLARED_SELECTOR = YES;
517+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
518+
GCC_WARN_UNUSED_FUNCTION = YES;
519+
GCC_WARN_UNUSED_VARIABLE = YES;
520+
MACOSX_DEPLOYMENT_TARGET = 10.7;
521+
ONLY_ACTIVE_ARCH = YES;
522+
SDKROOT = macosx;
523+
};
524+
name = Coverage;
525+
};
526+
A7313BDB190A619A007E130F /* Coverage */ = {
527+
isa = XCBuildConfiguration;
528+
buildSettings = {
529+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
530+
GCC_PREFIX_HEADER = "Demo/genstrings2-Prefix.pch";
531+
OTHER_LDFLAGS = (
532+
"-ObjC",
533+
"-all_load",
534+
);
535+
PRODUCT_NAME = genstrings2;
536+
};
537+
name = Coverage;
538+
};
539+
A7313BDC190A619A007E130F /* Coverage */ = {
540+
isa = XCBuildConfiguration;
541+
buildSettings = {
542+
CLANG_ENABLE_OBJC_ARC = YES;
543+
COMBINE_HIDPI_IMAGES = YES;
544+
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
545+
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
546+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
547+
GCC_PREFIX_HEADER = "Core/DTLocalizableStringScanner-Prefix.pch";
548+
PRODUCT_NAME = DTLocalizableStringScanner;
549+
SKIP_INSTALL = YES;
550+
};
551+
name = Coverage;
552+
};
553+
A7313BDD190A619A007E130F /* Coverage */ = {
554+
isa = XCBuildConfiguration;
555+
buildSettings = {
556+
COMBINE_HIDPI_IMAGES = YES;
557+
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
558+
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
559+
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
560+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
561+
GCC_PREFIX_HEADER = "Test/UnitTest-Prefix.pch";
562+
INFOPLIST_FILE = "Test/UnitTest-Info.plist";
563+
OTHER_LDFLAGS = "-ObjC";
564+
PRODUCT_NAME = "$(TARGET_NAME)";
565+
WRAPPER_EXTENSION = octest;
566+
};
567+
name = Coverage;
568+
};
569+
A7313BDE190A619A007E130F /* Coverage */ = {
570+
isa = XCBuildConfiguration;
571+
buildSettings = {
572+
COMBINE_HIDPI_IMAGES = YES;
573+
PRODUCT_NAME = "$(TARGET_NAME)";
574+
};
575+
name = Coverage;
576+
};
491577
A775234A14ACEF7A0035CDCA /* Debug */ = {
492578
isa = XCBuildConfiguration;
493579
buildSettings = {
@@ -652,6 +738,7 @@
652738
isa = XCConfigurationList;
653739
buildConfigurations = (
654740
A775234A14ACEF7A0035CDCA /* Debug */,
741+
A7313BDA190A619A007E130F /* Coverage */,
655742
A775234B14ACEF7A0035CDCA /* Release */,
656743
);
657744
defaultConfigurationIsVisible = 0;
@@ -661,6 +748,7 @@
661748
isa = XCConfigurationList;
662749
buildConfigurations = (
663750
A775234D14ACEF7A0035CDCA /* Debug */,
751+
A7313BDB190A619A007E130F /* Coverage */,
664752
A775234E14ACEF7A0035CDCA /* Release */,
665753
);
666754
defaultConfigurationIsVisible = 0;
@@ -670,6 +758,7 @@
670758
isa = XCConfigurationList;
671759
buildConfigurations = (
672760
A79AC09614B1A51800489FA3 /* Debug */,
761+
A7313BDC190A619A007E130F /* Coverage */,
673762
A79AC09714B1A51800489FA3 /* Release */,
674763
);
675764
defaultConfigurationIsVisible = 0;
@@ -679,6 +768,7 @@
679768
isa = XCConfigurationList;
680769
buildConfigurations = (
681770
A79D903616F7491B009D8A46 /* Debug */,
771+
A7313BDE190A619A007E130F /* Coverage */,
682772
A79D903716F7491B009D8A46 /* Release */,
683773
);
684774
defaultConfigurationIsVisible = 0;
@@ -688,6 +778,7 @@
688778
isa = XCConfigurationList;
689779
buildConfigurations = (
690780
A7F65DCC14C03E990092E2EE /* Debug */,
781+
A7313BDD190A619A007E130F /* Coverage */,
691782
A7F65DCD14C03E990092E2EE /* Release */,
692783
);
693784
defaultConfigurationIsVisible = 0;
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 = "Coverage">
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)