Skip to content

Commit 74a41d1

Browse files
authored
feat: make tests green with Xcode10 (#150)
1 parent fd6e31f commit 74a41d1

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

core/tns/tns.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
486486
attr = {"--provision": PROVISIONING}
487487
attributes.update(attr)
488488

489-
output = Tns.run_tns_command("build ios", attributes=attributes, tns_path=tns_path, log_trace=log_trace, measureTime=measureTime)
489+
output = Tns.run_tns_command("build ios", attributes=attributes, tns_path=tns_path, log_trace=log_trace,
490+
measureTime=measureTime)
490491

491492
app_name = Tns.__get_app_name_from_attributes(attributes=attributes)
492493
app_name = app_name.replace("\"", "") # Handle projects with space
@@ -505,9 +506,15 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
505506

506507
# Verify release/debug builds
507508
if "--release" in attributes.keys():
508-
assert "CONFIGURATION Release" in output
509+
if Xcode.get_version() < 10:
510+
assert "CONFIGURATION Release" in output
511+
else:
512+
assert '"-configuration" "Release"' in output
509513
else:
510-
assert "CONFIGURATION Debug" in output
514+
if Xcode.get_version() < 10:
515+
assert "CONFIGURATION Debug" in output
516+
else:
517+
assert '"-configuration" "Debug"' in output
511518

512519
# Verify simulator/device builds
513520
device_folder = app_name + "/platforms/ios/build/device/"
@@ -531,7 +538,7 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
531538
assert "build/emulator/" + app_id + ".app" in output
532539
else:
533540
# Xcode 8.* output contains some warnings for images, so we will assert only on Xcode 9.*
534-
if "9." in Xcode.get_version():
541+
if Xcode.get_version() >= 9:
535542
assert "CompileStoryboard" not in output, "Native build out is displayed!"
536543
assert "CompileAssetCatalog" not in output, "Native build out is displayed!"
537544
assert "ProcessInfoPlistFile" not in output, "Native build out is displayed!"

core/xcode/xcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ def get_version():
2020
Get Xcode version
2121
:return: Version as string.
2222
"""
23-
output = run(command="xcodebuild -version | grep Xcode", log_level=CommandLogLevel.SILENT)
24-
return output.replace("Xcode ", "")
23+
output = run(command="xcodebuild -version | head -n 1 | sed -e 's/Xcode //'", log_level=CommandLogLevel.SILENT)
24+
return int(output.split('.')[0])

runNose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_repos():
8181
get_test_packages(platform=Platform.BOTH)
8282
Simulator.reset()
8383

84-
if "8." in Xcode.get_version():
84+
if Xcode.get_version() < 9:
8585
SIMULATOR_SDK = '10.0'
8686

8787
Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK)

tests/build/ios/build_ios_tests.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class BuildiOSTests(BaseClass):
2222
app_name_dash = "test-app"
2323
app_name_space = "Test App"
24-
app_name_noplatform = "Test_AppNoPlatform"
24+
app_name_no_platform = "Test_AppNoPlatform"
2525
app_name_ios = "testapp_ios"
2626

2727
@classmethod
@@ -35,15 +35,14 @@ def setUpClass(cls):
3535

3636
Xcode.cleanup_cache()
3737

38-
3938
def setUp(self):
4039
BaseClass.setUp(self)
4140
Simulator.stop()
4241
Folder.cleanup(self.app_name_dash)
4342
Folder.cleanup(self.app_name_space)
4443
Folder.cleanup(self.app_name_ios)
45-
Folder.cleanup(self.app_name_noplatform)
46-
Folder.cleanup(self.app_name_noplatform + '/platforms/ios/build')
44+
Folder.cleanup(self.app_name_no_platform)
45+
Folder.cleanup(self.app_name_no_platform + '/platforms/ios/build')
4746

4847
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name}, assert_success=False)
4948

@@ -57,7 +56,7 @@ def tearDownClass(cls):
5756
File.remove("TestApp.ipa")
5857

5958
Folder.cleanup(cls.app_name)
60-
Folder.cleanup(cls.app_name_noplatform)
59+
Folder.cleanup(cls.app_name_no_platform)
6160
Folder.cleanup(cls.app_name_dash)
6261
Folder.cleanup(cls.app_name_space)
6362

@@ -114,8 +113,8 @@ def test_200_build_ios_inside_project(self):
114113
assert File.exists(self.app_name + "/platforms/ios/build/emulator/TestApp.app")
115114

116115
def test_210_build_ios_platform_not_added_or_platforms_deleted(self):
117-
Tns.create_app(self.app_name_noplatform)
118-
Tns.build_ios(attributes={"--path": self.app_name_noplatform})
116+
Tns.create_app(self.app_name_no_platform)
117+
Tns.build_ios(attributes={"--path": self.app_name_no_platform})
119118

120119
def test_300_build_ios_with_dash(self):
121120
Tns.create_app(self.app_name_dash)
@@ -185,8 +184,8 @@ def test_320_build_ios_with_custom_entitlements(self):
185184
assert "doesn't include the aps-environment and inter-app-audio entitlements" in output
186185

187186
def test_400_build_ios_with_wrong_param(self):
188-
Tns.create_app(self.app_name_noplatform)
189-
output = Tns.build_ios(attributes={"--path": self.app_name_noplatform, "--" + invalid: ""},
187+
Tns.create_app(self.app_name_no_platform)
188+
output = Tns.build_ios(attributes={"--path": self.app_name_no_platform, "--" + invalid: ""},
190189
assert_success=False)
191190
assert invalid_option.format(invalid) in output
192191
assert error not in output.lower()

0 commit comments

Comments
 (0)