-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrunNose.py
123 lines (100 loc) · 4.43 KB
/
runNose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import os
import shutil
import sys
import nose
from core.device.device import Device
from core.device.emulator import Emulator
from core.device.simulator import Simulator
from core.git.git import Git
from core.gradle.gradle import Gradle
from core.installer.cli import Cli
from core.npm.npm import Npm
from core.osutils.command import run
from core.osutils.folder import Folder
from core.settings.settings import OUTPUT_FOLDER, CURRENT_OS, OSType, \
ANDROID_PATH, IOS_PATH, SUT_FOLDER, CLI_PATH, IOS_INSPECTOR_PATH, SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK, \
TEST_RUN_HOME
from core.tns.tns import Tns
from core.tns.tns_platform_type import Platform
from core.xcode.xcode import Xcode
reload(sys)
sys.setdefaultencoding('UTF8')
def disable_crash_report():
if CURRENT_OS == OSType.OSX:
run("defaults write com.apple.CrashReporter DialogType none")
run("defaults write -g ApplePersistence -bool no")
def get_test_packages(platform=Platform.BOTH):
"""Copy {N} CLI form CLI_PATH to local folder"""
shutil.copy2(CLI_PATH.strip(), SUT_FOLDER)
shutil.copy2(ANDROID_PATH.strip(), SUT_FOLDER)
if platform is Platform.BOTH or platform is Platform.IOS:
shutil.copy2(IOS_PATH.strip(), SUT_FOLDER)
shutil.copy2(IOS_INSPECTOR_PATH.strip(), SUT_FOLDER)
def get_repos():
"""
Clone template-hello-world repositories
"""
Git.clone_repo(repo_url='git@github.com:NativeScript/template-hello-world.git',
local_folder=os.path.join(SUT_FOLDER, 'template-hello-world'))
Git.clone_repo(repo_url='git@github.com:NativeScript/template-hello-world-ts.git',
local_folder=os.path.join(SUT_FOLDER, 'template-hello-world-ts'))
# `nativescript-angular` do not longer use release branch
Git.clone_repo(repo_url='git@github.com:NativeScript/template-hello-world-ng.git',
local_folder=os.path.join(SUT_FOLDER, 'template-hello-world-ng'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world.tgz'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world-ts'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world-ts.tgz'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world-ng'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world-ng.tgz'))
if __name__ == '__main__':
# Cleanup files and folders created by the test execution
Folder.cleanup(OUTPUT_FOLDER)
Folder.create(OUTPUT_FOLDER)
Folder.cleanup(SUT_FOLDER)
Folder.cleanup("node_modules")
Npm.cache_clean()
Gradle.kill()
Gradle.cache_clean()
get_repos()
Emulator.stop() # Stop running emulators
# Copy test packages and cleanup
if CURRENT_OS == OSType.OSX:
Simulator.stop()
disable_crash_report()
get_test_packages(platform=Platform.BOTH)
Simulator.reset()
if Xcode.get_version() < 10:
SIMULATOR_SDK = '11.0'
if Xcode.get_version() < 9:
SIMULATOR_SDK = '10.0'
Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK)
Xcode.cleanup_cache() # Clean Xcode cache folders
Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS)
else:
get_test_packages(platform=Platform.ANDROID)
# Install CLI
Cli.install()
Tns.disable_reporting()
# Add local CLI to PATH
if CURRENT_OS != OSType.WINDOWS:
base_path = os.path.join(TEST_RUN_HOME, 'node_modules', 'nativescript', 'bin')
where_command = 'which tns'
else:
base_path = os.path.join(TEST_RUN_HOME, 'node_modules', '.bin')
where_command = 'where tns'
path = base_path + os.pathsep + os.environ['PATH']
os.environ['PATH'] = path
assert 'not found' not in run(command='tns --version'), 'Tns global installation not found!'
assert base_path in run(command=where_command), 'Global installation is not the local one!'
# Run Tests
arguments = ['nosetests', '-v', '-s', '--nologcapture', '--with-doctest', '--with-xunit', '--with-flaky']
for i in sys.argv:
arguments.append(str(i))
nose.run(argv=arguments)
# Cleanup and reset after test run is complete
if CURRENT_OS == OSType.OSX:
Simulator.reset()
Gradle.kill()
Gradle.cache_clean()