Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VUnit fails to parse file with commented code #670

Open
PaulWozny opened this issue Jul 28, 2020 · 3 comments · May be fixed by #836
Open

VUnit fails to parse file with commented code #670

PaulWozny opened this issue Jul 28, 2020 · 3 comments · May be fixed by #836
Labels

Comments

@PaulWozny
Copy link

PaulWozny commented Jul 28, 2020

Hello,

On the newest docker image ghdl/vunit:gcc-master sha256:35b8034a5102aabcd34c1d87e337b3e071eeb38d3ad23eb21cc93bd479bf1ab2 following code produces error only when commented line is in the file.

  • test.vhd
library vunit_lib;
context vunit_lib.vunit_context;

entity mwe_parsing_comments is
    generic (runner_cfg : string);
end entity mwe_parsing_comments;

architecture beh of mwe_parsing_comments is
begin

    main : process
    begin
        test_runner_setup(runner, runner_cfg);
        test_runner_cleanup(runner);
    end process;

    -- Remove following line to compile
    --            check(false, "max5719 vunit:no response from dac");

end architecture beh;
  • run.py
from vunit import VUnit
vu = VUnit.from_argv()
testlib = vu.add_library("test")
testlib.add_source_files("test.vhd")
vu.main()
  • error message:
I have no name!@72499ee8c65a:/work$ python3 run.py                                                                      [7/1680]
WARNING - Entity mwe_parsing_comments has runner_cfg generic but the file name and the entity name does not match regex ^(tb_.*)
|(.*_tb)$
in file /work/test.vhd
Traceback (most recent call last):
  File "run.py", line 4, in <module>
    testlib.add_source_files("test.vhd")
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/ui/library.py", line 200, in add_source_files
    for file_name in get_checked_file_names_from_globs(pattern, allow_empty)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/ui/library.py", line 200, in <listcomp>
    for file_name in get_checked_file_names_from_globs(pattern, allow_empty)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/ui/library.py", line 260, in add_source_file
    self._test_bench_list.add_from_source_file(source_file)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench_list.py", line 37, in add_from_source_file
    self._add_test_bench(TestBench(design_unit, self._database))
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 47, in __init__
    self._add_architecture_callback()
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 57, in _add_architecture_callback
    self.scan_tests_from_file(file_name)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 201, in scan_tests_from_file
    newline="",
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/cached.py", line 47, in cached
    result = function(content)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 192, in parse
    tests, attributes = _find_tests_and_attributes(content, file_name)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 553, in _find_tests_and_attributes
    attributes = _find_attributes(content, file_name, line_offsets)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 638, in _find_attributes
    _find(Attribute, _RE_ATTRIBUTE)
  File "/usr/local/lib/python3.7/dist-packages/vunit_hdl-4.4.1rc0-py3.7.egg/vunit/test/bench.py", line 632, in _find
    % (name, file_name, location.lineno)
RuntimeError: Invalid attribute 'no' in /work/test.vhd line 20

@eine eine added the Parsing label Jul 28, 2020
@eine
Copy link
Collaborator

eine commented Jul 28, 2020

@PaulWozny, does it work if you remove/replace : in the string?

@PaulWozny
Copy link
Author

@PaulWozny, does it work if you remove/replace : in the string?

Yes.

It also works when there are no characters after :.
For example this works as well:

    --            check(false, "max5719 vunit:");

@eine
Copy link
Collaborator

eine commented Aug 28, 2020

@PaulWozny, thanks for checking! The parser, which is based on regexps, is known to work just well enough, and there are weird constraints such as this one. However, it is undesirable to make the parser more complex than it already is. See related discussions: https://github.com/VUnit/vunit/issues?q=label%3Aparsing+sort%3Aupdated-desc+

Hence, unless someone comes up with a not very complex modification to the regular expressions (https://github.com/VUnit/vunit/blob/master/vunit/vhdl_parser.py), I think avoiding : in comments is the safest approach.

@std-max std-max linked a pull request May 31, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants