some progress but eh
This commit is contained in:
@@ -28,7 +28,7 @@ class Tags:
|
|||||||
def _update_cache(self):
|
def _update_cache(self):
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
with self.TAGS_PATH.open('r') as f:
|
with self.TAGS_PATH.open('r') as f:
|
||||||
lines = (l for l in f.readlines() if not l.startswith('!_'))
|
lines = (l for l in f.readlines() if not l.startswith('!_') and not l.startswith('__anon'))
|
||||||
for line in lines:
|
for line in lines:
|
||||||
symbol, file, location, type, *_ = line.split('\t')
|
symbol, file, location, type, *_ = line.split('\t')
|
||||||
location = location.removesuffix(';"')
|
location = location.removesuffix(';"')
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ctags_ls.tags import Tags
|
from ctags_ls.tags import Tag, Tags
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
# TODO: generate the tags file dynamically as preperation to the test.
|
tags_path = Path(__file__).parent.resolve() / 'tags'
|
||||||
def test_parsing():
|
tags = (tag for tags in Tags(tags_path=tags_path).symbols.values() for tag in tags)
|
||||||
tags_path = Path(__file__).parent.resolve() / 'tags'
|
|
||||||
tags = Tags(tags_path=tags_path)
|
@pytest.mark.parametrize("tag", tags)
|
||||||
for tags in tags.symbols.values():
|
def test_tag(tag: Tag):
|
||||||
for tag in tags:
|
assert len(tag.type) == 1
|
||||||
assert len(tag.type) == 1
|
assert tag.file.is_file()
|
||||||
assert tag.file.is_file()
|
text = tag.file.read_text()
|
||||||
text = tag.file.read_text()
|
if isinstance(tag.location, re.Pattern):
|
||||||
if isinstance(tag.location, re.Pattern):
|
assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}'
|
||||||
assert next(tag.location.finditer(text), None) is not None, f'{tag.location.pattern} has no matches in {tag.file}'
|
else:
|
||||||
else:
|
assert text.count('\n') >= tag.location
|
||||||
assert text.count('\n') >= tag.location
|
assert tag.symbol in text.splitlines()[tag.location-1]
|
||||||
|
|||||||
Reference in New Issue
Block a user