Пример #1
0
    def create_result(self):
        '''
        Create a final JSON result file from the build and test information.
        '''
        result = {'bin': {}, 'date': {}, 'tests': {}, 'submodules': {}}

        labels = {
            'profiles/minimal-profile-build':
            'minimal-profile',
            'profiles/target-es5.1-profile-build':
            'target-es5_1-profile',
            'profiles/target-es2015subset-profile-build':
            'target-es2015subset-profile'
        }

        for job_id, build_path in self.results.iteritems():
            # Append the binary information.
            if 'test-build' in job_id:
                filename = utils.join(build_path, 'testresults.json')
                # Do not save the testresults if there is no available data.
                if not utils.exists(filename):
                    continue

                result.update(utils.read_json_file(filename))

            else:
                filename = utils.join(build_path, 'build.json')
                # Do not save build info if there is no available data.
                if not utils.exists(filename):
                    continue

                bin_data = utils.read_json_file(filename)
                # Translate job_id to database schema name.
                label = labels[job_id]

                result['bin'][label] = bin_data['bin']
                result['submodules'] = bin_data['submodules']
                result['date'] = bin_data['last-commit-date']

        filepath = utils.join(paths.RESULT_PATH, self.options.app,
                              self.options.device)
        filename = utils.join(filepath, utils.current_date() + '.json')
        # Save the content info a result file.
        utils.write_json_file(filename, result)

        console.log()
        console.log('The results are written into:', console.TERMINAL_BLUE)
        console.log('  {json_file}'.format(json_file=filename))
        console.log()

        return result
Пример #2
0
def load_testing_environment(options):
    '''
    Create a testing environment object that contains the
    module information and the user specified options.
    '''
    resources = utils.read_json_file(paths.RESOURCES_JSON)

    # Get the dependencies of the current device.
    deps = resources['targets'][options.device]
    # Update the deps list with user selected projects.
    deps.append(options.app)

    # Get the required module information.
    modules = {name: resources['modules'][name] for name in deps}

    # Update the path of the target application.
    if options.app_path:
        modules[options.app]['src'] = options.app_path
    # Add an 'app' named module that is just a reference
    # to the user defined target application.
    modules['app'] = modules[options.app]
    modules['app']['name'] = options.app

    # Create the testing environment object.
    environment = {
        'info': vars(options),
        'modules': modules,
        'paths': resources['paths']
    }

    _resolve_symbols(environment)

    return environment
Пример #3
0
    def save(self):
        '''
        Save the current testresults into JSON format.
        '''
        if self.env['info']['no_test']:
            return

        build_file = self.env['paths']['build-json']
        build_info = utils.read_json_file(build_file)

        # Add the build information.
        test_info = {
            'date': build_info['last-commit-date'],
            'bin': build_info['bin'],
            'submodules': build_info['submodules']
        }

        # Specify a date named results file.
        result_dir = self.env['paths']['result']
        filename = utils.join(result_dir, build_info['build-date'])

        if self.env['info']['coverage']:
            # Add the coverage information.
            test_info['coverage_info'] = self.coverage_info
            filename += '_coverage'
        else:
            # Add the test results.
            test_info['tests'] = self.results

        # Save the results into the date named file.
        utils.write_json_file(filename + '.json', test_info)

        # Publish the results if necessary.
        testrunner_utils.upload_data_to_firebase(self.env, test_info)
Пример #4
0
def read_testsets(env):
    '''
    Read all the tests into dictionary.
    '''
    testset = utils.join(env.modules.app.paths.tests, 'testsets.json')

    if utils.exists(testset):
        return utils.read_json_file(testset)

    return testrunner_utils.read_test_files(env)
Пример #5
0
    def _read_skiplist(self):
        '''
        Read the local skiplists.
        '''
        skiplists = {
            'iotjs': 'iotjs-skiplist.json',
            'jerryscript': 'jerryscript-skiplist.json'
        }

        skipfile = utils.join(paths.TESTRUNNER_PATH, skiplists[self.app])
        skiplist = utils.read_json_file(skipfile)

        return skiplist[self.device_type]
Пример #6
0
def create_testing_environment(user_options, job_options):
    '''
    Load the resource infromation that all modules define.
    '''
    resources = encode_as_objdict(utils.read_json_file(paths.RESOURCES_JSON))
    # Merge the two options.
    # Modify the user options with the options for the current job.
    options = namespace_as_dict(user_options)
    options.update(job_options)
    # Create an object from the dictionary.
    options = encode_as_objdict(options)

    # Get the dependencies of the current device.
    deps = resources.targets[options.device]
    # Update the deps list with user selected project.
    deps.insert(0, options.app)

    # Get the required module information. Drop all the
    # modules that are not required by the target.
    modules = encode_as_objdict(
        {name: resources.modules[name]
         for name in deps})

    # Update the path of the target application if custom
    # iotjs or jerryscript is used.
    if options.app_path:
        modules[options.app].src = options.app_path

    if options.testsuite:
        modules[options.app].paths.tests = options.testsuite

    # Add an 'app' named module that is just a reference
    # to the user defined target application.
    modules.app = modules[options.app]
    modules.app.name = options.app

    # Set the current build directory to the paths.
    resources.paths.builddir = utils.join(resources.paths.build, options.id)

    # Modify the no-build options according to the no-profile-build option.
    no_profile_build = options.no_profile_build and 'profile' in options.id
    options.no_build = options.no_build or no_profile_build

    environment = encode_as_objdict({
        'options': options,
        'modules': modules,
        'paths': resources.paths
    })

    # Resolve the symbolic values in the resources.json file.
    return encode_as_objdict(symbol_resolver.resolve(environment, environment))
Пример #7
0
    def _read_test_descriptor(self):
        '''
        Read the local skiplists.
        '''
        descriptors = {
            'iotjs': 'iotjs-test-descriptor.json',
            'jerryscript': 'jerryscript-test-descriptor.json'
        }

        descriptor_file = utils.join(paths.SKIPLIST_PATH,
                                     descriptors[self.app])
        descriptor_info = utils.read_json_file(descriptor_file)

        return descriptor_info[self.device_type]
Пример #8
0
def read_testsets(env):
    '''
    Read all the tests into dictionary.
    '''
    application = env['modules']['app']

    # Since JerryScript doesn't have testset descriptor file,
    # simply read the file contents from the test folder.
    if application['name'] == 'jerryscript':
        testsets = testrunner_utils.read_test_files(env)
    else:
        testsets = utils.read_json_file(application['paths']['testfiles'])

    return testsets