-
Notifications
You must be signed in to change notification settings - Fork 3
Add test for symlink resolution #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ad09716
Add logging to base class
furtib e301806
Fix path problems
furtib 7300af9
Add way to pass path to base class, move folder change before environ…
furtib b7767d7
Format
furtib 684b954
Move template into unittest folder
furtib ba55b0c
Change template place
furtib 86af7d5
Enforce setting __test_path__ BAZEL_BIN_DIR and BAZEL_TESTLOGS_DIR
furtib f4a49cd
Revert "Move template into unittest folder"
furtib d3893a2
Revert "Change template place"
furtib 9c4ef5d
Add comments, and teardown method
furtib caa8916
Move clean command to only run once per suite
furtib e807c8b
Test splitting to files by platform
furtib fe64b0c
Revert "Test splitting to files by platform"
furtib 663ddb3
Change message, rename file
furtib 44695be
What extra " ?
furtib 891cf6a
Reword Note
furtib a43633e
Update Note for rhel9 to
furtib fb753da
Add composite actions for environment setup
furtib 108e4d6
Use composite actions
furtib 1ca4911
Chenge extension yml to yaml
furtib 38216f9
Move composite actions into a different directory
furtib a3ad98a
Trigger Build
furtib 55afb25
Trigger Build
furtib 7845c01
Add test for path resolution, in plist files (in accordance with #22)
furtib 60700f0
Add manual tag
furtib 238f971
Add python test
furtib 0972d32
Create __init__.py
furtib d76faab
Rename to fit unittest standards
furtib 14ed3e3
Set to use common lib
furtib efedb47
Check whether the _virtual_includes folder really does exists
furtib ab10737
remove unnecessary imports
furtib 84f9d25
Fix import of common module, by adding unit to pythons path
furtib edb06ee
Move to common
furtib c4261b7
Add comments
furtib 30c64bb
Fix to new __init__.py
furtib e77fcfd
Remove unnecesary include
furtib 30e56c3
Add path override
furtib f74564f
Format
furtib fb1302f
change comment
furtib 42b1ee7
Add license
furtib 96819d8
Update test to follow common lib
furtib 7679d95
Form to new template
furtib e20e8a6
Use base lib grep instead
furtib 17a542e
Fix test to pass
furtib cb9e07b
Add zero division not detectable by compiler
furtib ef5159f
Change to lib
furtib 1b94f5c
Remove unused functions
furtib 5c570bb
Change comment
furtib 545eb21
Change way of detection, add new function
furtib b747da8
Split check into 2
furtib 0f48b4a
Remove comment
furtib 9586d62
remove unnecessary comments
furtib d3ef687
Update test/unit/virtual_include/test_virtual_include.py
furtib 12fa5c6
Remove comments
furtib cf98334
Add description to test file
furtib c590c27
Use common lib
furtib b9dff14
Add license
furtib 74e7c98
Add comments
furtib e2ee06f
Fix formating
furtib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright 2023 Ericsson AB | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # cc_binary for simple C++ tests | ||
| load( | ||
| "@rules_cc//cc:defs.bzl", | ||
| "cc_library", | ||
| ) | ||
|
|
||
| # codechecker rules | ||
| load( | ||
| "@bazel_codechecker//src:codechecker.bzl", | ||
| "codechecker_test", | ||
| ) | ||
|
|
||
| load( | ||
| "@bazel_codechecker//src:code_checker.bzl", | ||
| "code_checker_test", | ||
| ) | ||
|
|
||
| # Test for strip_include_prefix | ||
| cc_library( | ||
| name = "test_inc", | ||
| hdrs = glob(["inc/*.h"]), | ||
| strip_include_prefix = "inc", | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "virtual_include", | ||
| srcs = ["source.cc"], | ||
| deps = ["test_inc"], | ||
| ) | ||
|
|
||
| # Simplest virtual include resolution test | ||
| codechecker_test( | ||
| name = "codechecker_virtual_include", | ||
| tags = [ | ||
| "manual", | ||
| ], | ||
| targets = [ | ||
| "virtual_include", | ||
| ], | ||
| ) | ||
|
|
||
| code_checker_test( | ||
| name = "code_checker_virtual_include", | ||
| tags = [ | ||
| "manual", | ||
| ], | ||
| targets = [ | ||
| "virtual_include", | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2023 Ericsson AB | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright 2023 Ericsson AB | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef ZERODIV_H | ||
| #define ZERODIV_H | ||
| int warnMe(int i){ | ||
| if (i == 0) | ||
| return 1/i; | ||
| } | ||
| #endif //ZERODIV_H | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright 2023 Ericsson AB | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "zeroDiv.h" | ||
|
|
||
| int main(){ | ||
| warnMe(0); | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Copyright 2023 Ericsson AB | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """ | ||
| We want CodeChecker to point to the original files in its results, this needs | ||
| post processing. | ||
| Bazel creates _virtual_includes folder for headers, declared in a cc_library | ||
| rule with the include_prefix or strip_include_prefix. When warnings are found | ||
| in these headers, their paths in the plist files should get resolved to the | ||
| original file path. | ||
| This unittest test whether these paths containing `_virtual_include` have been | ||
| resolved | ||
| """ | ||
| import logging | ||
| import os | ||
| import re | ||
| import unittest | ||
| import glob | ||
| from typing import final | ||
| from common.base import TestBase | ||
|
|
||
|
|
||
| class TestVirtualInclude(TestBase): | ||
| """Tests checking virtual include path resolution""" | ||
|
|
||
| # Set working directory | ||
| __test_path__ = os.path.dirname(os.path.abspath(__file__)) | ||
| BAZEL_BIN_DIR = os.path.join( | ||
| "../../..", "bazel-bin", "test", "unit", "virtual_include" | ||
| ) | ||
| BAZEL_TESTLOGS_DIR = os.path.join( | ||
| "../../..", "bazel-testlogs", "test", "unit", "virtual_include" | ||
| ) | ||
|
|
||
| @final | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| """Set up before the test suite""" | ||
| super().setUpClass() | ||
| cls.run_command("bazel clean") | ||
|
|
||
| def contains_in_files(self, regex, folder_path): | ||
| result = [] | ||
| for file in folder_path: | ||
| logging.debug(f"Checking file: {file}") | ||
| if self.contains_regex_in_file: | ||
| result.append(file) | ||
| return result | ||
|
|
||
| def test_bazel_code_checker_plist_path_resolved(self): | ||
| """Test: bazel build :code_checker_virtual_include""" | ||
| ret, _, _ = self.run_command( | ||
| "bazel build //test/unit/virtual_include:code_checker_virtual_include", | ||
| ) | ||
| self.assertEqual(ret, 0) | ||
| plist_files = glob.glob( | ||
| os.path.join( | ||
| self.BAZEL_BIN_DIR, | ||
| "code_checker_virtual_include", | ||
| "**", | ||
| "*.plist", | ||
| ), | ||
| recursive=True, | ||
| ) | ||
| # Test whether the _virtual_include directory was actually created. | ||
| self.assertTrue( | ||
| os.path.isdir(f"{self.BAZEL_BIN_DIR}/_virtual_includes") | ||
| ) | ||
| # FIXME: In the postprocessed plists, all _virtual_include paths | ||
| # should've been removed. Possible fix is in the github PR #14. | ||
| self.assertNotEqual( | ||
| self.contains_in_files(r"/_virtual_includes/", plist_files), [] | ||
| ) | ||
|
|
||
| def test_bazel_codechecker_plist_path_resolved(self): | ||
| """Test: bazel build :codechecker_virtual_include""" | ||
| ret, _, _ = self.run_command( | ||
| "bazel build //test/unit/virtual_include:codechecker_virtual_include" | ||
| ) | ||
| self.assertEqual(ret, 0) | ||
| plist_files = glob.glob( | ||
| os.path.join( | ||
| self.BAZEL_BIN_DIR, | ||
| "codechecker_virtual_include", | ||
| "**", | ||
| "*.plist", | ||
| ), | ||
| recursive=True, | ||
| ) | ||
| # Test whether the _virtual_include directory was actually created. | ||
| self.assertTrue( | ||
| os.path.isdir(f"{self.BAZEL_BIN_DIR}/_virtual_includes") | ||
| ) | ||
| # FIXME: In the postprocessed plists, all _virtual_include paths | ||
| # should've been removed. Possible fix is in the github PR #14. | ||
| self.assertNotEqual( | ||
| self.contains_in_files(r"/_virtual_includes/", plist_files), [] | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main(buffer=True) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.