def find_run_strings(self, code, file_name): """ Finds all if run("something") strings in file """ code = remove_comments(code) run_strings = [match.group(1) for match in self._re_run_string.finditer(code)] unique = set() not_unique = set() for run_string in run_strings: if run_string in unique and run_string not in not_unique: # @TODO line number information could be useful logger.error('Duplicate test case "%s" in %s' % (run_string, file_name)) not_unique.add(run_string) unique.add(run_string) if len(not_unique) > 0: raise TestScannerError for run_string in run_strings: if self._re_valid_run_string.match(run_string) is None: logger.warning('Test name "%s" does not match %s in %s', run_string, self._valid_run_string_fmt, file_name) return run_strings
def find_run_strings(self, code, file_name, verilog): """ Finds all if run("something") strings in file """ if verilog: # @TODO verilog regexp = self._re_verilog_run_string else: code = remove_comments(code) regexp = self._re_vhdl_run_string run_strings = [match.group(1) for match in regexp.finditer(code)] unique = set() not_unique = set() for run_string in run_strings: if run_string in unique and run_string not in not_unique: # @TODO line number information could be useful LOGGER.error('Duplicate test case "%s" in %s', run_string, file_name) not_unique.add(run_string) unique.add(run_string) if len(not_unique) > 0: raise TestScannerError for run_string in run_strings: if self._re_valid_run_string.match(run_string) is None: LOGGER.warning( 'Test name "%s" does not match %s in %s', run_string, self._valid_run_string_fmt, file_name ) return run_strings
def _find_test_cases(code, file_name): """ Finds all if run("something") strings in file """ is_verilog = file_type_of(file_name) in VERILOG_FILE_TYPES if is_verilog: regexp = _RE_VERILOG_TEST_CASE else: code = remove_comments(code) regexp = _RE_VHDL_TEST_CASE test_cases = [match.group("name") for match in regexp.finditer(code)] unique = set() not_unique = set() for test_case in test_cases: if test_case in unique and test_case not in not_unique: # @TODO line number information could be useful LOGGER.error('Duplicate test case "%s" in %s', test_case, file_name) not_unique.add(test_case) unique.add(test_case) if not_unique: raise RuntimeError('Duplicate test cases') return test_cases
def find_run_strings(self, code, file_name, verilog): """ Finds all if run("something") strings in file """ if verilog: # @TODO verilog regexp = self._re_verilog_run_string else: code = remove_comments(code) regexp = self._re_vhdl_run_string run_strings = [match.group(1) for match in regexp.finditer(code)] unique = set() not_unique = set() for run_string in run_strings: if run_string in unique and run_string not in not_unique: # @TODO line number information could be useful LOGGER.error('Duplicate test case "%s" in %s', run_string, file_name) not_unique.add(run_string) unique.add(run_string) if len(not_unique) > 0: raise TestScannerError return run_strings
def parse(cls, code): """ Return a new VHDLPackage instance for a single package found within the code """ code = remove_comments(code).lower() return cls( cls._package_start_re.match(code).group('id'), list(CodecVHDLEnumerationType.find(code)), list(CodecVHDLRecordType.find(code)), list(CodecVHDLArrayType.find(code)))
def parse(cls, code): """ Return a new VHDLPackage instance for a single package found within the code """ code = remove_comments(code).lower() # Extract identifier identifier = cls._package_start_re.match(code).group('id') enumeration_types = [e for e in CodecVHDLEnumerationType.find(code)] record_types = [r for r in CodecVHDLRecordType.find(code)] array_types = [a for a in CodecVHDLArrayType.find(code)] return cls(identifier, enumeration_types, record_types, array_types)
def test_two_adjacent_hyphens_in_a_literal(self): stimulus = 'signal a : std_logic_vector(3 downto 0) := "----";' self.assertEqual(remove_comments(stimulus), stimulus)
def test_remove_comments(self): self.assertEqual(remove_comments("a\n-- foo \nb"), "a\n \nb")