Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 58 additions & 6 deletions cross-platform-scale-2015-demo/third-party/ios/xctool/BUCK
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
COMMON_PREPROCESSOR_FLAGS = ['-fobjc-arc', '-mmacosx-version-min=10.7', '-Wno-deprecated-declarations']

COMMON_COMPILER_FLAGS = ['-Wno-undeclared-selector', '-Wno-implicit-retain-self']

COMMON_OTEST_SRCS = [
'Common/DuplicateTestNameFix.m',
'Common/NSInvocationInSetFix.m',
Expand All @@ -22,13 +24,21 @@ COMMON_REPORTERS_SRCS = [
'Common/EventGenerator.m',
'Common/NSFileHandle+Print.m',
'Common/Reporter.m',
'Common/TaskUtil.m',
'Common/XcodeBuildSettings.m',
'Common/XCToolUtil.m',
]

COMMON_REPORTERS_HEADERS = [
'Common/EventGenerator.h',
'Common/EventSink.h',
'Common/NSConcreteTask.h',
'Common/NSFileHandle+Print.h',
'Common/Reporter.h',
'Common/ReporterEvents.h',
'Common/TaskUtil.h',
'Common/XcodeBuildSettings.h',
'Common/XCToolUtil.h',
]

TEXT_REPORTERS_SRCS = COMMON_REPORTERS_SRCS + glob(['reporters/text/**/*.m']) + [
Expand All @@ -53,14 +63,19 @@ apple_binary(
]),
linker_flags = [
'-F$DEVELOPER_DIR/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks',
'-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/Library/Frameworks',
'-F$DEVELOPER_DIR/../SharedFrameworks',
'-F$DEVELOPER_DIR/Library/PrivateFrameworks',
'-F$DEVELOPER_DIR/Library/MigrationFrameworks',
'-weak_framework',
'DVTFoundation',
'-weak_framework',
'DVTiPhoneSimulatorRemoteClient',
'-weak_framework',
'CoreSimulator',
'-weak_framework',
'XCTest',
'-liconv',
],
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [
'-DXCODE_VERSION=0630',
Expand All @@ -69,6 +84,7 @@ apple_binary(
'CXX': ['-std=c++11', '-stdlib=libc++'],
'OBJCXX': ['-std=c++11', '-stdlib=libc++'],
},
compiler_flags = COMMON_COMPILER_FLAGS,
frameworks = [
'$SDKROOT/System/Library/Frameworks/AppKit.framework',
'$SDKROOT/System/Library/Frameworks/CoreFoundation.framework',
Expand All @@ -85,6 +101,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -95,6 +115,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -109,6 +133,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -123,6 +151,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -137,6 +169,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -151,6 +187,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -165,6 +205,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -177,6 +221,10 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
linker_flags = [
'-liconv',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

apple_binary(
Expand All @@ -185,6 +233,7 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

genrule(
Expand All @@ -194,7 +243,7 @@ genrule(
':otest-query-ios-bin#iphonesimulator-x86_64',
],
out = 'otest-query-ios',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

apple_binary(
Expand All @@ -209,6 +258,7 @@ apple_binary(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

genrule(
Expand All @@ -218,7 +268,7 @@ genrule(
':otest-query-osx-bin#macosx-x86_64',
],
out = 'otest-query-osx',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

apple_library(
Expand All @@ -233,6 +283,7 @@ apple_library(
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
compiler_flags = COMMON_COMPILER_FLAGS,
)

genrule(
Expand All @@ -242,7 +293,7 @@ genrule(
':otest-query-lib#iphonesimulator-x86_64,shared',
],
out = 'otest-query-lib-ios.dylib',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

genrule(
Expand All @@ -252,7 +303,7 @@ genrule(
':otest-query-lib#macosx-x86_64,shared',
],
out = 'otest-query-lib-osx.dylib',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

apple_library(
Expand Down Expand Up @@ -284,6 +335,7 @@ apple_library(
# this shouldn't be needed as soon as Buck is fixed
# it comes from `otest-shim-sentestingkit`'s `exported_preprocessor_flags`
preprocessor_flags = ['-DSENTEST_IGNORE_DEPRECATION_WARNING'],
compiler_flags = COMMON_COMPILER_FLAGS,
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
Expand All @@ -299,7 +351,7 @@ genrule(
':otest-shim#iphonesimulator-x86_64,shared',
],
out = 'otest-shim-ios.dylib',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

genrule(
Expand All @@ -309,7 +361,7 @@ genrule(
':otest-shim#macosx-x86_64,shared',
],
out = 'otest-shim-osx.dylib',
cmd = 'lipo $SRCS -create -output $OUT',
cmd = 'lipo $SRCS -create -output $OUT; codesign --force --sign - --timestamp=none $OUT',
)

genrule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void ProcessTestSuite(id testSuite)

static id TestProbe_specifiedTestSuite(Class cls, SEL cmd)
{
id testSuite = objc_msgSend(cls,
id testSuite = ((id (*)(id, SEL))objc_msgSend)(cls,
sel_registerName([[NSString stringWithFormat:@"__%s_specifiedTestSuite",
class_getName(cls)] UTF8String]));
ProcessTestSuite(testSuite);
Expand All @@ -115,7 +115,7 @@ static id TestProbe_specifiedTestSuite(Class cls, SEL cmd)

static id TestSuite_allTests(Class cls, SEL cmd)
{
id testSuite = objc_msgSend(cls,
id testSuite = ((id (*)(id, SEL))objc_msgSend)(cls,
sel_registerName([[NSString stringWithFormat:@"__%s_allTests",
class_getName(cls)] UTF8String]));
ProcessTestSuite(testSuite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@

#import "ReporterEvents.h"

#ifdef __cplusplus
extern "C" {
#endif

NSDictionary *EventDictionaryWithNameAndContent(NSString *name, NSDictionary *content);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
NSDictionary *EventDictionaryWithNameAndContent(NSString *name, NSDictionary *content)
{
NSMutableDictionary *eventJSON = [NSMutableDictionary dictionaryWithDictionary:@{
@"event": name,
kReporter_Event_Key: name,
kReporter_TimestampKey: @([[NSDate date] timeIntervalSince1970])
}];
[eventJSON addEntriesFromDictionary:content];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void ParseClassAndMethodFromTestName(NSString **className, NSString **methodName
static dispatch_once_t onceToken;
static NSRegularExpression *testNameRegex;
dispatch_once(&onceToken, ^{
testNameRegex = [[NSRegularExpression alloc] initWithPattern:@"^-\\[([\\w.]+) (\\w+)\\]$"
testNameRegex = [[NSRegularExpression alloc] initWithPattern:@"^-\\[([\\w.]+) ([\\w\\:]+)\\]$"
options:0
error:nil];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- (void)beginTest:(NSDictionary *)event;
- (void)endTest:(NSDictionary *)event;
- (void)testOutput:(NSDictionary *)event;
- (void)simulatorOutput:(NSDictionary *)event;
- (void)beginStatus:(NSDictionary *)event;
- (void)endStatus:(NSDictionary *)event;
- (void)analyzerResult:(NSDictionary *)event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,9 @@
#import "Reporter.h"

#import <objc/runtime.h>
#import <poll.h>
#import <sys/stat.h>

static void ReadFileDescriptorAndOutputLinesToBlock(int inputFD,
void (^block)(NSString *line))
{
NSMutableData *buffer = [NSMutableData dataWithCapacity:0];

// Split whatever content we have in 'buffer' into lines.
void (^processBuffer)(void) = ^{
NSUInteger offset = 0;
NSData *newlineData = [NSData dataWithBytes:"\n" length:1];
for (;;) {
NSRange newlineRange = [buffer rangeOfData:newlineData
options:0
range:NSMakeRange(offset, [buffer length] - offset)];
if (newlineRange.length == 0) {
break;
} else {
NSData *line = [buffer subdataWithRange:NSMakeRange(offset, newlineRange.location - offset)];
block([[NSString alloc] initWithData:line encoding:NSUTF8StringEncoding]);
offset = newlineRange.location + 1;
}
}

[buffer replaceBytesInRange:NSMakeRange(0, offset) withBytes:NULL length:0];
};

const int readBufferSize = 32768;
uint8_t *readBuffer = malloc(readBufferSize);
NSCAssert(readBuffer, @"Failed to alloc readBuffer");

for (;;) {
ssize_t bytesRead = read(inputFD, readBuffer, readBufferSize);
NSCAssert(bytesRead != -1, @"read() failed with error: %s", strerror(errno));

if (bytesRead > 0) {
@autoreleasepool {
[buffer appendBytes:readBuffer length:bytesRead];

processBuffer();
}
} else {
// EOF
break;
}
}

free(readBuffer);
}
#import "ReporterEvents.h"
#import "TaskUtil.h"

@implementation Reporter

Expand All @@ -78,7 +31,12 @@ + (void)readFromInput:(NSFileHandle *)inputHandle

[reporter willBeginReporting];

ReadFileDescriptorAndOutputLinesToBlock([inputHandle fileDescriptor], ^(NSString *line){
int fildes[1] = {inputHandle.fileDescriptor};
ReadOutputsAndFeedOuputLinesToBlockOnQueue(fildes, 1, ^(int fd, NSString *line){
if (line.length == 0) {
return;
}

@autoreleasepool {
NSError *error = nil;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[line dataUsingEncoding:NSUTF8StringEncoding]
Expand All @@ -87,7 +45,7 @@ + (void)readFromInput:(NSFileHandle *)inputHandle
NSCAssert(dict != nil, @"Failed to decode JSON '%@' with error: %@", line, [error localizedFailureReason]);
[reporter handleEvent:dict];
}
});
}, NULL, NULL, YES);

[reporter didFinishReporting];

Expand Down Expand Up @@ -118,7 +76,7 @@ - (void)handleEvent:(NSDictionary *)eventDict
{
NSAssert(([eventDict count] > 0), @"Event was empty.");

NSString *event = eventDict[@"event"];
NSString *event = eventDict[kReporter_Event_Key];
NSAssert(event != nil && [event length] > 0, @"Event name was empty for event: %@", eventDict);

NSMutableString *selectorName = [NSMutableString string];
Expand Down Expand Up @@ -155,6 +113,7 @@ - (void)endTestSuite:(NSDictionary *)event {}
- (void)beginTest:(NSDictionary *)event {}
- (void)endTest:(NSDictionary *)event {}
- (void)testOutput:(NSDictionary *)event {}
- (void)simulatorOutput:(NSDictionary *)event {}
- (void)beginStatus:(NSDictionary *)event {}
- (void)endStatus:(NSDictionary *)event {}
- (void)analyzerResult:(NSDictionary *)event {}
Expand Down
Loading