Skip to content

Commit 8c963c3

Browse files
committed
Fix android tests
1 parent 546ca4a commit 8c963c3

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

core/tns/tns.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,16 @@ def prepare_ios(attributes={}, assert_success=True, log_trace=False, tns_path=No
348348
return output
349349

350350
@staticmethod
351-
def build_android(attributes={}, assert_success=True, tns_path=None):
352-
output = Tns.run_tns_command("build android", attributes=attributes, tns_path=tns_path)
351+
def build_android(attributes={}, assert_success=True, tns_path=None, log_trace=False):
352+
output = Tns.run_tns_command("build android", attributes=attributes, tns_path=tns_path, log_trace=log_trace)
353353
if assert_success:
354354
# Verify output of build command
355-
assert "BUILD SUCCESSFUL" in output, "Build failed!" + os.linesep + output
356355
assert "Project successfully built" in output, "Build failed!" + os.linesep + output
357356
assert "NOT FOUND" not in output # Test for https://github.com/NativeScript/android-runtime/issues/390
357+
if log_trace:
358+
assert "BUILD SUCCESSFUL" in output, "Build failed!" + os.linesep + output
359+
else:
360+
assert "BUILD SUCCESSFUL" not in output, "Native build out is displayed even without --log trace"
358361

359362
# Verify apk packages
360363
app_name = Tns.__get_app_name_from_attributes(attributes=attributes)
@@ -397,6 +400,9 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
397400
if log_trace:
398401
assert "BUILD SUCCEEDED" in output
399402
assert "CodeSign" in output
403+
else:
404+
assert "BUILD SUCCEEDED" not in output, "Native build out is displayed even without --log trace"
405+
assert "CodeSign" not in output, "Native build out is displayed even without --log trace"
400406

401407
# Verify release/debug builds
402408
if "--release" in attributes.keys():
@@ -416,6 +422,9 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
416422
assert "build/device/" + app_id + ".app" in output
417423
assert "ARCHIVE SUCCEEDED" in output
418424
assert "EXPORT SUCCEEDED" in output
425+
else:
426+
assert "ARCHIVE SUCCEEDED" not in output, "Native build out is displayed even without --log trace"
427+
assert "EXPORT SUCCEEDED" not in output, "Native build out is displayed even without --log trace"
419428
assert File.exists(device_folder + app_id + ".ipa"), "IPA file not found!"
420429
bundle_content = File.read(device_folder + app_id + ".app/" + app_id)
421430
xcode_project = Tns.__get_xcode_project_file(app_name)
@@ -427,6 +436,9 @@ def build_ios(attributes={}, assert_success=True, tns_path=None, log_trace=False
427436
else:
428437
if log_trace:
429438
assert "build/emulator/" + app_id + ".app" in output
439+
else:
440+
assert "build/emulator/" + app_id + ".app" not in output, \
441+
"Native build out is displayed even without --log trace"
430442
assert File.exists(app_name + "/platforms/ios/" + app_id + "/" + app_id + "-Prefix.pch")
431443
assert File.exists(emu_folder + app_id + ".app")
432444
bundle_content = File.read(emu_folder + app_id + ".app/" + app_id)

tests/build/android/build_android_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ def test_002_build_android_release(self):
105105
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
106106
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
107107
"--release": ""
108-
})
108+
}, log_trace=True)
109109

110110
# Configs are respected
111111
assert 'release' in File.read(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json'))
112112

113113
def test_200_build_android_inside_project_folder(self):
114114
Folder.navigate_to(self.app_name)
115115
output = Tns.build_android(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name},
116-
assert_success=False)
116+
assert_success=False, log_trace=True)
117117
Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
118118
assert successfully_prepared in output
119119
assert build_successful in output
@@ -311,8 +311,8 @@ def test_390_build_project_with_foursquare_android_oauth(self):
311311
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_RUNTIME_PATH})
312312

313313
# Add foursquare native library as dependency
314-
source = os.path.join('data','issues','android-runtime-755','app.gradle')
315-
target = os.path.join(self.app_name, 'app','App_Resources','Android','app.gradle')
314+
source = os.path.join('data', 'issues', 'android-runtime-755', 'app.gradle')
315+
target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle')
316316
File.copy(src=source, dest=target)
317317

318318
# Build the project

tests/device/run_ios_device_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def test_330_tns_run_ios_after_rebuild_of_native_project(self):
232232

233233
# `tns run ios` and wait until app is deployed
234234
log = Tns.run_ios(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False,
235-
assert_success=False)
235+
assert_success=False, log_trace=True)
236236
strings = [self.DEVICE_ID, 'Successfully synced application']
237237
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)
238238

0 commit comments

Comments
 (0)