def test_200_build_android_ng_project_release(self): Tns.build_android( attributes={ "--keyStorePath": ANDROID_KEYSTORE_PATH, "--keyStorePassword": ANDROID_KEYSTORE_PASS, "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, "--release": "", "--path": self.app_name }) platform_folder = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "app", 'item') assert File.pattern_exists(platform_folder, '*.js'), "JS files not found!" assert not File.pattern_exists(platform_folder, '*.ts'), "TS files found!"
def test_001_build_ios(self): Tns.build_ios(attributes={"--path": self.app_name}, log_trace=True) Tns.build_ios(attributes={ "--path": self.app_name, "--release": "" }, log_trace=True) Tns.build_ios(attributes={ "--path": self.app_name, "--forDevice": "" }, log_trace=True) Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) Tns.build_ios(attributes={ "--path": self.app_name, "--forDevice": "", "--release": "" }, log_trace=True) # Verify no aar and frameworks in platforms folder assert not File.pattern_exists(self.app_name + "/platforms/ios", "*.aar") assert not File.pattern_exists( self.app_name + "/platforms/ios/TestApp/app/tns_modules", "*.framework") # Verify ipa has both armv7 and arm64 archs ipa_path = os.path.join(self.app_name, "platforms", "ios", "build", "Release-iphoneos", "TestApp.ipa") run("mv " + ipa_path + " TestApp-ipa.tgz") run("unzip -o TestApp-ipa.tgz") output = run("lipo -info Payload/TestApp.app/TestApp") Folder.cleanup("Payload") assert "Architectures in the fat file: Payload/TestApp.app/TestApp are: armv7 arm64" in output
def test_001_build_android(self): Tns.build_android(attributes={"--path": self.app_name}) assert File.pattern_exists(self.platforms_android, "*.aar") assert not File.pattern_exists(self.platforms_android, "*.plist") assert not File.pattern_exists(self.platforms_android, "*.android.js") assert not File.pattern_exists(self.platforms_android, "*.ios.js") # Configs are respected assert 'debug' in File.read(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json')) # And new platform specific file and verify next build is ok (test for issue #2697) src = os.path.join(self.app_name, 'app', 'app.js') dest_1 = os.path.join(self.app_name, 'app', 'new.android.js') dest_2 = os.path.join(self.app_name, 'app', 'new.ios.js') File.copy(src=src, dest=dest_1) File.copy(src=src, dest=dest_2) # Verify incremental native build before_build = datetime.datetime.now() output = Tns.build_android(attributes={"--path": self.app_name}) after_build = datetime.datetime.now() assert "Gradle build..." in output, "Gradle build not called." assert output.count("Gradle build...") is 1, "Only one gradle build is triggered." assert (after_build - before_build).total_seconds() < 20, "Incremental build takes more then 20 sec." # Verify platform specific files assert File.pattern_exists(self.platforms_android, "*.aar") assert not File.pattern_exists(self.platforms_android, "*.plist") assert not File.pattern_exists(self.platforms_android, "*.android.js") assert not File.pattern_exists(self.platforms_android, "*.ios.js") # Verify apk does not contain aar files archive = ZipFile(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk)) archive.extractall(self.app_name + "/temp") archive.close() # Ceanup META-INF folder. It contains com.android.support.... files which are expected to be there due to # https://github.com/NativeScript/nativescript-cli/pull/3923 Folder.cleanup(os.path.join(self.app_name, "temp", "META-INF")) assert not File.pattern_exists(self.app_name + "/temp", "*.aar") assert not File.pattern_exists(self.app_name + "/temp", "*.plist") assert not File.pattern_exists(self.app_name + "/temp", "*.android.*") assert not File.pattern_exists(self.app_name + "/temp", "*.ios.*") Folder.cleanup(self.app_name + "/temp") # Verify incremental native build before_build = datetime.datetime.now() output = Tns.build_android(attributes={"--path": self.app_name}) after_build = datetime.datetime.now() assert "Gradle build..." in output, "Gradle build not called." assert output.count("Gradle build...") is 1, "Only one gradle build is triggered." assert (after_build - before_build).total_seconds() < 20, "Incremental build takes more then 20 sec." # Verify clean build force native project rebuild before_build = datetime.datetime.now() output = Tns.build_android(attributes={"--path": self.app_name, "--clean": ""}) after_build = datetime.datetime.now() build_time = (after_build - before_build).total_seconds() assert "Gradle clean..." in output, "Gradle clean is not called." assert "Gradle build..." in output, "Gradle build is not called." assert output.count("Gradle build...") is 1, "More than 1 gradle build is triggered." assert build_time > 10, "Clean build takes less then 15 sec." assert build_time < 90, "Clean build takes more than 90 sec."
def test_001_build_android(self): Tns.build_android(attributes={"--path": self.app_name}) assert File.pattern_exists(self.platforms_android, "*.aar") assert not File.pattern_exists(self.platforms_android, "*.plist") assert not File.pattern_exists(self.platforms_android, "*.android.js") assert not File.pattern_exists(self.platforms_android, "*.ios.js") # Configs are respected assert 'debug' in File.read( os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json')) # And new platform specific file and verify next build is ok (test for issue #2697) src = os.path.join(self.app_name, 'app', 'app.js') dest_1 = os.path.join(self.app_name, 'app', 'new.android.js') dest_2 = os.path.join(self.app_name, 'app', 'new.ios.js') File.copy(src=src, dest=dest_1) File.copy(src=src, dest=dest_2) # Verify incremental native build before_build = datetime.datetime.now() output = Tns.build_android(attributes={"--path": self.app_name}) after_build = datetime.datetime.now() assert "Gradle build..." in output, "Gradle build not called." assert output.count( "Gradle build...") is 1, "Only one gradle build is triggered." assert (after_build - before_build).total_seconds( ) < 20, "Incremental build takes more then 20 sec." # Verify platform specific files assert File.pattern_exists(self.platforms_android, "*.aar") assert not File.pattern_exists(self.platforms_android, "*.plist") assert not File.pattern_exists(self.platforms_android, "*.android.js") assert not File.pattern_exists(self.platforms_android, "*.ios.js") # Verify apk does not contain aar files archive = ZipFile( os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk)) archive.extractall(self.app_name + "/temp") archive.close() # Ceanup META-INF folder. It contains com.android.support.... files which are expected to be there due to # https://github.com/NativeScript/nativescript-cli/pull/3923 Folder.cleanup(os.path.join(self.app_name, "temp", "META-INF")) assert not File.pattern_exists(self.app_name + "/temp", "*.aar") assert not File.pattern_exists(self.app_name + "/temp", "*.plist") assert not File.pattern_exists(self.app_name + "/temp", "*.android.*") assert not File.pattern_exists(self.app_name + "/temp", "*.ios.*") Folder.cleanup(self.app_name + "/temp") # Verify incremental native build before_build = datetime.datetime.now() output = Tns.build_android(attributes={"--path": self.app_name}) after_build = datetime.datetime.now() assert "Gradle build..." in output, "Gradle build not called." assert output.count( "Gradle build...") is 1, "Only one gradle build is triggered." assert (after_build - before_build).total_seconds( ) < 20, "Incremental build takes more then 20 sec." # Verify clean build force native project rebuild before_build = datetime.datetime.now() output = Tns.build_android(attributes={ "--path": self.app_name, "--clean": "" }) after_build = datetime.datetime.now() build_time = (after_build - before_build).total_seconds() assert "Gradle clean..." in output, "Gradle clean is not called." assert "Gradle build..." in output, "Gradle build is not called." assert output.count( "Gradle build...") is 1, "More than 1 gradle build is triggered." assert build_time > 10, "Clean build takes less then 15 sec." assert build_time < 90, "Clean build takes more than 90 sec."
def test_200_build_ios_ng_project_release_fordevice(self): Tns.build_ios(attributes={"--path": self.app_name, "--for-device": "", "--release": ""}) platform_folder = os.path.join(self.app_name, 'platforms', 'ios', self.app_name, 'app', 'app', 'item') assert File.pattern_exists(platform_folder, '*.js'), "JS files not found!" assert not File.pattern_exists(platform_folder, '*.ts'), "TS files found!"