def load_tests(_, _2, _3):
  project = web_components_project.WebComponentsProject()
  suite = module_test_case.DiscoverTestsInModule(
      project,
      project.telemetry_path)
  assert suite.countTestCases() > 0, 'Expected to find at least one test.'
  return suite
    def WriteWebComponentToFile(self, f):
        project = web_components_project.WebComponentsProject()
        load_sequence = project.CalcLoadSequenceForModuleNames(
            self.GetDependentModuleNames())

        with open(
                os.path.join(os.path.dirname(__file__),
                             'web_component_bootstrap.js')) as bfile:
            bootstrap_js_template = string.Template(bfile.read())
        bootstrap_js = bootstrap_js_template.substitute(
            js_class_name=self._js_class_name,
            data_binding_property=self._data_binding_property)

        bootstrap_script = generate.ExtraScript(text_content=bootstrap_js)

        class WebComponentDataScript(generate.ExtraScript):
            def __init__(self, results_component):
                # pylint: disable=bad-super-call
                super(WebComponentDataScript, self).__init__()
                self._results_component = results_component

            def WriteToFile(self, output_file):
                output_file.write(
                    '<script id="telemetry-web-component-data" ' +
                    'type="application/json">\n')
                self._results_component.WriteDataToFileAsJson(output_file)
                output_file.write('</script>\n')

        generate.GenerateStandaloneHTMLToFile(
            f,
            load_sequence,
            title='Telemetry results',
            extra_scripts=[bootstrap_script,
                           WebComponentDataScript(self)])
def load_tests(_, _2, _3):
    project = web_components_project.WebComponentsProject()
    if os.getenv('NO_TVCM'):
        suite = unittest.TestSuite()
    else:
        suite = module_test_case.DiscoverTestsInModule(project,
                                                       project.telemetry_path)
        assert suite.countTestCases(
        ) > 0, 'Expected to find at least one test.'
    return suite
示例#4
0
def Main(port, args):
    parser = optparse.OptionParser()
    _, args = parser.parse_args(args)

    project = web_components_project.WebComponentsProject()
    server = tvcm.DevServer(port=port, project=project)

    def IsTestModuleResourcePartOfTelemetry(module_resource):
        return module_resource.absolute_path.startswith(project.telemetry_path)

    server.test_module_resource_filter = IsTestModuleResourcePartOfTelemetry
    return server.serve_forever()