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

[cmd] Parse command exits with error in case of duplicated suppress c… #3253

Merged
merged 7 commits into from
Jul 6, 2021

Conversation

zomen2
Copy link
Contributor

@zomen2 zomen2 commented Apr 5, 2021

…ommands

@zomen2 zomen2 added WIP 💣 Work In Progress CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands bugfix 🔨 labels Apr 5, 2021
@zomen2 zomen2 force-pushed the fix_doubled_report_error branch 2 times, most recently from 4ca23fe to c784e4a Compare April 8, 2021 13:22
@zomen2 zomen2 removed the WIP 💣 Work In Progress label Apr 8, 2021
@zomen2 zomen2 added this to the release 6.16.0 milestone Apr 8, 2021
Comment on lines 73 to 74
self._test_directory = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe())))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to use inspect module to get the current directory path. You can use the following code:

Suggested change
self._test_directory = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe())))
self._test_directory = os.path.dirname(os.path.realpath(__file__))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,10 @@
0c07579523063acece2d7aebd4357cac||suppress_export.cpp||foo1 simple||false_positive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is hardly connected to source file: https://github.com/zomen2/codechecker/blob/fix_doubled_report_error/analyzer/tests/projects/suppress/suppress_export.cpp
If we change the source file we need to change this file too. So it would be better to move this file back to the original location beside the source file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this moment the test source does not allow this. A large refactor should be performed on function test code before your suggestion can be done.

Comment on lines 145 to 263
"--input-format", "plist",
"--verbose", "debug", test_plist_file]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"--input-format", "plist",
"--verbose", "debug", test_plist_file]
test_plist_file]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the last two switch. But the file format switch does not modify the behavior of the test, but gives more information.

@@ -0,0 +1,6 @@
void foo()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there are two projects directories: in the analyzer part and in the web part. The module which handles the suppression comments can be found in the codechecker_common package: https://github.com/Ericsson/codechecker/blob/master/codechecker_common/source_code_comment_handler.py

For this reason I think we should create a common suppress project under this directory: https://github.com/Ericsson/codechecker/tree/master/codechecker_common/tests

So it would be codechecker_common/tests/projects/suppress. And we can move all the source files, suppress files, skip files under this project.

And test cases in the analyzer/web part can use this common project. This way we will test that the server and the parse command works the same way on the same code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above.

Comment on lines +3 to +4
// codechecker_suppress [deadcode.DeadStores] Same suppress comment twice.
// codechecker_suppress [deadcode.DeadStores] Same suppress comment twice.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a typical use case when the type and the checker name is the same. I agree that we need to test it too but we need to introduce more test cases which test the followin scenarios too:

  // codechecker_suppress [all] comment
  // codechecker_suppress [deadcode.DeadStores] comment
  // codechecker_suppress [all] comment
  // codechecker_confirmed [deadcode.DeadStores] comment
  // codechecker_suppress [all, deadcode.DeadStores] comment

For example on the second use case when I run the CodeChecker parse command I don't get an error message that multiple source code comments can be found for the same report but on the third use case I get this error. It should give an error in both cases.

Also now for every use cases we need to create a separte source files because it will give an error message on the first source code comment duplication. Maybe we can generate these source files on the fly. Simply creating a temp file, analyze and parse it. What do you think? We are doing the same for example at here: https://github.com/Ericsson/codechecker/blob/master/web/tests/functional/detection_status/test_detection_status.py#L82

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the implementation. New tests added to check these cases.

@zomen2 zomen2 force-pushed the fix_doubled_report_error branch from c784e4a to 25e09a1 Compare May 4, 2021 16:33
@zomen2 zomen2 added the WIP 💣 Work In Progress label May 4, 2021
@zomen2 zomen2 force-pushed the fix_doubled_report_error branch 3 times, most recently from 5baae28 to 19cd926 Compare May 6, 2021 11:29
@zomen2 zomen2 force-pushed the fix_doubled_report_error branch 2 times, most recently from c31937c to 3fb90be Compare May 27, 2021 11:32
@zomen2 zomen2 force-pushed the fix_doubled_report_error branch from 3fb90be to 41c3ad9 Compare May 31, 2021 14:37
zomen2 added 2 commits June 1, 2021 17:50
…processing

Functional tests enhanced to check semnthic of suppress comment language.
@zomen2 zomen2 removed the WIP 💣 Work In Progress label Jun 5, 2021
@zomen2 zomen2 requested a review from csordasmarton June 28, 2021 10:39
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@csordasmarton csordasmarton merged commit b4a7316 into Ericsson:master Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants