Exemplo n.º 1
0
    def prepare_and_build(template, platform, change_set, result_file):
        prepare_initial = 0
        build_initial = 0
        build_incremental = 0
        for _ in range(RETRY_COUNT):
            Tns.kill()
            Gradle.kill()
            Npm.cache_clean()
            Xcode.cache_clean()
            Folder.clean(folder=os.path.join(Settings.TEST_RUN_HOME, APP_NAME))
            Tns.create(app_name=APP_NAME, template=template, update=True)
            if platform == Platform.ANDROID:
                Tns.platform_add_android(
                    app_name=APP_NAME,
                    framework_path=Settings.Android.FRAMEWORK_PATH)
            elif platform == Platform.IOS:
                Tns.platform_add_ios(
                    app_name=APP_NAME,
                    framework_path=Settings.IOS.FRAMEWORK_PATH)
            else:
                raise Exception('Unknown platform: ' + str(platform))

            # Prepare
            time = Tns.prepare(app_name=APP_NAME,
                               platform=platform,
                               bundle=True).duration
            prepare_initial = prepare_initial + time

            # Build
            time = Tns.build(app_name=APP_NAME, platform=platform,
                             bundle=True).duration
            build_initial = build_initial + time
            Sync.replace(app_name=APP_NAME, change_set=change_set)
            time = Tns.build(app_name=APP_NAME, platform=platform,
                             bundle=True).duration
            build_incremental = build_incremental + time

        # Calculate averages
        result = PrepareBuildInfo()
        result.prepare_initial = prepare_initial / RETRY_COUNT
        result.build_initial = build_initial / RETRY_COUNT
        result.build_incremental = build_incremental / RETRY_COUNT

        # Save to results file
        File.delete(path=result_file)
        result_json = json.dumps(result,
                                 default=lambda o: o.__dict__,
                                 sort_keys=True,
                                 indent=4)
        File.write(path=result_file, text=str(result_json))
Exemplo n.º 2
0
 def setUp(self):
     TnsTest.setUp(self)
     Npm.cache_clean()