Skip to content

Commit dbcaf78

Browse files
committed
feat: visionOS unit tests (#257)
1 parent f26d72c commit dbcaf78

File tree

7 files changed

+93
-26
lines changed

7 files changed

+93
-26
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ To start diving into the v8 iOS runtime make sure you have Xcode and [Homebrew](
55
# Install CMake
66
brew install cmake
77

8+
# Install jq (for scripting json replacements)
9+
brew install jq
10+
811
# (Optional) Install clang-format to format the code
912
brew install clang-format
1013

TestFixtures/Api/TNSVersions.h

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
#define generateVersionDeclarations(V1, V2) \
2-
__attribute__((availability(ios, introduced = V1))) @interface TNSInterface \
3-
##V2##Plus : NSObject @end \
4-
\
5-
@interface TNSInterfaceMembers \
6-
##V2 : NSObject @property int property __attribute__((availability(ios, introduced = V1))); \
7-
\
8-
+(void)staticMethod __attribute__((availability(ios, introduced = V1))); \
9-
\
10-
-(void)instanceMethod __attribute__((availability(ios, introduced = V1))); \
11-
@end \
12-
\
13-
__attribute__((availability(ios, introduced = V1))) void TNSFunction##V2##Plus(); \
14-
\
15-
__attribute__((availability(ios, introduced = V1))) extern const int TNSConstant##V2##Plus; \
16-
\
17-
enum TNSEnum##V2##Plus { TNSEnum##V2##Member } \
18-
__attribute__((availability(ios, introduced = V1)))
1+
#define generateVersionDeclarations(V1, V2) \
2+
__attribute__((availability(ios, introduced = V1))) \
3+
__attribute__((availability(visionos, introduced = V1))) @interface TNSInterface \
4+
##V2##Plus : NSObject @end \
5+
\
6+
@interface TNSInterfaceMembers \
7+
##V2 : NSObject @property int property __attribute__((availability(ios, introduced = V1))) \
8+
__attribute__((availability(visionos, introduced = V1))); \
9+
\
10+
+(void)staticMethod __attribute__((availability(ios, introduced = V1))) \
11+
__attribute__((availability(visionos, introduced = V1))); \
12+
\
13+
-(void)instanceMethod __attribute__((availability(ios, introduced = V1))) \
14+
__attribute__((availability(visionos, introduced = V1))); \
15+
@end \
16+
\
17+
__attribute__((availability(ios, introduced = V1))) \
18+
__attribute__((availability(visionos, introduced = V1))) void TNSFunction##V2##Plus(); \
19+
\
20+
__attribute__((availability(ios, introduced = V1))) __attribute__( \
21+
(availability(visionos, introduced = V1))) extern const int TNSConstant##V2##Plus; \
22+
\
23+
enum TNSEnum##V2##Plus { TNSEnum##V2##Member } \
24+
__attribute__((availability(ios, introduced = V1))) \
25+
__attribute__((availability(visionos, introduced = V1)))
1926

2027
#ifndef generateVersionImpl
2128
#define generateVersion(V1, V2) generateVersionDeclarations(V1, V2)
@@ -45,6 +52,8 @@
4552
generateVersion(MAJOR##.4, MAJOR##_4); \
4653
generateVersion(MAJOR##.5, MAJOR##_5);
4754

55+
generateMinors(1);
56+
generateMinors(2);
4857
generateMinors(9);
4958
generateMinors(10);
5059
generateMinors(11);
@@ -58,6 +67,7 @@ generateMinors(15);
5867
#define MAX_AVAILABILITY 31.7
5968

6069
__attribute__((availability(ios, introduced = MAX_AVAILABILITY)))
70+
__attribute__((availability(visionos, introduced = MAX_AVAILABILITY)))
6171
@protocol TNSProtocolNeverAvailable<NSObject>
6272

6373
@property(class, readonly) int staticPropertyFromProtocolNeverAvailable;
@@ -74,7 +84,9 @@ __attribute__((availability(ios, introduced = MAX_AVAILABILITY)))
7484

7585
@end
7686

77-
__attribute__((availability(ios, introduced = 1.0))) @protocol TNSProtocolAlwaysAvailable<NSObject>
87+
__attribute__((availability(ios, introduced = 1.0)))
88+
__attribute__((availability(visionos, introduced = 1.0)))
89+
@protocol TNSProtocolAlwaysAvailable<NSObject>
7890

7991
@property(class, readonly) int staticPropertyFromProtocolAlwaysAvailable;
8092

@@ -91,6 +103,7 @@ __attribute__((availability(ios, introduced = 1.0))) @protocol TNSProtocolAlways
91103
@end
92104

93105
__attribute__((availability(ios, introduced = MAX_AVAILABILITY)))
106+
__attribute__((availability(visionos, introduced = MAX_AVAILABILITY)))
94107
@interface TNSInterfaceNeverAvailable : TNSInterfaceAlwaysAvailable
95108
@end
96109

TestFixtures/exported-symbols.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ _functionWithUShortPtr
5858
_TNSIsConfigurationDebug
5959
_TNSClearOutput
6060
_TNSConstant
61+
_TNSConstant1_0Plus
62+
_TNSConstant1_1Plus
63+
_TNSConstant1_2Plus
6164
_TNSConstant10_0Plus
6265
_TNSConstant10_1Plus
6366
_TNSConstant10_2Plus
@@ -94,12 +97,18 @@ _TNSConstant15_2Plus
9497
_TNSConstant15_3Plus
9598
_TNSConstant15_4Plus
9699
_TNSConstant15_5Plus
100+
_TNSConstant1_0Plus
101+
_TNSConstant1_1Plus
102+
_TNSConstant1_2Plus
97103
_TNSConstant9_0Plus
98104
_TNSConstant9_1Plus
99105
_TNSConstant9_2Plus
100106
_TNSConstant9_3Plus
101107
_TNSConstant9_4Plus
102108
_TNSConstant9_5Plus
109+
_TNSFunction1_0Plus
110+
_TNSFunction1_1Plus
111+
_TNSFunction1_2Plus
103112
_TNSFunction9_0Plus
104113
_TNSFunction9_1Plus
105114
_TNSFunction9_2Plus

TestRunner/app/tests/Infrastructure/simulator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ function isSimulator() {
77
}
88

99
global.isSimulator = isSimulator();
10+
11+
function isVision() {
12+
return UIDevice.currentDevice.model.toLowerCase().includes('vision');
13+
}
14+
15+
global.isVision = isVision();

TestRunner/app/tests/MetadataTests.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ describe("Metadata", function () {
1010
const swiftLikeObj = TNSSwiftLikeFactory.create();
1111
expect(swiftLikeObj.constructor).toBe(global.TNSSwiftLike);
1212
expect(swiftLikeObj.constructor.name).toBe("_TtC17NativeScriptTests12TNSSwiftLike");
13-
var expectedName = NSProcessInfo.processInfo.isOperatingSystemAtLeastVersion({ majorVersion: 13, minorVersion: 4, patchVersion: 0 })
13+
let majorVersion = 13;
14+
let minorVersion = 4;
15+
if (isVision) {
16+
majorVersion = 1;
17+
minorVersion = 0;
18+
}
19+
var expectedName = NSProcessInfo.processInfo.isOperatingSystemAtLeastVersion({ majorVersion: majorVersion, minorVersion: minorVersion, patchVersion: 0 })
1420
? "_TtC17NativeScriptTests12TNSSwiftLike"
1521
: "NativeScriptTests.TNSSwiftLike";
1622
expect(NSString.stringWithUTF8String(class_getName(swiftLikeObj.constructor)).toString()).toBe(expectedName);

TestRunner/app/tests/VersionDiffTests.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ describe(module.id, function() {
1717
}
1818

1919
function forEachVersion(action) {
20-
for (var major = 9; major <= 15; major++) {
21-
for (var minor = 0; minor <= 5; minor++) {
20+
let majorMinVersion = 9;
21+
let majorMaxVersion = 15;
22+
let minorMaxVersion = 5;
23+
if (isVision) {
24+
majorMinVersion = 1;
25+
majorMaxVersion = 1;
26+
minorMaxVersion = 2;
27+
}
28+
for (var major = majorMinVersion; major <= majorMaxVersion; major++) {
29+
for (var minor = 0; minor <= minorMaxVersion; minor++) {
2230
action(major, minor);
2331
}
2432
}
@@ -74,6 +82,10 @@ describe(module.id, function() {
7482
});
7583

7684
it("Base class which is unavailable should be skipped", function() {
85+
if (isVision) {
86+
pending();
87+
return;
88+
}
7789
// Test case inspired from MTLArrayType(8.0) : MTLType(11.0) : NSObject
7890
// TNSInterfaceNeverAvailableDescendant : TNSInterfaceNeverAvailable(API31.7 - skipped) : TNSInterfaceAlwaysAvailable
7991
expect(Object.getPrototypeOf(TNSInterfaceNeverAvailableDescendant).toString()).toBe(TNSInterfaceAlwaysAvailable.toString(), "TNSInterfaceNeverAvailable base class should be skipped as it is unavailable");

v8ios.xcodeproj/project.pbxproj

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
2B5088A62BBEB92300F6EB68 /* metadata-arm64.bin in Resources */ = {isa = PBXBuildFile; fileRef = 2BFE21ED2AC1AC3100307752 /* metadata-arm64.bin */; };
1110
2B5088A72BBEC1BC00F6EB68 /* TNSWidgets.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20525A72577D86600C12A5C /* TNSWidgets.xcframework */; };
12-
2B5088A82BBEC1BC00F6EB68 /* TNSWidgets.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C20525A72577D86600C12A5C /* TNSWidgets.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1311
2B7EA6AF2353477000E5184E /* NativeScriptException.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2B7EA6AD2353476F00E5184E /* NativeScriptException.mm */; };
1412
2B7EA6B02353477000E5184E /* NativeScriptException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7EA6AE2353477000E5184E /* NativeScriptException.h */; };
1513
2BFE22062AC1C93100307752 /* metadata-arm64.bin in Resources */ = {isa = PBXBuildFile; fileRef = 2BFE22052AC1C93100307752 /* metadata-arm64.bin */; };
@@ -1850,7 +1848,6 @@
18501848
files = (
18511849
C27E5DB522F3206B00498ED0 /* app in Resources */,
18521850
C27E5DBA22F324C200498ED0 /* [email protected] in Resources */,
1853-
2B5088A62BBEB92300F6EB68 /* metadata-arm64.bin in Resources */,
18541851
);
18551852
runOnlyForDeploymentPostprocessing = 0;
18561853
};
@@ -2290,7 +2287,6 @@
22902287
};
22912288
C293752B229FC4740075CB16 /* PBXTargetDependency */ = {
22922289
isa = PBXTargetDependency;
2293-
platformFilter = ios;
22942290
target = C29374E1229FC0F60075CB16 /* TestFixtures */;
22952291
targetProxy = C293752A229FC4740075CB16 /* PBXContainerItemProxy */;
22962292
};
@@ -2384,6 +2380,7 @@
23842380
C23992CE236C2D6E00D2F720 /* Debug */ = {
23852381
isa = XCBuildConfiguration;
23862382
buildSettings = {
2383+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
23872384
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
23882385
CLANG_ENABLE_MODULES = NO;
23892386
CODE_SIGN_STYLE = Automatic;
@@ -2399,6 +2396,8 @@
23992396
);
24002397
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TestRunnerTests;
24012398
PRODUCT_NAME = "$(TARGET_NAME)";
2399+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2400+
SUPPORTS_MACCATALYST = YES;
24022401
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
24032402
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
24042403
SWIFT_VERSION = 5.0;
@@ -2410,6 +2409,7 @@
24102409
C23992CF236C2D6E00D2F720 /* Release */ = {
24112410
isa = XCBuildConfiguration;
24122411
buildSettings = {
2412+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
24132413
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
24142414
CLANG_ENABLE_MODULES = NO;
24152415
CODE_SIGN_STYLE = Automatic;
@@ -2425,6 +2425,8 @@
24252425
);
24262426
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TestRunnerTests;
24272427
PRODUCT_NAME = "$(TARGET_NAME)";
2428+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2429+
SUPPORTS_MACCATALYST = YES;
24282430
SWIFT_COMPILATION_MODE = wholemodule;
24292431
SWIFT_OPTIMIZATION_LEVEL = "-O";
24302432
SWIFT_VERSION = 5.0;
@@ -2557,6 +2559,7 @@
25572559
C27E5D9F22F31CCC00498ED0 /* Debug */ = {
25582560
isa = XCBuildConfiguration;
25592561
buildSettings = {
2562+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
25602563
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
25612564
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
25622565
CLANG_CXX_LIBRARY = "compiler-default";
@@ -2588,13 +2591,16 @@
25882591
);
25892592
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.AppWithModules;
25902593
PRODUCT_NAME = "$(TARGET_NAME)";
2594+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2595+
SUPPORTS_MACCATALYST = YES;
25912596
TARGETED_DEVICE_FAMILY = 1;
25922597
};
25932598
name = Debug;
25942599
};
25952600
C27E5DA022F31CCC00498ED0 /* Release */ = {
25962601
isa = XCBuildConfiguration;
25972602
buildSettings = {
2603+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
25982604
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
25992605
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
26002606
CLANG_CXX_LIBRARY = "compiler-default";
@@ -2626,13 +2632,16 @@
26262632
);
26272633
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.AppWithModules;
26282634
PRODUCT_NAME = "$(TARGET_NAME)";
2635+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2636+
SUPPORTS_MACCATALYST = YES;
26292637
TARGETED_DEVICE_FAMILY = 1;
26302638
};
26312639
name = Release;
26322640
};
26332641
C29374E9229FC0F60075CB16 /* Debug */ = {
26342642
isa = XCBuildConfiguration;
26352643
buildSettings = {
2644+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
26362645
CLANG_ENABLE_MODULES = NO;
26372646
CLANG_WARN_STRICT_PROTOTYPES = NO;
26382647
DEFINES_MODULE = YES;
@@ -2641,7 +2650,10 @@
26412650
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
26422651
OTHER_LDFLAGS = "-ObjC";
26432652
PRODUCT_NAME = "$(TARGET_NAME)";
2653+
SDKROOT = iphoneos;
26442654
SKIP_INSTALL = YES;
2655+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2656+
SUPPORTS_MACCATALYST = YES;
26452657
SYMROOT = build;
26462658
TARGETED_DEVICE_FAMILY = "1,2";
26472659
};
@@ -2650,6 +2662,7 @@
26502662
C29374EA229FC0F60075CB16 /* Release */ = {
26512663
isa = XCBuildConfiguration;
26522664
buildSettings = {
2665+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
26532666
CLANG_ENABLE_MODULES = NO;
26542667
CLANG_WARN_STRICT_PROTOTYPES = NO;
26552668
DEFINES_MODULE = YES;
@@ -2659,7 +2672,10 @@
26592672
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
26602673
OTHER_LDFLAGS = "-ObjC";
26612674
PRODUCT_NAME = "$(TARGET_NAME)";
2675+
SDKROOT = iphoneos;
26622676
SKIP_INSTALL = YES;
2677+
SUPPORTED_PLATFORMS = "xrsimulator xros iphonesimulator iphoneos";
2678+
SUPPORTS_MACCATALYST = YES;
26632679
SYMROOT = build;
26642680
TARGETED_DEVICE_FAMILY = "1,2";
26652681
};
@@ -2847,6 +2863,7 @@
28472863
__DATA,
28482864
__TNSMetadata,
28492865
"\"$(SRCROOT)/NativeScript/metadata-arm64.bin\"",
2866+
"-w",
28502867
);
28512868
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.NativeScript;
28522869
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@@ -2939,6 +2956,7 @@
29392956
__DATA,
29402957
__TNSMetadata,
29412958
"\"$(SRCROOT)/NativeScript/metadata-arm64.bin\"",
2959+
"-w",
29422960
);
29432961
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.NativeScript;
29442962
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";

0 commit comments

Comments
 (0)