Skip to content

Commit

Permalink
Use new logging infra for Detox logging (#457)
Browse files Browse the repository at this point in the history
Use new logging infra for Detox logging
  • Loading branch information
LeoNatan authored Dec 10, 2017
1 parent 47793b0 commit 34cf76c
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
[submodule "detox/ios/COSTouchVisualizer"]
path = detox/ios/COSTouchVisualizer
url = https://github.com/conopsys/COSTouchVisualizer
[submodule "detox/ios/DTXLoggingInfra"]
path = detox/ios/DTXLoggingInfra
url = https://github.com/wix/DTXLoggingInfra.git
18 changes: 0 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ node_js: 8

matrix:
include:
- language: objective-c
os: osx
osx_image: xcode8.3
env:
- REACT_NATIVE_VERSION=0.44.2
install:
- ./scripts/install.ios.sh
script:
- ./scripts/ci.ios.sh
- language: objective-c
os: osx
osx_image: xcode8.3
env:
- REACT_NATIVE_VERSION=0.49.3
install:
- ./scripts/install.ios.sh
script:
- ./scripts/ci.ios.sh
- language: objective-c
os: osx
osx_image: xcode9
Expand Down
1 change: 1 addition & 0 deletions detox/ios/DTXLoggingInfra
Submodule DTXLoggingInfra added at f88aea
14 changes: 14 additions & 0 deletions detox/ios/Detox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
39C3C3511DBF9A13008177E1 /* EarlGrey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 394767DC1DBF991E00D72256 /* EarlGrey.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
39C3C3531DBF9A19008177E1 /* SocketRocket.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 394767E91DBF992400D72256 /* SocketRocket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
39CEFCDB1E34E91B00A09124 /* DetoxUserNotificationDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39CEFCDA1E34E91B00A09124 /* DetoxUserNotificationDispatcher.swift */; };
39F642281FDD5EB100468FED /* DTXLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 39F642201FDD5EB000468FED /* DTXLogging.h */; };
39F642291FDD5EB100468FED /* DTXLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = 39F642271FDD5EB000468FED /* DTXLogging.m */; };
468731A51E6C6D0500F151BE /* EarlGrey+Detox.h in Headers */ = {isa = PBXBuildFile; fileRef = 468731A31E6C6D0500F151BE /* EarlGrey+Detox.h */; };
468731A61E6C6D0500F151BE /* EarlGrey+Detox.m in Sources */ = {isa = PBXBuildFile; fileRef = 468731A41E6C6D0500F151BE /* EarlGrey+Detox.m */; };
46A6A63D1EF697BB00E3AA79 /* GREYConfiguration+Detox.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A6A63B1EF697BB00E3AA79 /* GREYConfiguration+Detox.m */; };
Expand Down Expand Up @@ -236,6 +238,10 @@
39A34C6F1E30F10D00BEBB59 /* DetoxAppDelegateProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetoxAppDelegateProxy.h; sourceTree = "<group>"; };
39A34C701E30F10D00BEBB59 /* DetoxAppDelegateProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetoxAppDelegateProxy.m; sourceTree = "<group>"; };
39CEFCDA1E34E91B00A09124 /* DetoxUserNotificationDispatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetoxUserNotificationDispatcher.swift; sourceTree = "<group>"; };
39F642201FDD5EB000468FED /* DTXLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DTXLogging.h; path = DTXLoggingInfra/DTXLogging.h; sourceTree = SOURCE_ROOT; };
39F642271FDD5EB000468FED /* DTXLogging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DTXLogging.m; path = DTXLoggingInfra/DTXLogging.m; sourceTree = SOURCE_ROOT; };
39F6422A1FDD5EEC00468FED /* Detox.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Detox.pch; sourceTree = "<group>"; };
39F6422B1FDD5F3300468FED /* DTXLoggingSubsystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DTXLoggingSubsystem.h; sourceTree = "<group>"; };
468731A31E6C6D0500F151BE /* EarlGrey+Detox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "EarlGrey+Detox.h"; sourceTree = "<group>"; };
468731A41E6C6D0500F151BE /* EarlGrey+Detox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "EarlGrey+Detox.m"; sourceTree = "<group>"; };
46A6A6341EF696B600E3AA79 /* GREYConfiguration+Detox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GREYConfiguration+Detox.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -334,6 +340,9 @@
394767991DBF985400D72256 /* Detox */ = {
isa = PBXGroup;
children = (
39F642201FDD5EB000468FED /* DTXLogging.h */,
39F642271FDD5EB000468FED /* DTXLogging.m */,
39F6422B1FDD5F3300468FED /* DTXLoggingSubsystem.h */,
390D1C981E3A2893007F5F46 /* Detox.xcconfig */,
390D1C661E3A1480007F5F46 /* UserNotificationsPrivate */,
3947679A1DBF985400D72256 /* Detox.h */,
Expand All @@ -353,6 +362,7 @@
394767B81DBF988C00D72256 /* EarlGreyExtensions */,
394767C31DBF98B100D72256 /* ReactNativeSupport */,
3947679B1DBF985400D72256 /* Info.plist */,
39F6422A1FDD5EEC00468FED /* Detox.pch */,
);
path = Detox;
sourceTree = "<group>";
Expand Down Expand Up @@ -438,6 +448,7 @@
390D1C691E3A14EF007F5F46 /* UNNotificationResponse+PrivateHeaders.h in Headers */,
391FA5E91E7FD96D0056F82F /* GREYIdlingResourcePrettyPrint.h in Headers */,
39A34C711E30F10D00BEBB59 /* DetoxAppDelegateProxy.h in Headers */,
39F642281FDD5EB100468FED /* DTXLogging.h in Headers */,
397EC9B51E7EDE0B00D5F2BB /* EarlGreyStatistics.h in Headers */,
A7F76A151ED33DE500FFE77E /* WXAnimatedDisplayLinkIdlingResource.h in Headers */,
394767AE1DBF987E00D72256 /* DetoxManager.h in Headers */,
Expand Down Expand Up @@ -673,6 +684,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
39F642291FDD5EB100468FED /* DTXLogging.m in Sources */,
394767B31DBF987E00D72256 /* TestFailureHandler.m in Sources */,
394767B71DBF987E00D72256 /* WebSocket.m in Sources */,
394767D51DBF98D900D72256 /* WXRunLoopIdlingResource.m in Sources */,
Expand Down Expand Up @@ -893,6 +905,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
GCC_PREFIX_HEADER = Detox/Detox.pch;
HEADER_SEARCH_PATHS = EarlGrey/fishhook;
INFOPLIST_FILE = Detox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -922,6 +935,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
GCC_PREFIX_HEADER = Detox/Detox.pch;
HEADER_SEARCH_PATHS = EarlGrey/fishhook;
INFOPLIST_FILE = Detox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
11 changes: 11 additions & 0 deletions detox/ios/Detox/DTXLoggingSubsystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// DTXLoggingSubsystem.h
// Detox
//
// Created by Leo Natan (Wix) on 12/10/17.
// Copyright © 2017 Wix. All rights reserved.
//

#ifndef DTX_LOG_SUBSYSTEM
#define DTX_LOG_SUBSYSTEM "com.wix.Detox"
#endif /* DTX_LOG_SUBSYSTEM */
14 changes: 14 additions & 0 deletions detox/ios/Detox/Detox.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Detox.pch
// Detox
//
// Created by Leo Natan (Wix) on 12/10/17.
// Copyright © 2017 Wix. All rights reserved.
//

#ifndef Detox_pch
#define Detox_pch

#import "DTXLogging.h"

#endif /* Detox_pch */
4 changes: 3 additions & 1 deletion detox/ios/Detox/DetoxManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import "EarlGreyExtensions.h"
#import "EarlGreyStatistics.h"

DTX_CREATE_LOG(DetoxManager)

@interface DetoxManager()

@property (nonatomic) BOOL isReady;
Expand All @@ -35,7 +37,7 @@ static void detoxConditionalInit()
NSString *detoxSessionId = [options stringForKey:@"detoxSessionId"];
if (!detoxServer || !detoxSessionId)
{
NSLog(@"☣️ DETOX:: Either 'detoxServer' and/or 'detoxSessionId' arguments are missing; failing Detox.");
dtx_log_error(@"Either 'detoxServer' and/or 'detoxSessionId' arguments are missing; failing Detox.");
// if these args were not provided as part of options, don't start Detox at all!
return;
}
Expand Down
6 changes: 3 additions & 3 deletions detox/ios/Detox/EarlGreyStatistics.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ void WXFixupIdlingResourceClasses()

if(rv == NO)
{
//NSLog(@"☣️ DETOX:: %@ -> busy", NSStringFromClass([_self class]));
// dtx_log_info(@"%@ -> busy", NSStringFromClass([_self class]));
// NSString* prettyName = _prettyNames[CLS_STR(_self)] ?: _self.idlingResourceName;
// NSDictionary* (^prettyPrinter)(id<GREYIdlingResource>) = _prettyPrinters[CLS_STR(_self)] ?: ^ (id<GREYIdlingResource> res) { return @{}; };
//
// NSLog(@"☣️☣️ DETOX:: %@ -> busy %@", prettyName, prettyPrinter(_self)[@"prettyPrint"]);
// dtx_log_info(@"%@ -> busy %@", prettyName, prettyPrinter(_self)[@"prettyPrint"]);
//
// [resources addObject:@{@"name": prettyName, @"info": prettyPrinter(obj)}];
}

Expand Down
11 changes: 11 additions & 0 deletions detox/ios/Detox/GREYIdlingResourcePrettyPrint.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "GREYIdlingResourcePrettyPrint.h"
@import ObjectiveC;
#include <os/log.h>

@interface __DTXDeallocSafeProxy : NSObject

Expand All @@ -17,6 +18,16 @@ @interface __DTXDeallocSafeProxy : NSObject

@implementation __DTXDeallocSafeProxy

- (NSString *)description
{
return [self.object description];
}

- (NSString *)debugDescription
{
return [self.object debugDescription];
}

- (void)dealloc
{
self.object = nil;
Expand Down
4 changes: 3 additions & 1 deletion detox/ios/Detox/ReactNativeSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
@import ObjectiveC;
@import Darwin;

DTX_CREATE_LOG(ReactNativeSupport);

NSString *const RCTReloadNotification = @"RCTReloadNotification";

static dispatch_queue_t __currentIdlingResourceSerialQueue;
Expand Down Expand Up @@ -144,7 +146,7 @@ void setupForTests()

[__observedQueues addObject:queue];

NSLog(@"☣️ Adding idling resource for queue: %@", queue);
dtx_log_info(@"Adding idling resource for queue: %@", queue);


[[GREYUIThreadExecutor sharedInstance] registerIdlingResource:[GREYDispatchQueueIdlingResource resourceWithDispatchQueue:queue name:queueName ?: @"SomeReactQueue"]];
Expand Down
8 changes: 5 additions & 3 deletions detox/ios/Detox/TestFailureHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@

#import "TestFailureHandler.h"

DTX_CREATE_LOG(TestFailureHandler)

@implementation TestFailureHandler

- (void)handleException:(GREYFrameworkException *)exception details:(NSString *)details
{
NSString *description = [NSString stringWithFormat:@"%@\n%@", [exception description], details];
NSLog(@"☣️ DETOX:: Test Failed:\n%@", description);
dtx_log_error(@"Test Failed:\n%@", description);

UIWindow* window = [[UIApplication sharedApplication] keyWindow];
NSLog(@"☣️ DETOX:: UI Hierarchy on test failure:\n%@", [GREYElementHierarchy hierarchyStringForElement:window]);
dtx_log_error(@"UI Hierarchy on test failure:\n%@", [GREYElementHierarchy hierarchyStringForElement:window]);

if (self.delegate) [self.delegate onTestFailed:description];
}
Expand Down
8 changes: 5 additions & 3 deletions detox/ios/Detox/WXJSTimerObservationIdlingResource.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "WXJSTimerObservationIdlingResource.h"
@import ObjectiveC;

DTX_CREATE_LOG(WXJSTimerObservationIdlingResource)

@interface _WXJSTimingObservationWrapper : NSObject @end
@implementation _WXJSTimingObservationWrapper
{
Expand Down Expand Up @@ -59,7 +61,7 @@ - (void)removeObjectForKey:(NSNumber*)aKey
{
if([_observedTimers containsObject:aKey])
{
NSLog(@"☣️ DETOX:: Removing observed timer %@", aKey);
dtx_log_info(@"Removing observed timer %@", aKey);
[_observedTimers removeObject:aKey];
}

Expand Down Expand Up @@ -130,13 +132,13 @@ - (instancetype)init

if(duration > 0 && duration <= _durationThreshold && repeats == NO)
{
NSLog(@"☣️ DETOX:: Observing timer: %@ d: %@ r: %@", timerID, @(duration), @(repeats));
dtx_log_info(@"Observing timer: %@ d: %@ r: %@", timerID, @(duration), @(repeats));

[_observationWrapper addObservedTimer:timerID];
}
else
{
NSLog(@"☣️ DETOX:: Ignoring timer: %@ failure reason: \"%@\"", timerID, [strongSelf failuireReasonForDuration:duration repeats:repeats]);
dtx_log_info(@"Ignoring timer: %@ failure reason: \"%@\"", timerID, [strongSelf failuireReasonForDuration:duration repeats:repeats]);
}
});

Expand Down
2 changes: 1 addition & 1 deletion detox/ios/Detox/WXRunLoopIdlingResource.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (instancetype)initWithRunLoop:(CFRunLoopRef)runLoop

CFRunLoopAddObserver((__bridge CFRunLoopRef)_runLoop, CFRunLoopObserverCreateWithHandler(NULL, kCFRunLoopExit | kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting, YES, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
dispatch_sync(_syncSerialQueue, ^{
// NSLog(@"☣️ DETOX:: Current runloop activity: %@", [self translateRunLoopActivity: activity]);
// dtx_log_info(@"Current runloop activity: %@", [self translateRunLoopActivity: activity]);
if(activity == kCFRunLoopBeforeWaiting || activity == kCFRunLoopExit)
{
_isBusy = NO;
Expand Down
Loading

0 comments on commit 34cf76c

Please sign in to comment.