Skip to content

Commit

Permalink
Merge pull request #78 from xinzhel97/total-file-size-of-array
Browse files Browse the repository at this point in the history
Add a preprocessor to find total size of an array of files
  • Loading branch information
junyk authored Jun 30, 2021
2 parents 7340817 + 7b09212 commit 0b5b79f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions janis_core/tool/test_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TTestPreprocessor(Enum):
LineCount = "line-count"
ListSize = "list-size"
ListOfFilesExist = "list-of-files-exist"
ListOfFilesTotalSize = "list-of-files-total-size"


class TTestExpectedOutput(object):
Expand Down
11 changes: 11 additions & 0 deletions janis_core/tool/test_suite_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ def _apply_preprocessor(
if not (os.path.getsize(file + test_logic.suffix) > 0):
return False
return True
elif test_logic.preprocessor == TTestPreprocessor.ListOfFilesTotalSize:
total_size = 0
if not output_value:
return False
files = output_value.split("|")
for file in files:
if test_logic.suffix is None:
total_size += os.path.getsize(file)
else:
total_size += os.path.getsize(file + test_logic.suffix)
return total_size
else:
raise Exception(
f"{test_logic.preprocessor} comparison type is not supported"
Expand Down

0 comments on commit 0b5b79f

Please sign in to comment.