Skip to content

Commit 0ce8615

Browse files
author
vhristov5555
committed
Merge remote-tracking branch 'origin/master'
2 parents 081b32c + 0982876 commit 0ce8615

16 files changed

+157
-194
lines changed

core/device/simulator.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
class Simulator(object):
1515
@staticmethod
1616
def __get_sim_location():
17-
output = run(command='xcrun --show-sdk-path', log_level=CommandLogLevel.SILENT).strip()
18-
xcode_location = ''
19-
for paths in output.split('/'):
20-
xcode_location = xcode_location + paths + '/'
21-
if "Xcode" in paths:
22-
break
23-
sim_location = xcode_location + 'Contents/Developer/Applications/Simulator.app'
17+
xcode_location = run(command='xcode-select -p', log_level=CommandLogLevel.SILENT).strip()
18+
sim_location = xcode_location + '/Applications/Simulator.app/Contents/MacOS/Simulator'
2419
print "Simulator Application: " + sim_location
2520
return sim_location
2621

core/tns/tns.py

Lines changed: 13 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,17 @@ 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+
if log_trace:
513+
assert '"-configuration" "Release"' in output
509514
else:
510-
assert "CONFIGURATION Debug" in output
515+
if Xcode.get_version() < 10:
516+
assert "CONFIGURATION Debug" in output
517+
else:
518+
if log_trace:
519+
assert '"-configuration" "Debug"' in output
511520

512521
# Verify simulator/device builds
513522
device_folder = app_name + "/platforms/ios/build/device/"
@@ -531,7 +540,7 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
531540
assert "build/emulator/" + app_id + ".app" in output
532541
else:
533542
# Xcode 8.* output contains some warnings for images, so we will assert only on Xcode 9.*
534-
if "9." in Xcode.get_version():
543+
if Xcode.get_version() >= 9:
535544
assert "CompileStoryboard" not in output, "Native build out is displayed!"
536545
assert "CompileAssetCatalog" not in output, "Native build out is displayed!"
537546
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])
Loading
Loading

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()

tests/device/debug_device_tests.py

Lines changed: 17 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
import os
22

33
from core.base_class.BaseClass import BaseClass
4-
from core.device.device import Device
54
from core.chrome.chrome import Chrome
6-
from core.osutils.file import File
5+
from core.device.device import Device
6+
from core.osutils.command import run
77
from core.settings.settings import ANDROID_PACKAGE, IOS_PACKAGE
88
from core.tns.tns import Tns
99
from core.tns.tns_platform_type import Platform
10-
from core.osutils.command import run
11-
from time import sleep
12-
from enum import Enum
13-
from core.osutils.process import Process
10+
from tests.helpers.debug_chrome import DebugChromeHelpers
1411

15-
class DebugMode(Enum):
16-
DEFAULT = 0
17-
START = 1
1812

19-
class DebugBothPlatformsTests(BaseClass):
20-
ANDROID_DEVICES = Device.get_ids(platform=Platform.ANDROID, include_emulators=True)
21-
IOS_DEVICES = Device.get_ids(platform=Platform.IOS)
22-
DEVICE_ID = Device.get_id(platform=Platform.ANDROID)
13+
class DebugOnDevice(BaseClass):
14+
ANDROID_DEVICE_ID = Device.get_id(platform=Platform.ANDROID)
15+
IOS_DEVICE_ID = Device.get_id(platform=Platform.IOS)
2316

2417
@classmethod
2518
def setUpClass(cls):
@@ -47,80 +40,19 @@ def tearDown(self):
4740
def tearDownClass(cls):
4841
BaseClass.tearDownClass()
4942

50-
@staticmethod
51-
def attach_chrome(log, mode=DebugMode.DEFAULT, port="41000"):
52-
"""
53-
Attach chrome dev tools and verify logs
54-
:type log: Log file of `tns debug ios` command.
55-
"""
56-
57-
# Check initial logs
58-
strings = ["Setting up debugger proxy...", "Press Ctrl + C to terminate, or disconnect.",
59-
"Opened localhost", "To start debugging, open the following URL in Chrome"]
60-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
61-
62-
# Attach Chrome DevTools
63-
url = run(command="grep chrome-devtools " + log)
64-
text_log = File.read(log)
65-
assert "chrome-devtools://devtools/remote" in text_log, "Debug url not printed in output of 'tns debug ios'."
66-
assert "localhost:" + port in text_log, "Wrong port of debug url:" + url
67-
Chrome.start(url)
68-
69-
# Verify debugger attached
70-
strings = ["Frontend client connected", "Backend socket created"]
71-
if mode != DebugMode.START:
72-
strings.extend(["Loading inspector modules",
73-
"Finished loading inspector modules",
74-
"NativeScript debugger attached"])
75-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
76-
77-
# Verify debugger not disconnected
78-
sleep(10)
79-
output = File.read(log)
80-
assert "socket closed" not in output, "Debugger disconnected."
81-
assert "detached" not in output, "Debugger disconnected."
82-
assert not Process.is_running('NativeScript Inspector'), "iOS Inspector running instead of ChromeDev Tools."
83-
84-
@staticmethod
85-
def assert_not_detached(log):
86-
output = File.read(log)
87-
assert "socket created" in output, "Debugger not attached at all.\n Log:\n" + output
88-
assert "socket closed" not in output, "Debugger disconnected.\n Log:\n" + output
89-
assert "detached" not in output, "Debugger disconnected.\n Log:\n" + output
90-
91-
def __verify_debugger_start(self, log):
92-
strings = ['NativeScript Debugger started', 'To start debugging, open the following URL in Chrome',
93-
'chrome-devtools', 'localhost:4000']
94-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
95-
output = File.read(file_path=log, print_content=True)
96-
assert "closed" not in output
97-
assert "detached" not in output
98-
assert "did not start in time" not in output
99-
100-
def __verify_debugger_attach(self, log):
101-
strings = ['To start debugging', 'Chrome', 'chrome-devtools', 'localhost:4000']
102-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
103-
output = File.read(file_path=log, print_content=True)
104-
assert "closed" not in output
105-
assert "detached" not in output
106-
assert "did not start in time" not in output
107-
assert "NativeScript Debugger started" not in output
108-
109-
def test_001_tns_run_android(self):
110-
log = Tns.debug_android(attributes={'--path': self.app_name})
111-
strings = ['Successfully installed on device with identifier']
112-
for android_device_id in self.ANDROID_DEVICES:
113-
strings.append(android_device_id)
114-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
115-
self.__verify_debugger_start(log)
43+
def test_001_debug_android(self):
44+
log = Tns.debug_android(attributes={'--path': self.app_name, '--device': self.ANDROID_DEVICE_ID})
45+
strings = [self.ANDROID_DEVICE_ID, 'Successfully installed on device with identifier']
46+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=240, check_interval=10, clean_log=False)
47+
DebugChromeHelpers.verify_debugger_started(log)
11648

11749
# Get Chrome URL and open it
11850
url = run(command="grep chrome-devtools " + log)
11951
Chrome.start(url)
12052

121-
def test_002_tns_run_ios(self):
122-
log = Tns.debug_ios(attributes={'--path': self.app_name})
123-
self.attach_chrome(log)
124-
strings = ['Successfully started on device with identifier']
125-
Tns.wait_for_log(log_file=log, string_list= strings, clean_log=False)
126-
self.assert_not_detached(log)
53+
def test_002_debug_ios(self):
54+
log = Tns.debug_ios(attributes={'--path': self.app_name, '--device': self.IOS_DEVICE_ID})
55+
DebugChromeHelpers.attach_chrome(log)
56+
strings = [self.IOS_DEVICE_ID, 'Successfully started on device with identifier']
57+
Tns.wait_for_log(log_file=log, string_list=strings, clean_log=False)
58+
DebugChromeHelpers.assert_not_detached(log)

tests/emulator/debug_android_tests.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Tests for `tns debug android` executed on Android Emulator.
33
"""
44
import os
5-
import unittest
65

76
from core.base_class.BaseClass import BaseClass
87
from core.chrome.chrome import Chrome
@@ -14,6 +13,7 @@
1413
from core.settings.settings import EMULATOR_NAME, EMULATOR_ID, ANDROID_PACKAGE
1514
from core.tns.tns import Tns
1615
from core.tns.tns_platform_type import Platform
16+
from tests.helpers.debug_chrome import DebugChromeHelpers
1717

1818

1919
class DebugAndroidEmulatorTests(BaseClass):
@@ -45,30 +45,12 @@ def tearDownClass(cls):
4545
BaseClass.tearDownClass()
4646
Emulator.stop()
4747

48-
def __verify_debugger_start(self, log):
49-
strings = [EMULATOR_ID, 'NativeScript Debugger started', 'To start debugging, open the following URL in Chrome',
50-
'chrome-devtools', 'localhost:4000']
51-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
52-
output = File.read(file_path=log, print_content=True)
53-
assert "closed" not in output
54-
assert "detached" not in output
55-
assert "did not start in time" not in output
56-
57-
def __verify_debugger_attach(self, log):
58-
strings = [EMULATOR_ID, 'To start debugging', 'Chrome', 'chrome-devtools', 'localhost:4000']
59-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
60-
output = File.read(file_path=log, print_content=True)
61-
assert "closed" not in output
62-
assert "detached" not in output
63-
assert "did not start in time" not in output
64-
assert "NativeScript Debugger started" not in output
65-
6648
def test_001_debug_android(self):
6749
"""
6850
Default `tns debug android` starts debugger (do not stop at the first code statement)
6951
"""
7052
log = Tns.debug_android(attributes={'--path': self.app_name, '--emulator': ''})
71-
self.__verify_debugger_start(log)
53+
DebugChromeHelpers.verify_debugger_started(log)
7254

7355
# Verify app starts and do not stop on first line of code
7456
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
@@ -80,7 +62,7 @@ def test_002_debug_android_emulator_debug_brk(self):
8062
"""
8163

8264
log = Tns.debug_android(attributes={'--path': self.app_name, '--debug-brk': '', '--emulator': ''})
83-
self.__verify_debugger_start(log)
65+
DebugChromeHelpers.verify_debugger_started(log)
8466

8567
# Verify app starts and do not stop on first line of code
8668
Device.screen_match(device_name=EMULATOR_NAME, tolerance=3.0, device_id=EMULATOR_ID,
@@ -99,7 +81,7 @@ def test_003_debug_android_emulator_start(self):
9981

10082
# Attach debugger
10183
log = Tns.debug_android(attributes={'--path': self.app_name, '--start': '', '--emulator': ''})
102-
self.__verify_debugger_attach(log=log)
84+
DebugChromeHelpers.verify_debugger_attach(log=log)
10385

10486
def test_100_debug_android_should_start_emulator_if_there_is_no_device(self):
10587
"""
@@ -127,7 +109,7 @@ def test_200_debug_android_with_response_from_server(self):
127109

128110
Tns.build_android(attributes={'--path': self.app_name})
129111
log = Tns.debug_android(attributes={'--path': self.app_name, '--emulator': ''})
130-
self.__verify_debugger_start(log)
112+
DebugChromeHelpers.verify_debugger_started(log)
131113

132114
# Verify app is running
133115
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,

tests/helpers/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)