Skip to content

Unit test is wrong #57

@airween

Description

@airween

The linter has a few unit tests, but the [test_cli`(https://github.com/coreruleset/crs-linter/blob/main/tests/test_cli.py) is wrong.

It expects the main() returns with 0, but

  • most tests under examples/ contains some error intentionally to demonstrate how the linter works
  • therefore the main() mustn't return with 0
  • the reason is simple: in the unit test we passed wrong path of tests here and here: the ../ isn't necessary
  • the other problem is that if the linter gets a non-existent path for rules, it eats silently, there is no report

I can send a PR, but how do we want to solve this?

My suggestion is:

  • add check against -r argument; if there is a nonexistent file/path, so the files is an empty list, then linter exists immediately
  • remove ../ from arguments' -r of cli's unit test
  • change assert == 0 to assert == 1

Question: now the APPROVED_TAGS and TEST_EXCLUSIONS are empty (temporary) files; because all listed tests contain some error (intentionally), we don't need to fill them, those need only to start the linter, right?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions