MarketSquare / robotframework-sherlock

Robot Framework code inspector
Apache License 2.0
13 stars 1 forks source link

Tasks and Test Cases cannot be included to the same run #75

Open jannek76 opened 1 year ago

jannek76 commented 1 year ago

If we have example two files:

├── rpa_test.robot └── test_robot.robot

rpa_test.robot:

*** Tasks ***
Test Tasks
  No Operation

test_robot.robot:

*** Test Cases ***
Test Case Example
    No Operation

We got error:

$ sherlock
Sherlock analysis of Robot Framework code:

Using <home_path>/sources/sherlock_test as source repository
Traceback (most recent call last):
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 177, in _build_suite
    self._validate_execution_mode(suite)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 191, in _validate_execution_mode
    raise DataError(f"Conflicting execution modes. File has {this} "
robot.errors.DataError: Conflicting execution modes. File has tests but files parsed earlier have tasks. Fix headers or use '--rpa' or '--norpa' options to set the execution mode explicitly.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<home_path>/.pyenv/versions/sherlock/bin/sherlock", line 8, in <module>
    sys.exit(run_cli())
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/sherlock/__init__.py", line 19, in run_cli
    raise err
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/sherlock/__init__.py", line 9, in run_cli
    runner.run()
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/sherlock/core.py", line 29, in run
    suite = TestSuiteBuilder().build(self.config.path)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 91, in build
    suite = parser.parse(structure)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 138, in parse
    structure.visit(self)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/parsing/suitestructure.py", line 46, in visit
    visitor.visit_directory(self)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/parsing/suitestructure.py", line 166, in visit_directory
    child.visit(self)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/parsing/suitestructure.py", line 44, in visit
    visitor.visit_file(self)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 144, in visit_file
    suite, _ = self._build_suite(structure)
  File "<home_path>/.pyenv/versions/3.8.15/envs/sherlock/lib/python3.8/site-packages/robot/running/builder/builders.py", line 179, in _build_suite
    raise DataError(f"Parsing '{source}' failed: {err.message}")
robot.errors.DataError: Parsing '<home_path>/sources/sherlock_test/test_robot.robot' failed: Conflicting execution modes. File has tests but files parsed earlier have tasks. Fix headers or use '--rpa' or '--norpa' options to set the execution mode explicitly.
Fatal exception occurred. You can create an issue at https://github.com/bhirsz/robotframework-sherlock/issues . Thanks!
$ pip list
Package                 Version
----------------------- -------
commonmark              0.9.1
Jinja2                  3.1.2
MarkupSafe              2.1.2
pathspec                0.9.0
pip                     22.0.4
Pygments                2.14.0
rich                    13.1.0
robotframework          6.0.2
robotframework-sherlock 0.2.0
setuptools              56.0.0
tabulate                0.8.9
toml                    0.10.2
typing_extensions       4.4.0
bhirsz commented 1 year ago

Thanks for the report, I'm getting back to Sherlock and I will try to fix it. I believe we should handle both (tasks and tests) without need to set --rpa/--no-rpa options.