def scan_tests_from_file(self, file_name): """ Scan file for test cases and pragmas """ if not file_exists(file_name): raise ValueError("File %r does not exist" % file_name) def parse(content): """ Parse pragmas and test case names """ pragmas = _find_pragmas(content, file_name) test_case_names = _find_test_cases(content, file_name) return pragmas, test_case_names pragmas, test_case_names = cached("test_bench.parse", parse, file_name, encoding=HDL_FILE_ENCODING, database=self._database) default_config = Configuration(DEFAULT_NAME, self.design_unit) if "fail_on_warning" in pragmas: default_config.set_sim_option("vhdl_assert_stop_level", "warning") self._configs = OrderedDict({default_config.name: default_config}) self._individual_tests = "run_all_in_same_sim" not in pragmas and len(test_case_names) > 0 self.test_cases = [TestCase(name, self.design_unit, self._individual_tests, default_config.copy()) for name in test_case_names]
def scan_tests_from_file(self, file_name): """ Scan file for test cases and attributes """ if not file_exists(file_name): raise ValueError("File %r does not exist" % file_name) def parse(content): """ Parse attributes and test case names """ tests, attributes = _find_tests_and_attributes(content, file_name) return tests, attributes tests, attributes = cached("test_bench.parse", parse, file_name, encoding=HDL_FILE_ENCODING, database=self._database, newline='') for attr in attributes: if _is_user_attribute(attr.name): raise RuntimeError("File global attributes are not yet supported: %s in %s line %i" % (attr.name, file_name, attr.location.lineno)) for test in tests: for attr in test.attributes: if attr.name in _VALID_ATTRIBUTES: raise RuntimeError("Attribute %s is global and cannot be associated with test %s: %s line %i" % (attr.name, test.name, file_name, attr.location.lineno)) attribute_names = [attr.name for attr in attributes] default_config = Configuration(DEFAULT_NAME, self.design_unit) if "fail_on_warning" in attribute_names: default_config.set_sim_option("vhdl_assert_stop_level", "warning") self._configs = OrderedDict({default_config.name: default_config}) explicit_tests = [test for test in tests if test.is_explicit] if explicit_tests: # All tests shall be explicit when there are at least one explicit test assert len(tests) == len(explicit_tests) self._implicit_test = None else: # There can only be one implicit test assert len(tests) == 1 self._implicit_test = tests[0] self._individual_tests = "run_all_in_same_sim" not in attribute_names and len(explicit_tests) > 0 self._test_cases = [TestConfigurationVisitor(test, self.design_unit, self._individual_tests, default_config.copy()) for test in explicit_tests]
def parse(self, file_name): """ Parse the VHDL code and return a VHDLDesignFile parse result parse result is re-used if content hash found in database """ file_name = abspath(file_name) return cached("CachedVHDLParser.parse", VHDLDesignFile.parse, file_name, encoding=HDL_FILE_ENCODING, database=self._database)
def scan_tests_from_file(self, file_name): """ Scan file for test cases and pragmas """ if not file_exists(file_name): raise ValueError("File %r does not exist" % file_name) def parse(content): """ Parse pragmas and test case names """ pragmas = _find_pragmas(content, file_name) tests = _find_tests(content, file_name) return pragmas, tests pragmas, tests = cached("test_bench.parse", parse, file_name, encoding=HDL_FILE_ENCODING, database=self._database) default_config = Configuration(DEFAULT_NAME, self.design_unit) if "fail_on_warning" in pragmas: default_config.set_sim_option("vhdl_assert_stop_level", "warning") self._configs = OrderedDict({default_config.name: default_config}) explicit_tests = [test for test in tests if test.is_explicit] if explicit_tests: # All tests shall be explicit when there are at least one explicit test assert len(tests) == len(explicit_tests) self._implicit_test = None else: # There can only be one implicit test assert len(tests) == 1 self._implicit_test = tests[0] self._individual_tests = "run_all_in_same_sim" not in pragmas and len( explicit_tests) > 0 self._test_cases = [ TestConfigurationVisitor(test, self.design_unit, self._individual_tests, default_config.copy()) for test in explicit_tests ]
def scan_tests_from_file(self, file_name): """ Scan file for test cases and attributes """ if not file_exists(file_name): raise ValueError("File %r does not exist" % file_name) def parse(content): """ Parse attributes and test case names """ tests, attributes = _find_tests_and_attributes(content, file_name) return tests, attributes tests, attributes = cached("test_bench.parse", parse, file_name, encoding=HDL_FILE_ENCODING, database=self._database, newline='') for attr in attributes: if _is_user_attribute(attr.name): raise RuntimeError( "File global attributes are not yet supported: %s in %s line %i" % (attr.name, file_name, attr.location.lineno)) for test in tests: for attr in test.attributes: if attr.name in _VALID_ATTRIBUTES: raise RuntimeError( "Attribute %s is global and cannot be associated with test %s: %s line %i" % (attr.name, test.name, file_name, attr.location.lineno)) attribute_names = [attr.name for attr in attributes] default_config = Configuration(DEFAULT_NAME, self.design_unit) if "fail_on_warning" in attribute_names: default_config.set_sim_option("vhdl_assert_stop_level", "warning") self._configs = OrderedDict({default_config.name: default_config}) explicit_tests = [test for test in tests if test.is_explicit] if explicit_tests: # All tests shall be explicit when there are at least one explicit test assert len(tests) == len(explicit_tests) self._implicit_test = None else: # There can only be one implicit test assert len(tests) == 1 self._implicit_test = tests[0] self._individual_tests = "run_all_in_same_sim" not in attribute_names and len( explicit_tests) > 0 self._test_cases = [ TestConfigurationVisitor(test, self.design_unit, self._individual_tests, default_config.copy()) for test in explicit_tests ]