Skip to content

Commit

Permalink
Merge branch 'unstable'
Browse files Browse the repository at this point in the history
  • Loading branch information
suoto committed Mar 11, 2017
2 parents 2a06c68 + a740dab commit 3b1b105
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
8 changes: 7 additions & 1 deletion hdlcc/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ def getMessagesByPath():
"no content" if content is None else "with content")

server = _getServerByProjectFile(project_file)
return {'messages': server.getMessagesByPath(path)}
response = {}
if content is None:
response['messages'] = server.getMessagesByPath(path)
else:
response['messages'] = server.getMessagesWithText(path, content)

return response

@app.post('/get_ui_messages')
@_exceptionWrapper
Expand Down
6 changes: 3 additions & 3 deletions hdlcc/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def __init__(self, filename, library='work', flags=None):
self._content = None
self._mtime = 0
self.filetype = getFileType(self.filename)

self._prev = None

self.abspath = p.abspath(filename)

def getState(self):
Expand Down Expand Up @@ -122,7 +124,6 @@ def _changed(self):
provided by p.getmtime
"""
if self.getmtime() > self._mtime:
_logger.debug("File '%s' has changed", self.filename)
return True
return False

Expand Down Expand Up @@ -186,7 +187,6 @@ def _setBufferContent(self, content):
buffer_dump_path = self.getDumpPath()
_logger.debug("Dumping buffer content to '%s'", buffer_dump_path)
open(buffer_dump_path, 'w').write(self._content)
return buffer_dump_path

def _clearBufferContent(self):
"""
Expand All @@ -204,6 +204,7 @@ def getSourceContent(self):
"""
Cached version of the _getSourceContent method
"""

self._clearCachesIfChanged()

if self._content is None:
Expand All @@ -221,7 +222,6 @@ def getRawSourceContent(self):

if self.hasBufferContent():
return self._content

if 'raw_content' not in self._cache or self._changed():
self._cache['raw_content'] = \
open(self.filename, mode='rb').read().decode(errors='ignore')
Expand Down
58 changes: 29 additions & 29 deletions hdlcc/tests/test_server_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,35 +355,35 @@ def build_with_buffer_leave():

# TODO: This test has side effects and makes other tests fail. Skip
# it for now
# @it.should("get messages with content")
# def test():
# data = {
# 'project_file' : it.PROJECT_FILE,
# 'path' : p.join(
# VIM_HDL_EXAMPLES, 'another_library', 'foo.vhd'),
# 'content' : '-- TODO: Nothing to see here'}

# ui_reply = it.app.post('/get_ui_messages', data)
# reply = it.app.post('/get_messages_by_path', data)

# _logger.info("UI reply: %s", ui_reply)
# _logger.info("Reply: %s", reply)

# messages = reply.json['messages']

# for message in messages:
# it.assertTrue(utils.samefile(message.pop('filename'),
# data['path']))

# it.assertIn(
# {"error_type" : "W",
# "checker" : "HDL Code Checker/static",
# "line_number" : 1,
# "column" : 4,
# "error_subtype" : "",
# "error_number" : "0",
# "error_message" : "TODO: Nothing to see here"},
# messages)
@it.should("get messages with content")
def test():
data = {
'project_file' : it.PROJECT_FILE,
'path' : p.join(
VIM_HDL_EXAMPLES, 'another_library', 'foo.vhd'),
'content' : '-- TODO: Nothing to see here'}

ui_reply = it.app.post('/get_ui_messages', data)
reply = it.app.post('/get_messages_by_path', data)

_logger.info("UI reply: %s", ui_reply)
_logger.info("Reply: %s", reply)

messages = reply.json['messages']

for message in messages:
it.assertTrue(utils.samefile(message.pop('filename'),
data['path']))

it.assertIn(
{"error_type" : "W",
"checker" : "HDL Code Checker/static",
"line_number" : 1,
"column" : 4,
"error_subtype" : "",
"error_number" : "0",
"error_message" : "TODO: Nothing to see here"},
messages)

@it.should("get source dependencies")
@mock.patch('hdlcc.config_parser.foundVunit', lambda: False)
Expand Down

0 comments on commit 3b1b105

Please sign in to comment.