Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying XCTest #641

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
  •  
  •  
  •  
27 changes: 0 additions & 27 deletions AppledocTests_prefix.pch

This file was deleted.

2 changes: 2 additions & 0 deletions Application/GBAppledocApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
*/
@interface GBAppledocApplication : NSObject <DDCliApplicationDelegate>

- (NSString *)standardizeCurrentDirectoryForPath:(NSString *)path;

@end
6 changes: 6 additions & 0 deletions Application/GBAppledocApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#import "DDXcodeProjectFile.h"
#import "DDEmbeddedDataReader.h"
#import "DDZipReader.h"
#import "GBExitCodes.h"
#import "GBLog.h"
#import "NSObject+GBObject.h"
#import "NSException+GBException.h"
#import "NSString+GBString.h"
#import "NSError+GBError.h"

static char *kGBArgInputPath = "input";
static char *kGBArgOutputPath = "output";
Expand Down
1 change: 1 addition & 0 deletions Application/GBApplicationSettingsProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "GBDataObjects.h"
#import "GBApplicationSettingsProvider.h"
#import "GBLog.h"
#import "GBExitCodes.h"

#import "SynthesizeSingleton.h"

Expand Down
96 changes: 58 additions & 38 deletions Common/GBLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Undefine defaults

#undef LOG_FLAG_ERROR
#undef LOG_FLAG_WARN
#undef LOG_FLAG_WARN
#undef LOG_FLAG_INFO
#undef LOG_FLAG_VERBOSE

Expand Down Expand Up @@ -46,32 +46,52 @@ extern NSUInteger kGBLogLevel;
extern NSInteger kGBLogBasedResult;
void GBLogUpdateResult(NSInteger result);

#define LOG_FLAG_FATAL (1 << 0) // 0...0000001
#define LOG_FLAG_ERROR (1 << 1) // 0...0000010
#define LOG_FLAG_WARN (1 << 2) // 0...0000100
#define LOG_FLAG_NORMAL (1 << 3) // 0...0001000
#define LOG_FLAG_INFO (1 << 4) // 0...0010000
#define LOG_FLAG_FATAL (1 << 0) // 0...0000001
#define LOG_FLAG_ERROR (1 << 1) // 0...0000010
#define LOG_FLAG_WARN (1 << 2) // 0...0000100
#define LOG_FLAG_NORMAL (1 << 3) // 0...0001000
#define LOG_FLAG_INFO (1 << 4) // 0...0010000
#define LOG_FLAG_VERBOSE (1 << 5) // 0...0100000
#define LOG_FLAG_DEBUG (1 << 6) // 0...1000000

#define LOG_LEVEL_FATAL (LOG_FLAG_FATAL) // 0...0000001
#define LOG_LEVEL_ERROR (LOG_FLAG_ERROR | LOG_LEVEL_FATAL) // 0...0000011
#define LOG_LEVEL_WARN (LOG_FLAG_WARN | LOG_LEVEL_ERROR) // 0...0000111
#define LOG_LEVEL_NORMAL (LOG_FLAG_NORMAL | LOG_LEVEL_WARN) // 0...0001111
#define LOG_LEVEL_INFO (LOG_FLAG_INFO | LOG_LEVEL_NORMAL) // 0...0011111
#define LOG_LEVEL_VERBOSE (LOG_FLAG_VERBOSE | LOG_LEVEL_INFO) // 0...0111111
#define LOG_LEVEL_DEBUG (LOG_FLAG_DEBUG | LOG_LEVEL_VERBOSE) // 0...1111111

#define SYNC_LOG_OBJC_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE(YES, lvl, flg, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)

#define GBLogFatal(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_FATAL); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_FATAL, frmt, ##__VA_ARGS__); }
#define GBLogError(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_ERROR); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_ERROR, frmt, ##__VA_ARGS__); }
#define GBLogWarn(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_WARNING); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_WARN, frmt, ##__VA_ARGS__); }
#define GBLogNormal(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_NORMAL, frmt, ##__VA_ARGS__)
#define GBLogInfo(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_INFO, frmt, ##__VA_ARGS__)
#define GBLogVerbose(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_VERBOSE, frmt, ##__VA_ARGS__)
#define GBLogDebug(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_DEBUG, frmt, ##__VA_ARGS__)
#define GBLogIsEnabled(level) ((kGBLogLevel & level) > 0)
#ifdef LOG_FLAG_DEBUG
#undef LOG_FLAG_DEBUG
#define LOG_FLAG_DEBUG (1 << 6) // 0...1000000
#endif

#define LOG_LEVEL_FATAL (LOG_FLAG_FATAL) // 0...0000001
#define LOG_LEVEL_ERROR (LOG_FLAG_ERROR | LOG_LEVEL_FATAL) // 0...0000011
#define LOG_LEVEL_WARN (LOG_FLAG_WARN | LOG_LEVEL_ERROR) // 0...0000111
#define LOG_LEVEL_NORMAL (LOG_FLAG_NORMAL | LOG_LEVEL_WARN) // 0...0001111
#define LOG_LEVEL_INFO (LOG_FLAG_INFO | LOG_LEVEL_NORMAL) // 0...0011111
#define LOG_LEVEL_VERBOSE (LOG_FLAG_VERBOSE | LOG_LEVEL_INFO) // 0...0111111
#ifdef LOG_LEVEL_DEBUG
#undef LOG_LEVEL_DEBUG
#define LOG_LEVEL_DEBUG (LOG_FLAG_DEBUG | LOG_LEVEL_VERBOSE) // 0...1111111
#endif

#define SYNC_LOG_OBJC_MAYBE(lvl, flg, frmt, ...) GBLOG_MAYBE(YES, lvl, flg, 0, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__)

#define GBLOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \
do { if(lvl & flg) GBLOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0)

#define GBLOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
[DDLog log:isAsynchronous \
level:lvl \
flag:flg \
context:ctx \
file:nil \
function:fnct \
line:__LINE__ \
tag:atag \
format:(frmt), ##__VA_ARGS__]

#define GBLogFatal(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_FATAL); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_FATAL, frmt, ##__VA_ARGS__); }
#define GBLogError(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_ERROR); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_ERROR, frmt, ##__VA_ARGS__); }
#define GBLogWarn(frmt, ...) { GBLogUpdateResult(GBEXIT_LOG_WARNING); SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_WARN, frmt, ##__VA_ARGS__); }
#define GBLogNormal(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_NORMAL, frmt, ##__VA_ARGS__)
#define GBLogInfo(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_INFO, frmt, ##__VA_ARGS__)
#define GBLogVerbose(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_VERBOSE, frmt, ##__VA_ARGS__)
#define GBLogDebug(frmt, ...) SYNC_LOG_OBJC_MAYBE(kGBLogLevel, LOG_FLAG_DEBUG, frmt, ##__VA_ARGS__)
#define GBLogIsEnabled(level) ((kGBLogLevel & level) > 0)

// Macros that store given file/line info. Mostly used for better Xcode integration!
#define GBLogXError(source,frmt,...) { [DDLog storeFilename:[source fullpath] line:[source lineNumber]]; GBLogError(frmt, ##__VA_ARGS__); }
Expand All @@ -82,20 +102,20 @@ void GBLogUpdateResult(NSInteger result);
// in higher level log formats. The information is already verbose enough!
#define GBLogExceptionLine(frmt,...) { ddprintf(frmt, ##__VA_ARGS__); ddprintf(@"\n"); }
#define GBLogExceptionNoStack(exception,frmt,...) { \
if (frmt.length > 0) GBLogExceptionLine(frmt, ##__VA_ARGS__); \
GBLogExceptionLine(@"%@: %@", [exception name], [exception reason]); \
if (frmt.length > 0) GBLogExceptionLine(frmt, ##__VA_ARGS__); \
GBLogExceptionLine(@"%@: %@", [exception name], [exception reason]); \
}
#define GBLogException(exception,frmt,...) { \
GBLogExceptionNoStack(exception,frmt,##__VA_ARGS__); \
NSArray *symbols = [exception callStackSymbols]; \
for (NSString *symbol in symbols) { \
GBLogExceptionLine(@" @ %@", symbol); \
} \
GBLogExceptionNoStack(exception,frmt,##__VA_ARGS__); \
NSArray *symbols = [exception callStackSymbols]; \
for (NSString *symbol in symbols) { \
GBLogExceptionLine(@" @ %@", symbol); \
} \
}
#define GBLogNSError(error,frmt,...) { \
if (frmt.length > 0) GBLogExceptionLine(frmt, ##__VA_ARGS__); \
if ([error localizedDescription]) GBLogExceptionLine(@"%@", [error localizedDescription]); \
if ([error localizedFailureReason]) GBLogExceptionLine(@"%@", [error localizedFailureReason]); \
if (frmt.length > 0) GBLogExceptionLine(frmt, ##__VA_ARGS__); \
if ([error localizedDescription]) GBLogExceptionLine(@"%@", [error localizedDescription]); \
if ([error localizedFailureReason]) GBLogExceptionLine(@"%@", [error localizedFailureReason]); \
}

#pragma mark Application wide logging helpers
Expand All @@ -115,7 +135,7 @@ void GBLogUpdateResult(NSInteger result);

/** Sets logging level from the given verbose command line argument value.

The method converts the given command line argument value to a proper log level and sends it to @c setLogLevel:
The method converts the given command line argument value to a proper log level and sends it to @c setLogLevel:
method. The value is forced into a valid range beforehand.

@param verbosity Verbose command line argument value to use.
Expand All @@ -124,7 +144,7 @@ void GBLogUpdateResult(NSInteger result);

/** Returns proper log formatter based on the given log format command line argument value.

The method returns `GBLogFormat0Formatter`, `GBLogFormat1Formatter`, `GBLogFormat2Formatter`, `GBLogFormat3Formatter`
The method returns `GBLogFormat0Formatter`, `GBLogFormat1Formatter`, `GBLogFormat2Formatter`, `GBLogFormat3Formatter`
or `GBLogFormat4Formatter` instance, based on the given value. The value is forced into a valid range beforehand.

@param level Log format command line argument value to use.
Expand Down
Loading