Transforms the test in a serializable version of it and sends it to a queue for further analysis

        :param test: the test to save
436156
def addSuccess(self, test: unittest.case.TestCase) -> None:
        
        # noinspection PyTypeChecker
        self.add_result(TestState.success, test)
320591
def run(self, test):
        ""
        # These parts of Nose's pluggability are baked into
        # nose.core.TextTestRunner. Reproduce them:
        wrapper = self.config.plugins.prepareTest(test)
        if wrapper is not None:
            test = wrapper
        wrapped = self.config.plugins.setOutputStream(self.stream)
        if wrapped is not None:
            self.stream = wrapped

        result = self._makeResult()
        startTime = time()
        try:
            test(result)
        except KeyboardInterrupt:
            # we need to ignore these exception to not
            # show traceback when user intentionally
            # interrupted test suite execution, and
            # to output some reasonable results on
            # already passed and failed tests.
            pass
        stopTime = time()

        # We don't care to hear about errors again at the end; we take care of
        # that in result.addError(), while the tests run.
        # result.printErrors()
        #
        # However, we do need to call this one useful line from
        # nose.result.TextTestResult's implementation of printErrors() to make
        # sure other plugins get a chance to report:
        self.config.plugins.report(self.stream)

        result.printSummary(startTime, stopTime)
        self.config.plugins.finalize(result)
        return result
941495
def finalize(self):
        
        #Determine the percentage success on the unit tests. Also see the total time for all
        #the unit tests.
        stotal = 0
        ttotal = 0
        for test in self.repo.testing.tests:
            stotal += (1 if test["success"]==True else 0)
            ttotal += (test["end"] - test["start"]).seconds

        self.percent = stotal/float(len(self.repo.testing.tests))
        self.message = "Results: {0:.2%} in {1:d}s.".format(self.percent, ttotal)
        if not self.testmode:
            if percent < 1:
                self.commit.create_status("failure", self.url, self.message)
            elif any([test["code"] == 1 for test in self.repo.testing.tests]):
                self.commit.create_status("pending", self.url, self.message + " Slowdown reported.")
            else:
                self.commit.create_status("success", self.url, self.message)
        self.server.wiki.update(self)
148467
function (test) {
    var ret = []
    for (var n = 0; n < batchTest.length; n++) {
      if (batchTest[n] === test) continue
      ret.push(batchTest[n])
    }
    batchTest = ret
  }
999007
def cmp_out(test)
      test.out_result = FileUtils.cmp(test.expected_out_path, 
                                      test.result_out_path)
    end
1170952
def _copy_flaky_attributes(cls, test, test_class):
        
        test_callable = cls._get_test_callable(test)
        if test_callable is None:
            return
        for attr, value in cls._get_flaky_attributes(test_class).items():
            already_set = hasattr(test, attr)
            if already_set:
                continue
            attr_on_callable = getattr(test_callable, attr, None)
            if attr_on_callable is not None:
                cls._set_flaky_attribute(test, attr, attr_on_callable)
            elif value is not None:
                cls._set_flaky_attribute(test, attr, value)
29193
def change_jira_status(test_key, test_status, test_comment, test_attachments):
    
    logger = logging.getLogger(__name__)

    if not execution_url:
        logger.warning("Test Case '%s' can not be updated: execution_url is not configured", test_key)
        return

    logger.info("Updating Test Case '%s' in Jira with status %s", test_key, test_status)
    composed_comments = comments
    if test_comment:
        composed_comments = '{}\n{}'.format(comments, test_comment) if comments else test_comment
    payload = {'jiraTestCaseId': test_key, 'jiraStatus': test_status, 'summaryPrefix': summary_prefix,
               'labels': labels, 'comments': composed_comments, 'version': fix_version, 'build': build}
    if only_if_changes:
        payload['onlyIfStatusChanges'] = 'true'
    try:
        if test_attachments and len(test_attachments) > 0:
            files = dict()
            for index in range(len(test_attachments)):
                files['attachments{}'.format(index)] = open(test_attachments[index], 'rb')
        else:
            files = None
        response = requests.post(execution_url, data=payload, files=files)
    except Exception as e:
        logger.warning("Error updating Test Case '%s': %s", test_key, e)
        return

    if response.status_code >= 400:
        logger.warning("Error updating Test Case '%s': [%s] %s", test_key, response.status_code,
                       get_error_message(response.content))
    else:
        logger.debug("%s", response.content.decode().splitlines()[0])
563866
function (test) {
        if (test.iteration >= test.cfg.repeat) {
            return completeTest(test);
        }
        test.iteration += 1;

        test.cfg.action.call(null, test.name, test.iteration - 1, generateTestCallback(test, this));
    }
126621
def dump_json(testcase, json_file):
    
    logging.info("dump testcase to JSON format.")

    with io.open(json_file, 'w', encoding="utf-8") as outfile:
        my_json_str = json.dumps(testcase, ensure_ascii=ensure_ascii, indent=4)
        if isinstance(my_json_str, bytes):
            my_json_str = my_json_str.decode("utf-8")

        outfile.write(my_json_str)

    logging.info("Generate JSON testcase successfully: {}".format(json_file))
877142
def _save(self):
        
        collection = JSONClientValidated('assessment',
                                         collection='AssessmentSection',
                                         runtime=self._runtime)
        if '_id' in self._my_map:  # This is the first time:
            collection.save(self._my_map)
        else:
            insert_result = collection.insert_one(self._my_map)
            self._my_map = collection.find_one({'_id': insert_result.inserted_id})
1301607
def transform(testtype):
    '''
    
    '''
    # XXX: Evaluate which of these transformations are still valid
    if testtype.startswith('[funsize'):
        return None

    testtype = testtype.split('/opt-')[-1]
    testtype = testtype.split('/debug-')[-1]

    # this is plain-reftests for android
    testtype = testtype.replace('plain-', '')

    testtype = testtype.strip()

    # https://bugzilla.mozilla.org/show_bug.cgi?id=1313844
    testtype = testtype.replace('browser-chrome-e10s', 'e10s-browser-chrome')
    testtype = testtype.replace('devtools-chrome-e10s', 'e10s-devtools-chrome')
    testtype = testtype.replace('[TC] Android 4.3 API15+ ', '')

    # mochitest-gl-1 <-- Android 4.3 armv7 API 15+ mozilla-inbound opt test mochitest-gl-1
    # mochitest-webgl-9  <-- test-android-4.3-arm7-api-15/opt-mochitest-webgl-9
    testtype = testtype.replace('webgl-', 'gl-')

    return testtype
288416
def addError(self, test, err):
        
        super().addError(test, err)
        self.test_info(test)
        self._call_test_results('addError', test, err)
982796
def serialize(cls, obj, buf, lineLength, validate=True):
        

        cls.generateImplicitParameters(obj)
        if validate:
            cls.validate(obj, raiseException=True)

        if obj.isNative:
            transformed = obj.transformFromNative()
            undoTransform = True
        else:
            transformed = obj
            undoTransform = False

        out = base.defaultSerialize(transformed, buf, lineLength)
        if undoTransform:
            obj.transformToNative()
        return out
1153951
function (test) {
        test.iteration = 0;

        removeSelector(test.selector, test.cfg.incremental);
        log(test);

        test.start = +(new Date());
        executeAction(test);
    }
426365
function() {
      while (JSLitmus._queue.length) {
        var test = JSLitmus._queue.shift();
        JSLitmus.renderTest(test);
      }
    }
1174434
def prepare_renderable(request, test_case_result, is_admin):
    """"""
    test_case = test_case_result.test_case
    file_directory = request.registry.settings['file_directory']
    sha1 = test_case_result.diff.sha1 if test_case_result.diff else None
    kwargs = {'number': test_case.id, 'group': test_case.testable.name,
              'name': test_case.name, 'points': test_case.points,
              'status': test_case_result.status,
              'extra': test_case_result.extra}

    if test_case.output_type == 'image':
        url = request.route_path('file_item', filename='_', _query={'raw': 1},
                                 sha1sum=sha1) if sha1 else None
        return ImageOutput(url=url, **kwargs)
    elif test_case.output_type == 'text':
        content = None
        if sha1:
            with open(File.file_path(file_directory, sha1)) as fp:
                content = fp.read()
        return TextOutput(content=content, **kwargs)
    elif not test_case_result.diff:  # Outputs match
        return DiffWithMetadata(diff=None, **kwargs)

    try:
        with open(File.file_path(file_directory, sha1)) as fp:
            diff = pickle.load(fp)
    except (AttributeError, EOFError):
        content = 'submit system mismatch -- requeue submission'
        content += traceback.format_exc(1)
        return TextOutput(content=content, **kwargs)
    except Exception:
        content = 'unexected error -- requeue submission\n'
        content += traceback.format_exc(1)
        return TextOutput(content=content, **kwargs)

    diff.hide_expected = not is_admin and test_case.hide_expected
    return DiffWithMetadata(diff=diff, **kwargs)
630253
def store(self, report, test_id):
        '''
        
        '''
        report_d = report.to_dict()
        content = self._serialize_dict(report_d)
        report_id = self.insert(
            ['test_id', 'content', 'status', 'reason'],
            [test_id, content, report.get_status(), report.get('reason')],
        )
        return report_id