Skip to content

refactor: folder structure #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
564 changes: 564 additions & 0 deletions .pylintrc

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Once you are ready with our changes, please run flake8:
python -m flake8 --max-line-length=120 core core_tests data products tests
```

Notes:
We plan to adopt `pylint`, but we are still in process of defining rules and fixing lint errors.
```bash
python -m pylint core data product --rcfile=c:\Git\nativescript-tooling-qa\.pylintrc
```

## Hints, Tips and Tricks

Please see [Hints, Tips and Tricks](HINTS.md) document.
2 changes: 1 addition & 1 deletion products/angular/ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def serve(project=Settings.AppName.DEFAULT, prod=False):
if prod:
command = command + ' --prod'
result = NG.exec_command(command=command, cwd=project_path, wait=False)
compiled = Wait.until(lambda: 'Compiled successfully' in File.read(result.log_file), timeout=90)
compiled = Wait.until(lambda: 'Compiled successfully' in File.read(result.log_file), timeout=180)
if not compiled:
Log.error('NG Serve failed to compile in 90 sec.')
Log.error('Logs:{0}{1}'.format(os.linesep, File.read(result.log_file)))
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ numpy>=1.15.4
opencv-python>=3.4.3.18
pytesseract>=0.2.5
flake8>=3.6.0
pylint>=2.2.2
selenium>=3.141.0
webdriver_manager>=1.7
1 change: 1 addition & 0 deletions requirements_darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ numpy>=1.15.4
opencv-python>=3.4.3.18
pytesseract>=0.2.5
flake8>=3.6.0
pylint>=2.2.2
selenium>=3.141.0
webdriver_manager>=1.7
atomac>=1.1.0
Expand Down
21 changes: 10 additions & 11 deletions run_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,11 @@ def __get_templates():
raise IOError("Failed to clone and pack template: " + template_name)


def __get_packages():
def __get_runtimes():
"""
Get NativeScript CLI and runtimes in TEST_SUT_HOME.
Get {N} Runtimes in TEST_SUT_HOME.
"""

# Copy or install NativeScript CLI
if '.tgz' in Settings.Packages.NS_CLI:
cli_package = os.path.join(Settings.TEST_SUT_HOME, 'nativescript.tgz')
File.copy(src=Settings.Packages.NS_CLI, target=cli_package)
Settings.Packages.NS_CLI = cli_package
else:
Npm.install(package=Settings.Packages.NS_CLI, folder=Settings.TEST_RUN_HOME)

# Copy or download tns-android
android_package = os.path.join(Settings.TEST_SUT_HOME, 'tns-android.tgz')
if '.tgz' in Settings.Packages.ANDROID:
Expand All @@ -92,6 +84,13 @@ def __install_ns_cli():
Install NativeScript CLI locally.
"""

# Copy NativeScript CLI (if used from local package)
if '.tgz' in Settings.Packages.NS_CLI:
cli_package = os.path.join(Settings.TEST_SUT_HOME, 'nativescript.tgz')
File.copy(src=Settings.Packages.NS_CLI, target=cli_package)
Settings.Packages.NS_CLI = cli_package

# Install NativeScript CLI
output = Npm.install(package=Settings.Packages.NS_CLI, folder=Settings.TEST_RUN_HOME)

# Verify executable exists after install
Expand Down Expand Up @@ -136,8 +135,8 @@ def __install_schematics():
def prepare(clone_templates=True, install_ng_cli=False):
Log.info('================== Prepare Test Run ==================')
__cleanup()
__get_packages()
__install_ns_cli()
__get_runtimes()
if install_ng_cli:
__install_ng_cli()
__install_schematics()
Expand Down
9 changes: 9 additions & 0 deletions tests/cli/build/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Tests to be writen

**platform add/remove/list/update**

**prepare**

**build**

**install**
4 changes: 4 additions & 0 deletions tests/cli/create/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**create and init**
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/project/creation
4 changes: 4 additions & 0 deletions tests/cli/debug/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**debug**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


# noinspection PyMethodMayBeStatic
class DoctorFunctionalTests(TnsTest):
class DoctorTests(TnsTest):
APP_NAME = Settings.AppName.DEFAULT
ANDROID_HOME = os.environ.get('ANDROID_HOME')
JAVA_HOME = os.environ.get('JAVA_HOME')
Expand Down
18 changes: 18 additions & 0 deletions tests/cli/misc/misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Tests to be writen

**autocomplete**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/autocomplete.md

**setup**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/env-configuration/setup.md

**usage and error reporting**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/error-reporting.md
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/usage-reporting.md

**tns appstore and publish**

**tns help**

**tns proxy**

31 changes: 31 additions & 0 deletions tests/cli/misc/pacakge_manager_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from core.base_test.tns_test import TnsTest
from products.nativescript.tns import Tns


# noinspection PyMethodMayBeStatic
class PackageManagerTests(TnsTest):

@classmethod
def setUpClass(cls):
TnsTest.setUpClass()

def setUp(self):
TnsTest.setUp(self)

def tearDown(self):
TnsTest.tearDown(self)

@classmethod
def tearDownClass(cls):
TnsTest.tearDownClass()

def test_001_package_manager_get(self):
result = Tns.exec_command(command='package-manager get')
assert result.exit_code == 0, 'tns package-manager get exit with non zero exit code.'
assert 'npm' in result.output, 'Default package manager is not npm.'

def test_400_package_manager_set_wrong_value(self):
result = Tns.exec_command(command='package-manager set fake')
assert result.exit_code != 0, 'tns package-manager should exit with non zero exit code on fails.'
assert 'fake is not a valid package manager.' in result.output, 'Wrong package manager not detected.'
assert 'Only yarn or npm are supported.' in result.output, 'No message for supported managers.'
4 changes: 4 additions & 0 deletions tests/cli/plugin/plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**plugin**
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/lib-management
4 changes: 4 additions & 0 deletions tests/cli/preview/preview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**preview**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/preview.md
4 changes: 4 additions & 0 deletions tests/cli/resources/resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**resources**
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/project/configuration/resources
8 changes: 8 additions & 0 deletions tests/cli/run/run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tests to be writen

**device**
https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages/device

**deploy**

**run**
2 changes: 0 additions & 2 deletions tests/cli/run/templates/hello_world_ng_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def test_200_run_android_bundle(self):
def test_300_run_android_bundle_aot(self):
sync_hello_world_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, aot=True)

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions tests/cli/run/templates/master_detail_ng_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def test_200_run_android_bundle(self):
def test_300_run_android_bundle_aot(self):
sync_master_detail_ng(self.app_name, Platform.ANDROID, self.emu, bundle=True, aot=True)

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

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

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

Expand Down
18 changes: 3 additions & 15 deletions tests/cli/smoke/smoke_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
from core.enums.os_type import OSType
from core.enums.platform_type import Platform
from core.settings import Settings
from core.utils.ci.jenkins import Jenkins
from core.utils.device.device_manager import DeviceManager
from data.sync.hello_world_js import sync_hello_world_js
from data.sync.hello_world_ng import sync_hello_world_ng
from data.templates import Template
from products.nativescript.tns import Tns


class CLISmokeTests(TnsTest):
class SmokeTests(TnsTest):
js_app = Settings.AppName.DEFAULT + 'JS'
js_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, js_app)
js_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', js_app)
Expand All @@ -25,8 +24,6 @@ class CLISmokeTests(TnsTest):
emu = None
sim = None

is_pr = Jenkins.is_pr()

@classmethod
def setUpClass(cls):
TnsTest.setUpClass()
Expand All @@ -37,13 +34,13 @@ def setUpClass(cls):
cls.sim = DeviceManager.Simulator.ensure_available(Settings.Simulators.DEFAULT)

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

# Create NG app and copy to temp data folder
Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=cls.is_pr)
Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=False)
Tns.platform_add_android(app_name=cls.ng_app, framework_path=Settings.Android.FRAMEWORK_PATH)
if Settings.HOST_OS is OSType.OSX:
Tns.platform_add_ios(app_name=cls.ng_app, framework_path=Settings.IOS.FRAMEWORK_PATH)
Expand All @@ -68,12 +65,3 @@ def test_100_run_android_ng(self):
@unittest.skipIf(Settings.HOST_OS is not OSType.OSX, 'iOS tests can be executed only on macOS.')
def test_101_run_ios_ng(self):
sync_hello_world_ng(app_name=self.ng_app, platform=Platform.IOS, device=self.sim, bundle=True)

@unittest.skipIf(is_pr, 'Skip on PR jobs.')
def test_200_build_android_release(self):
Tns.build_android(app_name=self.js_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True)

@unittest.skipIf(is_pr, 'Skip on PR jobs.')
@unittest.skipIf(Settings.HOST_OS is not OSType.OSX, 'iOS tests can be executed only on macOS.')
def test_200_build_ios_release(self):
Tns.build_ios(app_name=self.js_app, for_device=True, release=True, bundle=True, aot=True, uglify=True)
62 changes: 62 additions & 0 deletions tests/cli/test-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# NativeScript CLI Tests Folder Structure

### Smoke tests

`smoke` folder contains set smoke tests that are executed on PRs.

On commit in master we run:
```bash
python run_ns.py tests\cli --exclude="^test_[2-9]"
```

### Tests for CLI Commands

### build

Tests for `tns platform add/list/remove/update` commands.

Tests for `tns prepare` and `tns build` commands.

Tests for `tns install` command.

### create

Tests for `tns create` and `tns init` commands.

### debug

Tests for `tns debug` command.

### misc

Tests for `tns appstore` command.

Tests fot `tns autocomplete`.

Tests for `tns doctor`.

Tests for `tns help <command>`.

Tests for `tns proxy`.

Tests for `tns setup`.

Tests for `usage-reporting` and `error-reporting` commands

### plugin
Tests for `tns plugin` command.

### preview
Tests for `tns preview` command.

### resources
Tests for `resources update` command.

### run
Tests for `tns run`, `tns deploy` and `tns device` commands.

### test
Tests for `tns Tests init` and `tns test` commands.

### update
Tests for `update` command.
4 changes: 4 additions & 0 deletions tests/cli/test/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**test**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/project/testing/test.md
4 changes: 4 additions & 0 deletions tests/cli/update/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Tests to be writen

**update**
https://github.com/NativeScript/nativescript-cli/blob/master/docs/man_pages/general/update.md