This repository was archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Remove boost dependency #19
Open
kylealanhale
wants to merge
23
commits into
mrtazz:master
Choose a base branch
from
kylealanhale:sans_boost
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,647
−109
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6973532
Remove dependency on boost
shiva f328ffc
Fix README
shiva cc53a4f
Xcode project with integrated testing
kylealanhale 9b6b6c3
regex fix for multiline section support
kylealanhale cc4c603
DRYer tag/section construction
kylealanhale 3e598e8
fixing failing unescape test
kylealanhale ae7fc1e
cleaning up commented-out boost code; updating README
kylealanhale c7c90b8
further improving multiline section support by collapsing dangling ne…
kylealanhale eaca997
using raw strings for more readable tests
kylealanhale b643ea5
list sections with nested sections weren't iterating properly; now th…
kylealanhale 1b2d36d
even better section newline handling
kylealanhale a88cd2d
Use copy files instead of headers build phase
kylealanhale c45900f
Switch to c++0x for Xcode project
kylealanhale c4def92
Update travis with clang and gcc C++11 support
kylealanhale d7418db
Add manual test runner to Xcode
kylealanhale 05f8210
Simplify test_change_delimiter
kylealanhale 1304486
Account for difference in GCC's regex implementation
kylealanhale e0f6fcc
Update dependencies in README
kylealanhale ce1a4e6
Update build settings
kylealanhale 609a720
Apply project whitespace styles
kylealanhale 3ba0129
Clarify newline skipping
kylealanhale 8a04292
Wrap else clause in braces
kylealanhale 5f13c29
Add comments to new methods
kylealanhale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
sudo: false | ||
language: cpp | ||
script: autoreconf -i && ./configure && make check && ./test-program | ||
compiler: | ||
- gcc | ||
- clang | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- gcc-4.9 | ||
- g++-4.9 | ||
- clang | ||
before_install: | ||
- if [ "$CXX" = "g++" ]; then | ||
export CXX="g++-4.9" CC="gcc-4.9"; | ||
export CXXFLAGS="-std=c++11"; | ||
elif [ "$CXX" = "clang++" ]; then | ||
export CXXFLAGS="-std=c++11 -stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1"; | ||
fi | ||
install: | ||
- if [ "$CXX" == "clang++" ]; then | ||
svn co --quiet http://llvm.org/svn/llvm-project/libcxx/trunk libcxx; | ||
cd libcxx/lib && bash buildit; | ||
ln -sf libc++.so.1.0 libc++.so.1; | ||
cd "$TRAVIS_BUILD_DIR"; | ||
export CXXFLAGS="$CXXFLAGS -L`pwd`/libcxx/lib -I`pwd`/libcxx/include"; | ||
export LD_LIBRARY_PATH="`pwd`/libcxx/lib:$LD_LIBRARY_PATH"; | ||
fi | ||
before_script: | ||
- sudo apt-get install libgtest-dev libboost-regex-dev build-essential | ||
- ./utils/build_gtest.sh | ||
|
||
- autoreconf -i && ./configure && make check | ||
script: ./test-program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Created by https://www.gitignore.io | ||
|
||
### Xcode ### | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.xcuserstate | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
/* | ||
* Copyright (c) 2013 Matthew Stevens | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
// Downloaded from https://github.com/mattstevens/xcode-googletest on 21 Apr 2015 - kah | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <XCTest/XCTest.h> | ||
#import <gtest/gtest.h> | ||
|
||
using testing::TestCase; | ||
using testing::TestInfo; | ||
using testing::TestPartResult; | ||
using testing::UnitTest; | ||
|
||
static NSString * const GoogleTestDisabledPrefix = @"DISABLED_"; | ||
|
||
/** | ||
* A Google Test listener that reports failures to XCTest. | ||
*/ | ||
class XCTestListener : public testing::EmptyTestEventListener { | ||
public: | ||
XCTestListener(XCTestCase *testCase) : | ||
_testCase(testCase) {} | ||
|
||
void OnTestPartResult(const TestPartResult& test_part_result) { | ||
if (test_part_result.passed()) | ||
return; | ||
|
||
int lineNumber = test_part_result.line_number(); | ||
const char *fileName = test_part_result.file_name(); | ||
NSString *path = fileName ? [@(fileName) stringByStandardizingPath] : nil; | ||
NSString *description = @(test_part_result.message()); | ||
[_testCase recordFailureWithDescription:description | ||
inFile:path | ||
atLine:(lineNumber >= 0 ? (NSUInteger)lineNumber : 0) | ||
expected:YES]; | ||
} | ||
|
||
private: | ||
XCTestCase *_testCase; | ||
}; | ||
|
||
/** | ||
* Test suite used to run Google Test cases. | ||
* | ||
* This test suite skips its own run and instead runs each of its sub-tests. This results | ||
* in the Google Test cases being reported at the same level as other XCTest cases. | ||
* | ||
* Additionally, if a test case has been completely filtered out it is not run at all. | ||
* This eliminates noise from the test report when running only a subset of tests. | ||
*/ | ||
@interface GoogleTestSuite : XCTestSuite | ||
@end | ||
|
||
@implementation GoogleTestSuite | ||
|
||
- (void)performTest:(XCTestSuiteRun *)testRun { | ||
for (XCTest *test in self.tests) { | ||
if (test.testCaseCount > 0) { | ||
[testRun addTestRun:[test run]]; | ||
} | ||
} | ||
} | ||
|
||
@end | ||
|
||
/** | ||
* A test case that executes Google Test, reporting test results to XCTest. | ||
* | ||
* XCTest loads tests by looking for all classes derived from XCTestCase and calling | ||
* +defaultTestSuite on each of them. Normally this method returns an XCTestSuite | ||
* containing an XCTestCase for each method of the receiver whose name begins with "test". | ||
* Instead this class returns a custom test suite that runs an XCTestSuite for each Google | ||
* Test case. | ||
*/ | ||
@interface GoogleTests : XCTestCase | ||
@end | ||
|
||
@implementation GoogleTests { | ||
NSString *_name; | ||
NSString *_className; | ||
NSString *_methodName; | ||
NSString *_googleTestFilter; | ||
} | ||
|
||
- (id)initWithClassName:(NSString *)className methodName:(NSString *)methodName testFilter:(NSString *)filter { | ||
self = [super initWithSelector:@selector(runTest)]; | ||
if (self) { | ||
_className = [className copy]; | ||
_methodName = [methodName copy]; | ||
_name = [NSString stringWithFormat:@"-[%@ %@]", _className, _methodName]; | ||
_googleTestFilter = [filter copy]; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSString *)name { | ||
return _name; | ||
} | ||
|
||
/** | ||
* Returns the test name logged to the console for this test. | ||
*/ | ||
- (NSString *)nameForLegacyLogging { | ||
return _name; | ||
} | ||
|
||
/** | ||
* Returns the class name reported to Xcode for this test. | ||
*/ | ||
- (NSString *)testClassName { | ||
return _className; | ||
} | ||
|
||
/** | ||
* Returns the method name reported to Xcode for this test. | ||
*/ | ||
- (NSString *)testMethodName { | ||
return _methodName; | ||
} | ||
|
||
+ (id)defaultTestSuite { | ||
// Pass the command-line arguments to Google Test to support the --gtest options | ||
NSArray *arguments = [[NSProcessInfo processInfo] arguments]; | ||
|
||
int i = 0; | ||
int argc = (int)[arguments count]; | ||
const char **argv = (const char **)calloc((unsigned int)argc + 1, sizeof(const char *)); | ||
for (NSString *arg in arguments) { | ||
argv[i++] = [arg UTF8String]; | ||
} | ||
|
||
testing::InitGoogleTest(&argc, (char **)argv); | ||
UnitTest *googleTest = UnitTest::GetInstance(); | ||
testing::TestEventListeners& listeners = googleTest->listeners(); | ||
delete listeners.Release(listeners.default_result_printer()); | ||
free(argv); | ||
|
||
BOOL runDisabledTests = testing::GTEST_FLAG(also_run_disabled_tests); | ||
NSCharacterSet *decimalDigitCharacterSet = [NSCharacterSet decimalDigitCharacterSet]; | ||
|
||
XCTestSuite *testSuite = [GoogleTestSuite testSuiteWithName:NSStringFromClass([self class])]; | ||
|
||
for (int testCaseIndex = 0; testCaseIndex < googleTest->total_test_case_count(); testCaseIndex++) { | ||
const TestCase *testCase = googleTest->GetTestCase(testCaseIndex); | ||
NSString *testCaseName = @(testCase->name()); | ||
|
||
// For typed tests '/' is used to separate the parts of the test case name. | ||
NSArray *testCaseNameComponents = [testCaseName componentsSeparatedByString:@"/"]; | ||
|
||
if (runDisabledTests == NO) { | ||
BOOL testCaseDisabled = NO; | ||
|
||
for (NSString *component in testCaseNameComponents) { | ||
if ([component hasPrefix:GoogleTestDisabledPrefix]) { | ||
testCaseDisabled = YES; | ||
break; | ||
} | ||
} | ||
|
||
if (testCaseDisabled) { | ||
continue; | ||
} | ||
} | ||
|
||
// Xcode's parsing expects that the test's class and method names are valid | ||
// Objective-C names. If they are not the tests will not be displayed properly in | ||
// the UI. Join the test case name components with '_' rather than '/' to address | ||
// this. | ||
NSString *className = [testCaseNameComponents componentsJoinedByString:@"_"]; | ||
|
||
XCTestSuite *testCaseSuite = [XCTestSuite testSuiteWithName:className]; | ||
|
||
for (int testIndex = 0; testIndex < testCase->total_test_count(); testIndex++) { | ||
const TestInfo *testInfo = testCase->GetTestInfo(testIndex); | ||
NSString *testName = @(testInfo->name()); | ||
if (runDisabledTests == NO && [testName hasPrefix:GoogleTestDisabledPrefix]) { | ||
continue; | ||
} | ||
|
||
// Google Test allows test names starting with a digit, prefix these with an | ||
// underscore to create a valid method name. | ||
NSString *methodName = testName; | ||
if ([methodName length] > 0 && [decimalDigitCharacterSet characterIsMember:[methodName characterAtIndex:0]]) { | ||
methodName = [@"_" stringByAppendingString:methodName]; | ||
} | ||
|
||
NSString *testFilter = [NSString stringWithFormat:@"%@.%@", testCaseName, testName]; | ||
|
||
[testCaseSuite addTest:[[self alloc] initWithClassName:className | ||
methodName:methodName | ||
testFilter:testFilter]]; | ||
} | ||
|
||
[testSuite addTest:testCaseSuite]; | ||
} | ||
|
||
return testSuite; | ||
} | ||
|
||
/** | ||
* Runs a single test. | ||
*/ | ||
- (void)runTest { | ||
XCTestListener *listener = new XCTestListener(self); | ||
UnitTest *googleTest = UnitTest::GetInstance(); | ||
googleTest->listeners().Append(listener); | ||
|
||
testing::GTEST_FLAG(filter) = [_googleTestFilter UTF8String]; | ||
|
||
(void)RUN_ALL_TESTS(); | ||
|
||
delete googleTest->listeners().Release(listener); | ||
|
||
int totalTestsRun = googleTest->successful_test_count() + googleTest->failed_test_count(); | ||
XCTAssertEqual(totalTestsRun, 1, @"Expected to run a single test for filter \"%@\"", _googleTestFilter); | ||
} | ||
|
||
@end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move those into the Makefile and the gtest build utils script? Or is this a specific travis problem? I'd much rather have it close to the actual build if this will be a problem outside of Travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are for the sake of Travis, although they're good clues on dependencies needed for building anywhere. However, I believe you have the
-DGTEST_USE_OWN_TR1_TUPLE=1
documented already for clang, and I think I added something about gcc-4.9 and c++11, but I'll double check and make sure it's all there somewhere.