@bugsee/react-native 7.0.0-beta3 → 7.0.0-beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -10
- package/android/build.gradle +9 -0
- package/android/consumer-rules.pro +3 -0
- package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +224 -20
- package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +44 -21
- package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +15 -0
- package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +119 -5
- package/android/src/main/java/com/bugsee/reactnative/NetworkCaptureProbe.java +107 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +129 -14
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +48 -0
- package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +64 -8
- package/android/src/main/java/com/bugsee/reactnative/StartupHold.java +237 -0
- package/ios/BugseeModule.mm +293 -155
- package/ios/Support/Package.resolved +2 -2
- package/ios/Support/Package.swift +1 -1
- package/ios/Support/Sources/BugseeRNSupport/BGSRNBlackout.m +14 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNDeleteCollectedData.m +33 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterArming.m +22 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterDeadline.m +110 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +40 -6
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +1 -1
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNBlackout.h +23 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +2 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDeleteCollectedData.h +29 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterArming.h +26 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterDeadline.h +68 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +16 -2
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNBlackoutTests.m +38 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDeleteCollectedDataTests.m +135 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterArmingTests.m +48 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterDeadlineTests.m +230 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +86 -6
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +1 -1
- package/native-versions.json +2 -2
- package/package.json +1 -1
- package/plugin/build/dsym-script.d.ts +11 -0
- package/plugin/build/dsym-script.js +26 -3
- package/plugin/build/dsym-script.js.map +1 -1
- package/plugin/build/index.d.ts +27 -0
- package/plugin/build/index.js +33 -21
- package/plugin/build/index.js.map +1 -1
- package/plugin/build/manifest.d.ts +37 -0
- package/plugin/build/manifest.js +67 -1
- package/plugin/build/manifest.js.map +1 -1
- package/plugin/build/native-versions.baked.json +1 -1
- package/scripts/compose-then-inject.js +4 -2
- package/scripts/hermes-sourcemaps.js +40 -3
- package/src/NativeBugsee.ts +39 -22
- package/src/apm/span.ts +42 -7
- package/src/breadcrumbs/filter.ts +104 -13
- package/src/breadcrumbs/types.ts +6 -4
- package/src/breadcrumbs/url-scrub.ts +75 -0
- package/src/exceptions/ErrorBoundary.tsx +4 -1
- package/src/exceptions/RootErrorReporter.tsx +1 -1
- package/src/exceptions/handlers.ts +17 -1
- package/src/exceptions/report.ts +30 -8
- package/src/index.ts +125 -33
- package/src/logs/filter.ts +19 -8
- package/src/network/filter.ts +17 -5
- package/src/options/AndroidLaunchOptions.ts +310 -24
- package/src/options/BugseeLaunchOptions.ts +463 -18
- package/src/options/IOSLaunchOptions.ts +164 -8
- package/src/options/android-options-manifest.json +63 -6
- package/src/options/enums.ts +28 -0
- package/src/options/ios-enums.json +6 -5
- package/src/options/ios-options-manifest.json +594 -0
- package/src/options/keys.ts +19 -1
- package/src/options/noAccessor.ts +16 -0
- package/src/options/option-keys.json +9 -3
- package/src/options/unknownKeys.ts +198 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
@import XCTest;
|
|
2
|
+
@import BugseeRNSupport;
|
|
3
|
+
|
|
4
|
+
/// Pins `BGSRNDeleteCollectedData`: the promise carries the SDK's outcome however
|
|
5
|
+
/// long it takes, and only a long backstop, as a rejection, ends a wait that
|
|
6
|
+
/// never completes.
|
|
7
|
+
@interface BGSRNDeleteCollectedDataTests : XCTestCase
|
|
8
|
+
@end
|
|
9
|
+
|
|
10
|
+
@implementation BGSRNDeleteCollectedDataTests
|
|
11
|
+
|
|
12
|
+
- (dispatch_queue_t)queue {
|
|
13
|
+
return dispatch_queue_create("com.bugsee.rn.delete.test", DISPATCH_QUEUE_SERIAL);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
- (void)testResolvesWithTheSDKOutcome {
|
|
17
|
+
for (NSNumber *outcome in @[ @YES, @NO ]) {
|
|
18
|
+
XCTestExpectation *done = [self expectationWithDescription:@"resolved"];
|
|
19
|
+
__block NSInteger settles = 0;
|
|
20
|
+
__block BOOL value = !outcome.boolValue;
|
|
21
|
+
BGSRNDeleteCollectedData(
|
|
22
|
+
^(void (^completion)(BOOL)) {
|
|
23
|
+
completion(outcome.boolValue);
|
|
24
|
+
},
|
|
25
|
+
5000, [self queue],
|
|
26
|
+
^(BOOL success) {
|
|
27
|
+
settles += 1;
|
|
28
|
+
value = success;
|
|
29
|
+
[done fulfill];
|
|
30
|
+
},
|
|
31
|
+
^(NSString *code) {
|
|
32
|
+
XCTFail(@"unexpected reject %@", code);
|
|
33
|
+
});
|
|
34
|
+
[self waitForExpectations:@[ done ] timeout:2];
|
|
35
|
+
XCTAssertEqual(settles, 1);
|
|
36
|
+
XCTAssertEqual(value, outcome.boolValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)testASlowCompletionPastTheOldOneAndAHalfSecondDeadlineStillResolvesItsOutcome {
|
|
41
|
+
XCTestExpectation *done = [self expectationWithDescription:@"resolved late"];
|
|
42
|
+
dispatch_queue_t queue = [self queue];
|
|
43
|
+
__block BOOL value = NO;
|
|
44
|
+
BGSRNDeleteCollectedData(
|
|
45
|
+
^(void (^completion)(BOOL)) {
|
|
46
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC),
|
|
47
|
+
dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
|
|
48
|
+
completion(YES);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
5000, queue,
|
|
52
|
+
^(BOOL success) {
|
|
53
|
+
value = success;
|
|
54
|
+
[done fulfill];
|
|
55
|
+
},
|
|
56
|
+
^(NSString *code) {
|
|
57
|
+
XCTFail(@"unexpected reject %@", code);
|
|
58
|
+
});
|
|
59
|
+
[self waitForExpectations:@[ done ] timeout:3];
|
|
60
|
+
XCTAssertTrue(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)testRejectsWithATimeoutCodeWhenTheCompletionNeverComes {
|
|
64
|
+
XCTestExpectation *done = [self expectationWithDescription:@"rejected"];
|
|
65
|
+
__block NSString *rejectedCode = nil;
|
|
66
|
+
BGSRNDeleteCollectedData(
|
|
67
|
+
^(void (^completion)(BOOL)) {
|
|
68
|
+
},
|
|
69
|
+
50, [self queue],
|
|
70
|
+
^(BOOL success) {
|
|
71
|
+
XCTFail(@"must not resolve");
|
|
72
|
+
},
|
|
73
|
+
^(NSString *code) {
|
|
74
|
+
rejectedCode = code;
|
|
75
|
+
[done fulfill];
|
|
76
|
+
});
|
|
77
|
+
[self waitForExpectations:@[ done ] timeout:2];
|
|
78
|
+
XCTAssertEqualObjects(rejectedCode, @"E_DELETE_TIMEOUT");
|
|
79
|
+
XCTAssertEqualObjects(BGSRNDeleteTimeoutCode, @"E_DELETE_TIMEOUT");
|
|
80
|
+
XCTAssertEqual(BGSRNDeleteCollectedDataBackstopMs, 60000);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- (void)testALateCompletionAfterTheBackstopIsIgnored {
|
|
84
|
+
XCTestExpectation *rejected = [self expectationWithDescription:@"rejected"];
|
|
85
|
+
__block void (^lateCompletion)(BOOL) = nil;
|
|
86
|
+
__block NSInteger settles = 0;
|
|
87
|
+
dispatch_queue_t queue = [self queue];
|
|
88
|
+
BGSRNDeleteCollectedData(
|
|
89
|
+
^(void (^completion)(BOOL)) {
|
|
90
|
+
lateCompletion = [completion copy];
|
|
91
|
+
},
|
|
92
|
+
50, queue,
|
|
93
|
+
^(BOOL success) {
|
|
94
|
+
settles += 1;
|
|
95
|
+
},
|
|
96
|
+
^(NSString *code) {
|
|
97
|
+
settles += 1;
|
|
98
|
+
[rejected fulfill];
|
|
99
|
+
});
|
|
100
|
+
[self waitForExpectations:@[ rejected ] timeout:2];
|
|
101
|
+
lateCompletion(YES);
|
|
102
|
+
lateCompletion(NO);
|
|
103
|
+
XCTestExpectation *drained = [self expectationWithDescription:@"queue drained"];
|
|
104
|
+
dispatch_async(queue, ^{
|
|
105
|
+
[drained fulfill];
|
|
106
|
+
});
|
|
107
|
+
[self waitForExpectations:@[ drained ] timeout:2];
|
|
108
|
+
XCTAssertEqual(settles, 1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
- (void)testASecondCompletionIsIgnored {
|
|
112
|
+
XCTestExpectation *done = [self expectationWithDescription:@"resolved"];
|
|
113
|
+
__block NSInteger settles = 0;
|
|
114
|
+
dispatch_queue_t queue = [self queue];
|
|
115
|
+
BGSRNDeleteCollectedData(
|
|
116
|
+
^(void (^completion)(BOOL)) {
|
|
117
|
+
completion(YES);
|
|
118
|
+
completion(NO);
|
|
119
|
+
},
|
|
120
|
+
5000, queue,
|
|
121
|
+
^(BOOL success) {
|
|
122
|
+
settles += 1;
|
|
123
|
+
XCTAssertTrue(success);
|
|
124
|
+
},
|
|
125
|
+
^(NSString *code) {
|
|
126
|
+
XCTFail(@"unexpected reject");
|
|
127
|
+
});
|
|
128
|
+
dispatch_async(queue, ^{
|
|
129
|
+
[done fulfill];
|
|
130
|
+
});
|
|
131
|
+
[self waitForExpectations:@[ done ] timeout:2];
|
|
132
|
+
XCTAssertEqual(settles, 1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@end
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
@import Foundation;
|
|
2
2
|
@import Bugsee;
|
|
3
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
4
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
5
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
6
|
+
#import <Bugsee/BugseeSPI.h>
|
|
7
|
+
#endif
|
|
3
8
|
|
|
4
9
|
NS_ASSUME_NONNULL_BEGIN
|
|
5
10
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@import XCTest;
|
|
2
|
+
@import BugseeRNSupport;
|
|
3
|
+
|
|
4
|
+
/// Pins `BGSRNFilterArming`: after a JS reload the previous module's JS
|
|
5
|
+
/// armed a filter, the new module's has not, and the filter must drop.
|
|
6
|
+
@interface BGSRNFilterArmingTests : XCTestCase
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@implementation BGSRNFilterArmingTests
|
|
10
|
+
|
|
11
|
+
- (void)testNothingIsArmedUntilJsArms {
|
|
12
|
+
BGSRNFilterArming *arming = [BGSRNFilterArming new];
|
|
13
|
+
NSObject *module = [NSObject new];
|
|
14
|
+
XCTAssertFalse([arming isArmedFor:module]);
|
|
15
|
+
XCTAssertFalse([arming isArmedFor:nil]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
- (void)testArmedForTheModuleThatArmed {
|
|
19
|
+
BGSRNFilterArming *arming = [BGSRNFilterArming new];
|
|
20
|
+
NSObject *module = [NSObject new];
|
|
21
|
+
[arming armFor:module];
|
|
22
|
+
XCTAssertTrue([arming isArmedFor:module]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)testANewModuleIsNotArmedByTheOldOne {
|
|
26
|
+
BGSRNFilterArming *arming = [BGSRNFilterArming new];
|
|
27
|
+
NSObject *oldModule = [NSObject new];
|
|
28
|
+
NSObject *newModule = [NSObject new];
|
|
29
|
+
[arming armFor:oldModule];
|
|
30
|
+
XCTAssertFalse([arming isArmedFor:newModule]);
|
|
31
|
+
[arming armFor:newModule];
|
|
32
|
+
XCTAssertTrue([arming isArmedFor:newModule]);
|
|
33
|
+
XCTAssertFalse([arming isArmedFor:oldModule]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)testAReleasedOwnerIsNotArmed {
|
|
37
|
+
BGSRNFilterArming *arming = [BGSRNFilterArming new];
|
|
38
|
+
NSObject *replacement = [NSObject new];
|
|
39
|
+
@autoreleasepool {
|
|
40
|
+
NSObject *gone = [NSObject new];
|
|
41
|
+
[arming armFor:gone];
|
|
42
|
+
XCTAssertTrue([arming isArmedFor:gone]);
|
|
43
|
+
}
|
|
44
|
+
XCTAssertFalse([arming isArmedFor:replacement]);
|
|
45
|
+
XCTAssertFalse([arming isArmedFor:nil]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@end
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
@import XCTest;
|
|
2
|
+
@import BugseeRNSupport;
|
|
3
|
+
|
|
4
|
+
/// Shaped like the module's pending classes: the SDK's decision block, and
|
|
5
|
+
/// the wrapper's deadline token.
|
|
6
|
+
@interface BGSRNFakePendingFilter : NSObject
|
|
7
|
+
@property (nonatomic, copy, nullable) void (^decision)(id _Nullable);
|
|
8
|
+
@property (nonatomic, copy, nullable) dispatch_block_t deadline;
|
|
9
|
+
@property (nonatomic, strong, nullable) NSNumber *expiresAt;
|
|
10
|
+
@end
|
|
11
|
+
@implementation BGSRNFakePendingFilter
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
/// The wrapper's own deadline for a filter JS never answers. The SDK has none
|
|
15
|
+
/// on iOS, so without it a hung callback keeps its request, and the event the
|
|
16
|
+
/// request retains, until the process dies.
|
|
17
|
+
@interface BGSRNFilterDeadlineTests : XCTestCase
|
|
18
|
+
@property (nonatomic, strong) NSMutableDictionary<NSString *, id> *table;
|
|
19
|
+
@property (nonatomic, strong) id lock;
|
|
20
|
+
@property (nonatomic, strong) NSMutableArray *answers;
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
@implementation BGSRNFilterDeadlineTests
|
|
24
|
+
|
|
25
|
+
- (void)setUp {
|
|
26
|
+
self.table = [NSMutableDictionary dictionary];
|
|
27
|
+
self.lock = [NSObject new];
|
|
28
|
+
self.answers = [NSMutableArray array];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Pending item whose decision records what it was answered with. `NSNull`
|
|
32
|
+
/// stands for nil, so a drop and a keep can be told apart.
|
|
33
|
+
- (BGSRNFakePendingFilter *)addPending:(NSString *)requestId {
|
|
34
|
+
BGSRNFakePendingFilter *item = [BGSRNFakePendingFilter new];
|
|
35
|
+
__weak typeof(self) weakSelf = self;
|
|
36
|
+
item.decision = ^(id value) {
|
|
37
|
+
[weakSelf.answers addObject:value ?: [NSNull null]];
|
|
38
|
+
};
|
|
39
|
+
self.table[requestId] = item;
|
|
40
|
+
return item;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Same number as Android's log and network bridges.
|
|
44
|
+
- (void)testTheDeadlineIsNineSeconds {
|
|
45
|
+
XCTAssertEqual(BGSRNFilterDeadlineMs, 9000);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)testArmedBlockRunsOnTheQueueOnlyAfterTheDeadline {
|
|
49
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
50
|
+
XCTestExpectation *fired = [self expectationWithDescription:@"expire"];
|
|
51
|
+
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
|
|
52
|
+
__block CFAbsoluteTime elapsed = 0;
|
|
53
|
+
BGSRNArmFilterDeadline(150, queue, ^{
|
|
54
|
+
elapsed = CFAbsoluteTimeGetCurrent() - start;
|
|
55
|
+
[fired fulfill];
|
|
56
|
+
});
|
|
57
|
+
[self waitForExpectations:@[ fired ] timeout:5];
|
|
58
|
+
XCTAssertGreaterThanOrEqual(elapsed, 0.14);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void)testACancelledDeadlineNeverRuns {
|
|
62
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
63
|
+
__block BOOL ran = NO;
|
|
64
|
+
dispatch_block_t token = BGSRNArmFilterDeadline(50, queue, ^{
|
|
65
|
+
ran = YES;
|
|
66
|
+
});
|
|
67
|
+
XCTAssertNotNil(token);
|
|
68
|
+
BGSRNCancelFilterDeadline(token);
|
|
69
|
+
XCTestExpectation *later = [self expectationWithDescription:@"later"];
|
|
70
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 200 * NSEC_PER_MSEC), queue, ^{
|
|
71
|
+
[later fulfill];
|
|
72
|
+
});
|
|
73
|
+
[self waitForExpectations:@[ later ] timeout:5];
|
|
74
|
+
XCTAssertFalse(ran);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- (void)testArmingWithoutAQueueOrABlockIsANoOp {
|
|
78
|
+
XCTAssertNil(BGSRNArmFilterDeadline(1, nil, ^{
|
|
79
|
+
}));
|
|
80
|
+
XCTAssertNil(BGSRNArmFilterDeadline(1, dispatch_get_main_queue(), nil));
|
|
81
|
+
BGSRNCancelFilterDeadline(nil);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// The reply and the deadline race for the same item. Exactly one takes it.
|
|
85
|
+
- (void)testOnlyTheFirstTakeGetsThePendingItem {
|
|
86
|
+
self.table[@"7"] = @"item";
|
|
87
|
+
self.table[@"8"] = @"other";
|
|
88
|
+
|
|
89
|
+
XCTAssertEqualObjects(BGSRNTakePendingFilter(self.table, self.lock, @"7"), @"item");
|
|
90
|
+
XCTAssertNil(BGSRNTakePendingFilter(self.table, self.lock, @"7"));
|
|
91
|
+
XCTAssertNil(self.table[@"7"]);
|
|
92
|
+
XCTAssertEqualObjects(self.table[@"8"], @"other");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (void)testTakingAnUnknownOrNilRequestReturnsNilAndKeepsTheTable {
|
|
96
|
+
self.table[@"1"] = @"item";
|
|
97
|
+
|
|
98
|
+
XCTAssertNil(BGSRNTakePendingFilter(self.table, self.lock, @"2"));
|
|
99
|
+
XCTAssertNil(BGSRNTakePendingFilter(self.table, self.lock, nil));
|
|
100
|
+
XCTAssertEqual(self.table.count, 1u);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// A reply takes the item through the same call, so it stops the timer too.
|
|
104
|
+
- (void)testTakingAnItemCancelsItsDeadline {
|
|
105
|
+
BGSRNFakePendingFilter *item = [self addPending:@"1"];
|
|
106
|
+
__block BOOL ran = NO;
|
|
107
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
108
|
+
item.deadline = BGSRNArmFilterDeadline(50, queue, ^{
|
|
109
|
+
ran = YES;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
XCTAssertEqual(BGSRNTakePendingFilter(self.table, self.lock, @"1"), item);
|
|
113
|
+
|
|
114
|
+
XCTestExpectation *later = [self expectationWithDescription:@"later"];
|
|
115
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 200 * NSEC_PER_MSEC), queue, ^{
|
|
116
|
+
[later fulfill];
|
|
117
|
+
});
|
|
118
|
+
[self waitForExpectations:@[ later ] timeout:5];
|
|
119
|
+
XCTAssertFalse(ran);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// What the deadline does to a request: answer the SDK's decision with nil,
|
|
123
|
+
/// never with the item, and only once.
|
|
124
|
+
- (void)testDroppingAnswersTheDecisionWithNilExactlyOnce {
|
|
125
|
+
[self addPending:@"1"];
|
|
126
|
+
[self addPending:@"2"];
|
|
127
|
+
|
|
128
|
+
XCTAssertTrue(BGSRNDropPendingFilter(self.table, self.lock, @"1"));
|
|
129
|
+
XCTAssertFalse(BGSRNDropPendingFilter(self.table, self.lock, @"1"));
|
|
130
|
+
|
|
131
|
+
XCTAssertEqual(self.answers.count, 1u);
|
|
132
|
+
XCTAssertEqualObjects(self.answers[0], [NSNull null]);
|
|
133
|
+
XCTAssertNil(self.table[@"1"]);
|
|
134
|
+
XCTAssertNotNil(self.table[@"2"]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)testDroppingAnUnknownRequestAnswersNothing {
|
|
138
|
+
XCTAssertFalse(BGSRNDropPendingFilter(self.table, self.lock, @"9"));
|
|
139
|
+
XCTAssertEqual(self.answers.count, 0u);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
- (void)testDroppingAnItemWithoutADecisionStillRemovesIt {
|
|
143
|
+
self.table[@"1"] = [BGSRNFakePendingFilter new];
|
|
144
|
+
|
|
145
|
+
XCTAssertTrue(BGSRNDropPendingFilter(self.table, self.lock, @"1"));
|
|
146
|
+
XCTAssertNil(self.table[@"1"]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/// The module's path end to end: armed on the request, the deadline passes,
|
|
150
|
+
/// the decision gets nil, and a reply afterwards finds nothing.
|
|
151
|
+
- (void)testAnArmedRequestIsDroppedAtTheDeadlineAndALateReplyFindsNothing {
|
|
152
|
+
BGSRNFakePendingFilter *item = [self addPending:@"1"];
|
|
153
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
154
|
+
|
|
155
|
+
BGSRNArmPendingFilterDeadlineAfter(50, queue, self.table, self.lock, @"1");
|
|
156
|
+
XCTAssertNotNil(item.deadline);
|
|
157
|
+
XCTAssertEqual(self.answers.count, 0u);
|
|
158
|
+
|
|
159
|
+
XCTestExpectation *later = [self expectationWithDescription:@"later"];
|
|
160
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC), queue, ^{
|
|
161
|
+
[later fulfill];
|
|
162
|
+
});
|
|
163
|
+
[self waitForExpectations:@[ later ] timeout:5];
|
|
164
|
+
|
|
165
|
+
XCTAssertEqual(self.answers.count, 1u);
|
|
166
|
+
XCTAssertEqualObjects(self.answers[0], [NSNull null]);
|
|
167
|
+
XCTAssertNil(BGSRNTakePendingFilter(self.table, self.lock, @"1"));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/// The reply wins: its take cancels the timer, so the decision is not
|
|
171
|
+
/// answered a second time with nil.
|
|
172
|
+
- (void)testAReplyBeforeTheDeadlineLeavesTheDeadlineNothing {
|
|
173
|
+
[self addPending:@"1"];
|
|
174
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
175
|
+
BGSRNArmPendingFilterDeadlineAfter(100, queue, self.table, self.lock, @"1");
|
|
176
|
+
|
|
177
|
+
BGSRNFakePendingFilter *item = BGSRNTakePendingFilter(self.table, self.lock, @"1");
|
|
178
|
+
item.decision(@"kept");
|
|
179
|
+
|
|
180
|
+
XCTestExpectation *later = [self expectationWithDescription:@"later"];
|
|
181
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC), queue, ^{
|
|
182
|
+
[later fulfill];
|
|
183
|
+
});
|
|
184
|
+
[self waitForExpectations:@[ later ] timeout:5];
|
|
185
|
+
|
|
186
|
+
XCTAssertEqual(self.answers.count, 1u);
|
|
187
|
+
XCTAssertEqualObjects(self.answers[0], @"kept");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// The deadline's queue is starved, so its block has not run, but the
|
|
191
|
+
/// deadline has passed. A reply that takes the item first is refused: the
|
|
192
|
+
/// decision is answered nil and nothing is returned to apply.
|
|
193
|
+
- (void)testAReplyPastTheDeadlineIsRefusedEvenIfTheTimerBlockHasNotRun {
|
|
194
|
+
BGSRNFakePendingFilter *item = [self addPending:@"1"];
|
|
195
|
+
dispatch_queue_t queue = dispatch_queue_create("test.starved", DISPATCH_QUEUE_SERIAL);
|
|
196
|
+
dispatch_semaphore_t release = dispatch_semaphore_create(0);
|
|
197
|
+
dispatch_async(queue, ^{
|
|
198
|
+
dispatch_semaphore_wait(release, DISPATCH_TIME_FOREVER);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
BGSRNArmPendingFilterDeadlineAfter(30, queue, self.table, self.lock, @"1");
|
|
202
|
+
XCTAssertNotNil(item.expiresAt);
|
|
203
|
+
[NSThread sleepForTimeInterval:0.15];
|
|
204
|
+
|
|
205
|
+
XCTAssertNil(BGSRNTakePendingFilter(self.table, self.lock, @"1"));
|
|
206
|
+
XCTAssertEqual(self.answers.count, 1u);
|
|
207
|
+
XCTAssertEqualObjects(self.answers[0], [NSNull null]);
|
|
208
|
+
XCTAssertNil(self.table[@"1"]);
|
|
209
|
+
|
|
210
|
+
// The starved timer finally runs and finds nothing.
|
|
211
|
+
dispatch_semaphore_signal(release);
|
|
212
|
+
XCTestExpectation *drained = [self expectationWithDescription:@"drained"];
|
|
213
|
+
dispatch_async(queue, ^{
|
|
214
|
+
[drained fulfill];
|
|
215
|
+
});
|
|
216
|
+
[self waitForExpectations:@[ drained ] timeout:5];
|
|
217
|
+
XCTAssertEqual(self.answers.count, 1u);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// Inside the deadline a reply is still taken normally.
|
|
221
|
+
- (void)testAReplyInsideTheDeadlineIsStillTaken {
|
|
222
|
+
BGSRNFakePendingFilter *item = [self addPending:@"1"];
|
|
223
|
+
dispatch_queue_t queue = dispatch_queue_create("test.deadline", DISPATCH_QUEUE_SERIAL);
|
|
224
|
+
BGSRNArmPendingFilterDeadlineAfter(5000, queue, self.table, self.lock, @"1");
|
|
225
|
+
|
|
226
|
+
XCTAssertEqual(BGSRNTakePendingFilter(self.table, self.lock, @"1"), item);
|
|
227
|
+
XCTAssertEqual(self.answers.count, 0u);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@end
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
@import XCTest;
|
|
2
2
|
@import Bugsee;
|
|
3
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
4
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
5
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
6
|
+
#import <Bugsee/BugseeSPI.h>
|
|
7
|
+
#endif
|
|
3
8
|
@import BugseeRNSupport;
|
|
4
9
|
|
|
5
10
|
#import "BGSRNFakeReport.h"
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
@interface BGSRNFakeSpan : NSObject <BGSRNRetainedSpan>
|
|
6
6
|
@property (nonatomic) BOOL finished;
|
|
7
|
+
@property (nonatomic) NSInteger finishCalls;
|
|
7
8
|
@property (nonatomic, strong) NSNumber *finishedWith;
|
|
9
|
+
@property (nonatomic, strong) NSMutableArray<BGSRNFakeSpan *> *order;
|
|
8
10
|
@property (nonatomic, strong) NSMutableArray<BGSRNFakeSpan *> *children;
|
|
9
11
|
@end
|
|
10
12
|
|
|
@@ -18,14 +20,16 @@
|
|
|
18
20
|
return self;
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
/// No self-guard against a second finish: a registry that finishes a span
|
|
24
|
+
/// twice shows in `finishCalls`.
|
|
21
25
|
- (void)bgsrnFinishWithStatus:(NSNumber *)status {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
26
|
+
_finishCalls += 1;
|
|
27
|
+
[_order addObject:self];
|
|
25
28
|
_finished = YES;
|
|
26
29
|
_finishedWith = status;
|
|
27
30
|
for (BGSRNFakeSpan *child in _children) {
|
|
28
31
|
if (!child.finished) {
|
|
32
|
+
child.order = _order;
|
|
29
33
|
[child bgsrnFinishWithStatus:@(BGSSpanStatusCancelled)];
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -35,6 +39,10 @@
|
|
|
35
39
|
return _finished;
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
- (NSInteger)bgsrnStatus {
|
|
43
|
+
return _finishedWith != nil ? _finishedWith.integerValue : BGSSpanStatusOK;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
@end
|
|
39
47
|
|
|
40
48
|
@interface BGSRNStickySpan : NSObject <BGSRNRetainedSpan>
|
|
@@ -48,19 +56,89 @@
|
|
|
48
56
|
- (BOOL)bgsrnIsFinished {
|
|
49
57
|
return NO;
|
|
50
58
|
}
|
|
59
|
+
- (NSInteger)bgsrnStatus {
|
|
60
|
+
return BGSSpanStatusUnknown;
|
|
61
|
+
}
|
|
62
|
+
@end
|
|
63
|
+
|
|
64
|
+
@interface BGSRNThrowingSpan : BGSRNStickySpan
|
|
65
|
+
@end
|
|
66
|
+
|
|
67
|
+
@implementation BGSRNThrowingSpan
|
|
68
|
+
- (void)bgsrnFinishWithStatus:(NSNumber *)status {
|
|
69
|
+
@throw [NSException exceptionWithName:@"boom" reason:@"boom" userInfo:nil];
|
|
70
|
+
}
|
|
51
71
|
@end
|
|
52
72
|
|
|
73
|
+
static NSArray<NSString *> *BGSRNHandlesOf(NSArray<NSDictionary *> *released) {
|
|
74
|
+
NSMutableArray<NSString *> *out = [NSMutableArray array];
|
|
75
|
+
for (NSDictionary *item in released) {
|
|
76
|
+
[out addObject:item[@"handle"]];
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
53
81
|
@interface BGSRNSpanHandlesTests : XCTestCase
|
|
54
82
|
@end
|
|
55
83
|
|
|
56
84
|
@implementation BGSRNSpanHandlesTests
|
|
57
85
|
|
|
86
|
+
/// A reload must not leave transactions open in the SDK.
|
|
87
|
+
- (void)testCancelOpenAndReleaseAllCancelsOwnedOpenSpansParentFirstAndOnce {
|
|
88
|
+
BGSRNSpanHandles *handles = [BGSRNSpanHandles new];
|
|
89
|
+
NSMutableArray<BGSRNFakeSpan *> *order = [NSMutableArray array];
|
|
90
|
+
BGSRNFakeSpan *parent = [BGSRNFakeSpan new];
|
|
91
|
+
BGSRNFakeSpan *child = [BGSRNFakeSpan new];
|
|
92
|
+
BGSRNFakeSpan *done = [BGSRNFakeSpan new];
|
|
93
|
+
parent.order = order;
|
|
94
|
+
child.order = order;
|
|
95
|
+
done.order = order;
|
|
96
|
+
done.finished = YES;
|
|
97
|
+
[parent.children addObject:child];
|
|
98
|
+
[handles retainSpan:parent adapter:parent];
|
|
99
|
+
[handles retainSpan:child adapter:child];
|
|
100
|
+
[handles retainSpan:done adapter:done];
|
|
101
|
+
[handles cancelOpenAndReleaseAll];
|
|
102
|
+
XCTAssertEqual(parent.finishCalls, 1);
|
|
103
|
+
XCTAssertEqualObjects(parent.finishedWith, @(BGSSpanStatusCancelled));
|
|
104
|
+
XCTAssertEqual(child.finishCalls, 1);
|
|
105
|
+
XCTAssertEqualObjects(child.finishedWith, @(BGSSpanStatusCancelled));
|
|
106
|
+
XCTAssertEqual(done.finishCalls, 0, @"an already-finished span is skipped");
|
|
107
|
+
XCTAssertEqualObjects(order, (@[parent, child]));
|
|
108
|
+
XCTAssertEqual(handles.liveCount, 0u);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// The active span belongs to the SDK or the app, not to this runtime.
|
|
112
|
+
- (void)testCancelOpenAndReleaseAllDropsAdoptedSpansWithoutCancellingThem {
|
|
113
|
+
BGSRNSpanHandles *handles = [BGSRNSpanHandles new];
|
|
114
|
+
BGSRNFakeSpan *adopted = [BGSRNFakeSpan new];
|
|
115
|
+
BGSRNFakeSpan *owned = [BGSRNFakeSpan new];
|
|
116
|
+
[handles retainSpan:adopted adapter:adopted owned:NO];
|
|
117
|
+
[handles retainSpan:owned adapter:owned owned:YES];
|
|
118
|
+
[handles cancelOpenAndReleaseAll];
|
|
119
|
+
XCTAssertEqual(adopted.finishCalls, 0);
|
|
120
|
+
XCTAssertFalse(adopted.finished);
|
|
121
|
+
XCTAssertEqual(owned.finishCalls, 1);
|
|
122
|
+
XCTAssertEqual(handles.liveCount, 0u);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (void)testCancelOpenAndReleaseAllSurvivesASpanThatThrows {
|
|
126
|
+
BGSRNSpanHandles *handles = [BGSRNSpanHandles new];
|
|
127
|
+
BGSRNThrowingSpan *bad = [BGSRNThrowingSpan new];
|
|
128
|
+
BGSRNFakeSpan *next = [BGSRNFakeSpan new];
|
|
129
|
+
[handles retainSpan:bad adapter:bad];
|
|
130
|
+
[handles retainSpan:next adapter:next];
|
|
131
|
+
[handles cancelOpenAndReleaseAll];
|
|
132
|
+
XCTAssertEqual(next.finishCalls, 1);
|
|
133
|
+
XCTAssertEqual(handles.liveCount, 0u);
|
|
134
|
+
}
|
|
135
|
+
|
|
58
136
|
/// The pin: after finish the registry must not still hold the span.
|
|
59
137
|
- (void)testAFinishedSpanIsReleased {
|
|
60
138
|
BGSRNSpanHandles *handles = [BGSRNSpanHandles new];
|
|
61
139
|
BGSRNFakeSpan *span = [BGSRNFakeSpan new];
|
|
62
140
|
NSString *handle = [handles retainSpan:span adapter:span];
|
|
63
|
-
NSArray<NSString *> *released = [handles finishHandle:handle status:nil];
|
|
141
|
+
NSArray<NSString *> *released = BGSRNHandlesOf([handles finishHandle:handle status:nil]);
|
|
64
142
|
XCTAssertEqualObjects(released, @[handle]);
|
|
65
143
|
XCTAssertTrue(span.finished);
|
|
66
144
|
XCTAssertNil(span.finishedWith);
|
|
@@ -75,7 +153,9 @@
|
|
|
75
153
|
[parent.children addObject:child];
|
|
76
154
|
NSString *parentHandle = [handles retainSpan:parent adapter:parent];
|
|
77
155
|
NSString *childHandle = [handles retainSpan:child adapter:child];
|
|
78
|
-
NSArray<
|
|
156
|
+
NSArray<NSDictionary *> *releasedItems = [handles finishHandle:parentHandle status:nil];
|
|
157
|
+
NSArray<NSString *> *released = BGSRNHandlesOf(releasedItems);
|
|
158
|
+
XCTAssertEqual([releasedItems[1][@"status"] integerValue], (NSInteger)BGSSpanStatusCancelled);
|
|
79
159
|
XCTAssertTrue([released containsObject:parentHandle]);
|
|
80
160
|
XCTAssertTrue([released containsObject:childHandle]);
|
|
81
161
|
XCTAssertTrue(child.finished);
|
|
@@ -111,7 +191,7 @@
|
|
|
111
191
|
BGSRNSpanHandles *handles = [BGSRNSpanHandles new];
|
|
112
192
|
BGSRNStickySpan *span = [BGSRNStickySpan new];
|
|
113
193
|
NSString *handle = [handles retainSpan:span adapter:span];
|
|
114
|
-
NSArray<NSString *> *released = [handles finishHandle:handle status:nil];
|
|
194
|
+
NSArray<NSString *> *released = BGSRNHandlesOf([handles finishHandle:handle status:nil]);
|
|
115
195
|
XCTAssertEqualObjects(released, @[handle]);
|
|
116
196
|
XCTAssertTrue(span.finishCalled);
|
|
117
197
|
XCTAssertFalse(span.bgsrnIsFinished);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
@import XCTest;
|
|
2
2
|
@import Bugsee;
|
|
3
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
4
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
5
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
6
|
+
#import <Bugsee/BugseeSPI.h>
|
|
7
|
+
#endif
|
|
3
8
|
@import BugseeRNSupport;
|
|
4
9
|
|
|
5
10
|
/// Records every call it receives. Implements every optional channel method,
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
- (void)testWithoutJsRuntimeCarriesOnlyTypeAndVersion {
|
|
59
59
|
BGSRNWrapper *wrapper = [BGSRNWrapper wrapperWithoutJsRuntime];
|
|
60
60
|
XCTAssertEqualObjects(wrapper.wrapperType, @"react_native");
|
|
61
|
-
XCTAssertEqualObjects(wrapper.wrapperVersion, @"7.0.0-
|
|
61
|
+
XCTAssertEqualObjects(wrapper.wrapperVersion, @"7.0.0-beta4");
|
|
62
62
|
XCTAssertNil(wrapper.wrapperBuild);
|
|
63
63
|
XCTAssertEqual(wrapper.context.count, (NSUInteger)0);
|
|
64
64
|
}
|
package/native-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -12,6 +12,17 @@ export declare function resolveNativeCliPackageSource(packageJson: string): stri
|
|
|
12
12
|
* Shared with the bare example's scheme (scripts/__tests__/dsym-scheme-post-action.test.ts).
|
|
13
13
|
*/
|
|
14
14
|
export declare const TOKEN_GUARD: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Looks for the token in ios/.xcode.env and ios/.xcode.env.local, the files
|
|
17
|
+
* the README sends a bare app's `export BUGSEE_APP_TOKEN=...` to for the
|
|
18
|
+
* bundle phase. A GUI Archive does not inherit a shell, so the post-action
|
|
19
|
+
* reads them itself, and only when no earlier source gave a token. Each file
|
|
20
|
+
* is sourced in a subshell that prints the token: a file written for bash, a
|
|
21
|
+
* syntax error or an `exit` in it cannot stop this script or change its
|
|
22
|
+
* NODE_BINARY or BUGSEE_ENDPOINT, and the later file (.local) wins. Shared
|
|
23
|
+
* with the bare example's scheme (scripts/__tests__/dsym-scheme-post-action.test.ts).
|
|
24
|
+
*/
|
|
25
|
+
export declare const ENV_FILE_TOKEN: readonly string[];
|
|
15
26
|
/**
|
|
16
27
|
* Relays bugsee-cli output with Xcode's `error:` diagnostics turned into
|
|
17
28
|
* `warning: bugsee: ...`, and returns the CLI's exit status. A failed upload
|