Skip to content

Commit a238efb

Browse files
authored
refactor: folder structure (#10)
* chore: migrate to new templates repo Templates are now in mono repo: https://github.com/NativeScript/nativescript-app-templates * feat: propose folder structure for tests * feat: add pylintrc * chore: add pylintrc * fix: double install of {N} CLI
1 parent 4c83249 commit a238efb

File tree

22 files changed

+743
-32
lines changed

22 files changed

+743
-32
lines changed

.pylintrc

Lines changed: 564 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ Once you are ready with our changes, please run flake8:
7575
python -m flake8 --max-line-length=120 core core_tests data products tests
7676
```
7777

78+
Notes:
79+
We plan to adopt `pylint`, but we are still in process of defining rules and fixing lint errors.
80+
```bash
81+
python -m pylint core data product --rcfile=c:\Git\nativescript-tooling-qa\.pylintrc
82+
```
83+
7884
## Hints, Tips and Tricks
7985

8086
Please see [Hints, Tips and Tricks](HINTS.md) document.

products/angular/ng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def serve(project=Settings.AppName.DEFAULT, prod=False):
106106
if prod:
107107
command = command + ' --prod'
108108
result = NG.exec_command(command=command, cwd=project_path, wait=False)
109-
compiled = Wait.until(lambda: 'Compiled successfully' in File.read(result.log_file), timeout=90)
109+
compiled = Wait.until(lambda: 'Compiled successfully' in File.read(result.log_file), timeout=180)
110110
if not compiled:
111111
Log.error('NG Serve failed to compile in 90 sec.')
112112
Log.error('Logs:{0}{1}'.format(os.linesep, File.read(result.log_file)))

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ numpy>=1.15.4
1010
opencv-python>=3.4.3.18
1111
pytesseract>=0.2.5
1212
flake8>=3.6.0
13+
pylint>=2.2.2
1314
selenium>=3.141.0
1415
webdriver_manager>=1.7

requirements_darwin.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ numpy>=1.15.4
1010
opencv-python>=3.4.3.18
1111
pytesseract>=0.2.5
1212
flake8>=3.6.0
13+
pylint>=2.2.2
1314
selenium>=3.141.0
1415
webdriver_manager>=1.7
1516
atomac>=1.1.0

run_common.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,11 @@ def __get_templates():
5656
raise IOError("Failed to clone and pack template: " + template_name)
5757

5858

59-
def __get_packages():
59+
def __get_runtimes():
6060
"""
61-
Get NativeScript CLI and runtimes in TEST_SUT_HOME.
61+
Get {N} Runtimes in TEST_SUT_HOME.
6262
"""
6363

64-
# Copy or install NativeScript CLI
65-
if '.tgz' in Settings.Packages.NS_CLI:
66-
cli_package = os.path.join(Settings.TEST_SUT_HOME, 'nativescript.tgz')
67-
File.copy(src=Settings.Packages.NS_CLI, target=cli_package)
68-
Settings.Packages.NS_CLI = cli_package
69-
else:
70-
Npm.install(package=Settings.Packages.NS_CLI, folder=Settings.TEST_RUN_HOME)
71-
7264
# Copy or download tns-android
7365
android_package = os.path.join(Settings.TEST_SUT_HOME, 'tns-android.tgz')
7466
if '.tgz' in Settings.Packages.ANDROID:
@@ -92,6 +84,13 @@ def __install_ns_cli():
9284
Install NativeScript CLI locally.
9385
"""
9486

87+
# Copy NativeScript CLI (if used from local package)
88+
if '.tgz' in Settings.Packages.NS_CLI:
89+
cli_package = os.path.join(Settings.TEST_SUT_HOME, 'nativescript.tgz')
90+
File.copy(src=Settings.Packages.NS_CLI, target=cli_package)
91+
Settings.Packages.NS_CLI = cli_package
92+
93+
# Install NativeScript CLI
9594
output = Npm.install(package=Settings.Packages.NS_CLI, folder=Settings.TEST_RUN_HOME)
9695

9796
# Verify executable exists after install
@@ -136,8 +135,8 @@ def __install_schematics():
136135
def prepare(clone_templates=True, install_ng_cli=False):
137136
Log.info('================== Prepare Test Run ==================')
138137
__cleanup()
139-
__get_packages()
140138
__install_ns_cli()
139+
__get_runtimes()
141140
if install_ng_cli:
142141
__install_ng_cli()
143142
__install_schematics()

tests/cli/build/build.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Tests to be writen
2+
3+
**platform add/remove/list/update**
4+
5+
**prepare**
6+
7+
**build**
8+
9+
**install**

tests/cli/create/create.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**create and init**
4+
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/project/creation

tests/cli/debug/debug.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**debug**
4+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/debug.md

tests/cli/build/common/doctor_tests.py renamed to tests/cli/misc/doctor_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
# noinspection PyMethodMayBeStatic
12-
class DoctorFunctionalTests(TnsTest):
12+
class DoctorTests(TnsTest):
1313
APP_NAME = Settings.AppName.DEFAULT
1414
ANDROID_HOME = os.environ.get('ANDROID_HOME')
1515
JAVA_HOME = os.environ.get('JAVA_HOME')

tests/cli/misc/misc.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Tests to be writen
2+
3+
**autocomplete**
4+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/autocomplete.md
5+
6+
**setup**
7+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/env-configuration/setup.md
8+
9+
**usage and error reporting**
10+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/error-reporting.md
11+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/usage-reporting.md
12+
13+
**tns appstore and publish**
14+
15+
**tns help**
16+
17+
**tns proxy**
18+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from core.base_test.tns_test import TnsTest
2+
from products.nativescript.tns import Tns
3+
4+
5+
# noinspection PyMethodMayBeStatic
6+
class PackageManagerTests(TnsTest):
7+
8+
@classmethod
9+
def setUpClass(cls):
10+
TnsTest.setUpClass()
11+
12+
def setUp(self):
13+
TnsTest.setUp(self)
14+
15+
def tearDown(self):
16+
TnsTest.tearDown(self)
17+
18+
@classmethod
19+
def tearDownClass(cls):
20+
TnsTest.tearDownClass()
21+
22+
def test_001_package_manager_get(self):
23+
result = Tns.exec_command(command='package-manager get')
24+
assert result.exit_code == 0, 'tns package-manager get exit with non zero exit code.'
25+
assert 'npm' in result.output, 'Default package manager is not npm.'
26+
27+
def test_400_package_manager_set_wrong_value(self):
28+
result = Tns.exec_command(command='package-manager set fake')
29+
assert result.exit_code != 0, 'tns package-manager should exit with non zero exit code on fails.'
30+
assert 'fake is not a valid package manager.' in result.output, 'Wrong package manager not detected.'
31+
assert 'Only yarn or npm are supported.' in result.output, 'No message for supported managers.'

tests/cli/plugin/plugin.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**plugin**
4+
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/lib-management

tests/cli/preview/preview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**preview**
4+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/preview.md

tests/cli/resources/resources.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**resources**
4+
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/project/configuration/resources

tests/cli/run/run.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Tests to be writen
2+
3+
**device**
4+
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/device
5+
6+
**deploy**
7+
8+
**run**

tests/cli/run/templates/hello_world_ng_tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def test_200_run_android_bundle(self):
6464
def test_300_run_android_bundle_aot(self):
6565
sync_hello_world_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, aot=True)
6666

67-
@unittest.skip('Ignore because of https://github.com/NativeScript/nativescript-angular/issues/1572')
6867
def test_310_run_android_bundle_uglify(self):
6968
sync_hello_world_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, uglify=True)
7069

@@ -83,7 +82,6 @@ def test_200_run_ios_bundle(self):
8382
def test_300_run_ios_bundle_aot(self):
8483
sync_hello_world_ng(self.app_name, Platform.IOS, self.sim, bundle=True, aot=True)
8584

86-
@unittest.skip('Ignore because of https://github.com/NativeScript/nativescript-angular/issues/1572')
8785
def test_310_run_ios_bundle_uglify(self):
8886
sync_hello_world_ng(self.app_name, Platform.IOS, self.sim, bundle=True, uglify=True)
8987

tests/cli/run/templates/master_detail_ng_tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def test_200_run_android_bundle(self):
6464
def test_300_run_android_bundle_aot(self):
6565
sync_master_detail_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, aot=True)
6666

67-
@unittest.skip('Ignore because of https://github.com/NativeScript/nativescript-angular/issues/1572')
6867
def test_310_run_android_bundle_uglify(self):
6968
sync_master_detail_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, uglify=True)
7069

@@ -83,7 +82,6 @@ def test_200_run_ios_bundle(self):
8382
def test_300_run_ios_bundle_aot(self):
8483
sync_master_detail_ng(self.app_name, Platform.IOS, self.sim, bundle=True, aot=True)
8584

86-
@unittest.skip('Ignore because of https://github.com/NativeScript/nativescript-angular/issues/1572')
8785
def test_310_run_ios_bundle_uglify(self):
8886
sync_master_detail_ng(self.app_name, Platform.IOS, self.sim, bundle=True, uglify=True)
8987

tests/cli/smoke/smoke_tests.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
from core.enums.os_type import OSType
66
from core.enums.platform_type import Platform
77
from core.settings import Settings
8-
from core.utils.ci.jenkins import Jenkins
98
from core.utils.device.device_manager import DeviceManager
109
from data.sync.hello_world_js import sync_hello_world_js
1110
from data.sync.hello_world_ng import sync_hello_world_ng
1211
from data.templates import Template
1312
from products.nativescript.tns import Tns
1413

1514

16-
class CLISmokeTests(TnsTest):
15+
class SmokeTests(TnsTest):
1716
js_app = Settings.AppName.DEFAULT + 'JS'
1817
js_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, js_app)
1918
js_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', js_app)
@@ -25,8 +24,6 @@ class CLISmokeTests(TnsTest):
2524
emu = None
2625
sim = None
2726

28-
is_pr = Jenkins.is_pr()
29-
3027
@classmethod
3128
def setUpClass(cls):
3229
TnsTest.setUpClass()
@@ -37,13 +34,13 @@ def setUpClass(cls):
3734
cls.sim = DeviceManager.Simulator.ensure_available(Settings.Simulators.DEFAULT)
3835

3936
# Create JS app and copy to temp data folder
40-
Tns.create(app_name=cls.js_app, template=Template.HELLO_WORLD_JS.local_package, update=cls.is_pr)
37+
Tns.create(app_name=cls.js_app, template=Template.HELLO_WORLD_JS.local_package, update=False)
4138
Tns.platform_add_android(app_name=cls.js_app, framework_path=Settings.Android.FRAMEWORK_PATH)
4239
if Settings.HOST_OS is OSType.OSX:
4340
Tns.platform_add_ios(app_name=cls.js_app, framework_path=Settings.IOS.FRAMEWORK_PATH)
4441

4542
# Create NG app and copy to temp data folder
46-
Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=cls.is_pr)
43+
Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=False)
4744
Tns.platform_add_android(app_name=cls.ng_app, framework_path=Settings.Android.FRAMEWORK_PATH)
4845
if Settings.HOST_OS is OSType.OSX:
4946
Tns.platform_add_ios(app_name=cls.ng_app, framework_path=Settings.IOS.FRAMEWORK_PATH)
@@ -68,12 +65,3 @@ def test_100_run_android_ng(self):
6865
@unittest.skipIf(Settings.HOST_OS is not OSType.OSX, 'iOS tests can be executed only on macOS.')
6966
def test_101_run_ios_ng(self):
7067
sync_hello_world_ng(app_name=self.ng_app, platform=Platform.IOS, device=self.sim, bundle=True)
71-
72-
@unittest.skipIf(is_pr, 'Skip on PR jobs.')
73-
def test_200_build_android_release(self):
74-
Tns.build_android(app_name=self.js_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True)
75-
76-
@unittest.skipIf(is_pr, 'Skip on PR jobs.')
77-
@unittest.skipIf(Settings.HOST_OS is not OSType.OSX, 'iOS tests can be executed only on macOS.')
78-
def test_200_build_ios_release(self):
79-
Tns.build_ios(app_name=self.js_app, for_device=True, release=True, bundle=True, aot=True, uglify=True)

tests/cli/test-description.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# NativeScript CLI Tests Folder Structure
2+
3+
### Smoke tests
4+
5+
`smoke` folder contains set smoke tests that are executed on PRs.
6+
7+
On commit in master we run:
8+
```bash
9+
python run_ns.py tests\cli --exclude="^test_[2-9]"
10+
```
11+
12+
### Tests for CLI Commands
13+
14+
### build
15+
16+
Tests for `tns platform add/list/remove/update` commands.
17+
18+
Tests for `tns prepare` and `tns build` commands.
19+
20+
Tests for `tns install` command.
21+
22+
### create
23+
24+
Tests for `tns create` and `tns init` commands.
25+
26+
### debug
27+
28+
Tests for `tns debug` command.
29+
30+
### misc
31+
32+
Tests for `tns appstore` command.
33+
34+
Tests fot `tns autocomplete`.
35+
36+
Tests for `tns doctor`.
37+
38+
Tests for `tns help <command>`.
39+
40+
Tests for `tns proxy`.
41+
42+
Tests for `tns setup`.
43+
44+
Tests for `usage-reporting` and `error-reporting` commands
45+
46+
### plugin
47+
Tests for `tns plugin` command.
48+
49+
### preview
50+
Tests for `tns preview` command.
51+
52+
### resources
53+
Tests for `resources update` command.
54+
55+
### run
56+
Tests for `tns run`, `tns deploy` and `tns device` commands.
57+
58+
### test
59+
Tests for `tns Tests init` and `tns test` commands.
60+
61+
### update
62+
Tests for `update` command.

tests/cli/test/test.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**test**
4+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/test.md

tests/cli/update/update.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tests to be writen
2+
3+
**update**
4+
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/update.md

0 commit comments

Comments
 (0)