Skip to content

Commit

Permalink
[test] Add cmdline tests for the diff feature
Browse files Browse the repository at this point in the history
We usually test CodeChecker diff by making API calls that one can find
in report_server.py. However, `CodeChecker cmd diff` doesn't invoke
these plainly, but rather wraps it in various functions, for which we
never had proper tests. Until now!

I also made sure to include (almost all) cases discussed here:
Ericsson#3884
  • Loading branch information
Szelethus committed Jun 26, 2023
1 parent 8f10d60 commit 6a61420
Show file tree
Hide file tree
Showing 4 changed files with 668 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/server/codechecker_server/api/mass_store_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,15 @@ def store(self) -> int:
runtime = round(time.time() - start_time, 2)
zip_size_kb = round(zip_size / 1024)

tag_desc = ""
if self.__tag:
tag_desc = f", under tag '{self.__tag}'"

LOG.info("'%s' stored results (%s KB "
"/decompressed/) to run '%s' (id: %d) in "
"/decompressed/) to run '%s' (id: %d) %s in "
"%s seconds.", self.user_name,
zip_size_kb, self.__name, run_id, runtime)
zip_size_kb, self.__name, run_id, tag_desc,
runtime)

iso_start_time = datetime.fromtimestamp(
start_time).isoformat()
Expand Down
3 changes: 3 additions & 0 deletions web/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
REPO_ROOT = os.path.abspath(os.environ['REPO_ROOT'])
PKG_ROOT = os.path.join(REPO_ROOT, 'build', 'CodeChecker')

os.environ["CC_DATA_FILES_DIR"] = PKG_ROOT
os.environ["CC_LIB_DIR"] = os.path.join(PKG_ROOT, "lib", "python3")

sys.path.append(os.path.join(PKG_ROOT, 'lib', 'python3'))
8 changes: 8 additions & 0 deletions web/tests/functional/diff_cmdline/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
# -------------------------------------------------------------------------
#
# Part of the CodeChecker project, under the Apache License v2.0 with
# LLVM Exceptions. See LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# -------------------------------------------------------------------------
Loading

0 comments on commit 6a61420

Please sign in to comment.