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

[test] Test workspace is not necessarily under HOME #3421

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions analyzer/tests/functional/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,18 @@ def test_check_config(self):
analyzer only and parse the results with a parse command
config.
"""
# We assume that the source file path is at least 2 levels deep. This
# is true, since the test workspace directory is under the repo root
# and it also contains some sub-directories.
split_path = self.source_file.split(os.sep)
path_prefix = os.path.join(os.sep, *split_path[:3])
trimmed_file_path = os.path.join(*split_path[3:])

with open(self.config_file, 'w+',
encoding="utf-8", errors="ignore") as config_f:
json.dump({
'analyzer': ['--analyzers', 'clangsa'],
'parse': ['--trim-path-prefix', '${HOME}']},
'parse': ['--trim-path-prefix', path_prefix]},
config_f)

check_cmd = [self._codechecker_cmd, "check",
Expand All @@ -239,6 +246,4 @@ def test_check_config(self):

self.assertNotIn(self.source_file, out)

trimmed_file_path = self.source_file.replace(
os.path.expanduser("~") + os.path.sep, "")
self.assertIn(trimmed_file_path, out)