From b821098aa7a1c99782e6df6df4533f927014f60b Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 11 Nov 2024 21:48:08 -0500 Subject: [PATCH 01/41] feat(output.py): began working on grade weights --- gatorgrade/output/output.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 8fc94c5b..2f59ab59 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -174,6 +174,9 @@ def create_markdown_report_file(json: dict) -> str: if "command" == i: val = check["options"]["command"] markdown_contents += f"\n\t- **command** {val}" + if "weight" == i: + val = check["options"]["weight"] + markdown_contents += f"\n\t- **weight:** {val}" if "fragment" == i: val = check["options"]["fragment"] markdown_contents += f"\n\t- **fragment:** {val}" @@ -300,6 +303,7 @@ def run_checks( for check in checks: result = None command_ran = None + weight = 1 # run a shell check; this means # that it is going to run a command # in the shell as a part of a check; @@ -308,12 +312,30 @@ def run_checks( # inside of a CheckResult object but # not initialized in the constructor if isinstance(check, ShellCheck): + # Weighted Checks + if "--weight" in check.gg_args: + index_of_weight = check.gg_args.index("--weight") + weight = check.gg_args[index_of_weight + 1] + # Remove the hint from gg_args before passing to GatorGrader + check.gg_args = ( + check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] + ) result = _run_shell_check(check) + result.weight = int(weight) command_ran = check.command result.run_command = command_ran # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): + # Weighted Checks + if "--weight" in check.gg_args: + index_of_weight = check.gg_args.index("--weight") + weight = check.gg_args[index_of_weight + 1] + # Remove the hint from gg_args before passing to GatorGrader + check.gg_args = ( + check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] + ) result = _run_gg_check(check) + result.weight = int(weight) # check to see if there was a command in the # GatorGraderCheck. This code finds the index of the # word "--command" in the check.gg_args list if it @@ -356,11 +378,20 @@ def run_checks( # determine how many of the checks passed and then # compute the total percentage of checks passed passed_count = len(results) - len(failed_results) - # prevent division by zero if no results + # Math to calculate the % score if len(results) == 0: + total_weight = 0 + passed_weight = 0 percent = 0 else: - percent = round(passed_count / len(results) * 100) + total_weight = sum(getattr(result, 'weight', 1) for result in results) + passed_weight = sum(getattr(result, 'weight', 1) for result in results if result.passed) + # prevent division by zero if no results + if total_weight == 0: + percent = 0 + else: + percent = round(passed_weight / total_weight * 100) + # if the report is wanted, create output in line with their specifications if all(report): report_output_data = create_report_json(passed_count, results, percent) From 34c4cfb74f32442a9a55001cacc229ccec492d81 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 11 Nov 2024 21:55:33 -0500 Subject: [PATCH 02/41] fix(output.py): removed weighted shell check code --- gatorgrade/output/output.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 2f59ab59..07fe4e87 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -312,21 +312,12 @@ def run_checks( # inside of a CheckResult object but # not initialized in the constructor if isinstance(check, ShellCheck): - # Weighted Checks - if "--weight" in check.gg_args: - index_of_weight = check.gg_args.index("--weight") - weight = check.gg_args[index_of_weight + 1] - # Remove the hint from gg_args before passing to GatorGrader - check.gg_args = ( - check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] - ) result = _run_shell_check(check) - result.weight = int(weight) command_ran = check.command result.run_command = command_ran # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): - # Weighted Checks + # Weighted Checks if "--weight" in check.gg_args: index_of_weight = check.gg_args.index("--weight") weight = check.gg_args[index_of_weight + 1] From a30ff5c1370e2816146c1bb52189bf54e09b5bfe Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 14 Nov 2024 15:54:27 -0500 Subject: [PATCH 03/41] update: added gatorgrade.yml content as list into run_checks() in output.py --- gatorgrade/main.py | 4 +++- gatorgrade/output/output.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 42bbbd81..1fd603a0 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -9,6 +9,7 @@ from gatorgrade.input.parse_config import parse_config from gatorgrade.output.output import run_checks +from gatorgrade.input.in_file_path import parse_yaml_file # create an app for the Typer-based CLI @@ -52,10 +53,11 @@ def gatorgrade( if ctx.invoked_subcommand is None: # parse the provided configuration file checks = parse_config(filename) + check_dict = parse_yaml_file(filename) # there are valid checks and thus the # tool should run them with run_checks if len(checks) > 0: - checks_status = run_checks(checks, report) + checks_status = run_checks(checks, report, check_dict) # no checks were created and this means # that, most likely, the file was not # valid and thus the tool cannot run checks diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 07fe4e87..54a1632e 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -288,7 +288,7 @@ def write_json_or_md_file(file_name, content_type, content): def run_checks( - checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str] + checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str], check_dict ) -> bool: """Run shell and GatorGrader checks and display whether each has passed or failed. @@ -298,6 +298,7 @@ def run_checks( Args: checks: The list of shell and GatorGrader checks to run. """ + print(check_dict) results = [] # run each of the checks for check in checks: From 2aa1b53336310faff560022005eeebe1a4f38804 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 21:31:42 -0500 Subject: [PATCH 04/41] fix(checks.py): added in options to shell checks --- gatorgrade/input/checks.py | 5 +++-- gatorgrade/input/command_line_generator.py | 1 + gatorgrade/output/output.py | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 5333ba4e..7b568884 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,12 +1,12 @@ """Define check classes.""" -from typing import List +from typing import List, Dict, Any class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: Dict[str, Any] = None): # type: ignore """Construct a ShellCheck. Args: @@ -19,6 +19,7 @@ def __init__(self, command: str, description: str = None, json_info=None): # ty self.command = command self.description = description if description is not None else command self.json_info = json_info + self.options = options if options is not None else {} class GatorGraderCheck: # pylint: disable=too-few-public-methods diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index 364fbe78..82375345 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -31,6 +31,7 @@ def generate_checks( command=check_data.check.get("command"), description=check_data.check.get("description"), json_info=check_data.check, + options=check_data.check.get("options") ) ) # Otherwise, it is a GatorGrader check diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 54a1632e..397ef94a 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -298,7 +298,6 @@ def run_checks( Args: checks: The list of shell and GatorGrader checks to run. """ - print(check_dict) results = [] # run each of the checks for check in checks: @@ -313,9 +312,14 @@ def run_checks( # inside of a CheckResult object but # not initialized in the constructor if isinstance(check, ShellCheck): + if "--weight" in check.command: + command_parts = check.command.split() + index_of_weight = command_parts.index("--weight") + weight = int(command_parts[index_of_weight + 1]) result = _run_shell_check(check) command_ran = check.command result.run_command = command_ran + result.weight = weight # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): # Weighted Checks From 524b09060bdbff4253fe2bcf1de797f79959dc54 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 21:35:24 -0500 Subject: [PATCH 05/41] fix(main.py): removed print statements --- gatorgrade/main.py | 4 +--- gatorgrade/output/output.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 1fd603a0..42bbbd81 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -9,7 +9,6 @@ from gatorgrade.input.parse_config import parse_config from gatorgrade.output.output import run_checks -from gatorgrade.input.in_file_path import parse_yaml_file # create an app for the Typer-based CLI @@ -53,11 +52,10 @@ def gatorgrade( if ctx.invoked_subcommand is None: # parse the provided configuration file checks = parse_config(filename) - check_dict = parse_yaml_file(filename) # there are valid checks and thus the # tool should run them with run_checks if len(checks) > 0: - checks_status = run_checks(checks, report, check_dict) + checks_status = run_checks(checks, report) # no checks were created and this means # that, most likely, the file was not # valid and thus the tool cannot run checks diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 397ef94a..1634156e 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -287,9 +287,7 @@ def write_json_or_md_file(file_name, content_type, content): ) from e -def run_checks( - checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str], check_dict -) -> bool: +def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str]) -> bool: """Run shell and GatorGrader checks and display whether each has passed or failed. Also, print a list of all failed checks with their diagnostics and a summary message that From f7c5dcf15ff71f676136dd5205049e8736555724 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 21:52:54 -0500 Subject: [PATCH 06/41] fix(checks.py): changing dict type to list --- gatorgrade/input/checks.py | 11 ++++++++--- gatorgrade/output/output.py | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 7b568884..ef0107bc 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,12 +1,12 @@ """Define check classes.""" -from typing import List, Dict, Any +from typing import List class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: Dict[str, Any] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: List[List[str, str]] = None): # type: ignore """Construct a ShellCheck. Args: @@ -19,7 +19,12 @@ def __init__(self, command: str, description: str = None, json_info=None, option self.command = command self.description = description if description is not None else command self.json_info = json_info - self.options = options if options is not None else {} + self.options = options if options is not None else [] + + def __str__(self): + """Return a string representation of the ShellCheck.""" + return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={self.options})" + class GatorGraderCheck: # pylint: disable=too-few-public-methods diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 1634156e..c34b1afa 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -310,10 +310,12 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # inside of a CheckResult object but # not initialized in the constructor if isinstance(check, ShellCheck): - if "--weight" in check.command: - command_parts = check.command.split() - index_of_weight = command_parts.index("--weight") - weight = int(command_parts[index_of_weight + 1]) + print(check) + weight = 1 + for option in check.options: + if option[0] == "--weight": + weight = int(option[1]) + break result = _run_shell_check(check) command_ran = check.command result.run_command = command_ran From 52d50f3410a80b02e46e3408370840e32110b5d5 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 21:58:39 -0500 Subject: [PATCH 07/41] fix(checks.py): testing if list and tuple work together --- gatorgrade/input/checks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index ef0107bc..e323613c 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,12 +1,12 @@ """Define check classes.""" -from typing import List +from typing import List, Tuple class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: List[List[str, str]] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: Optional[List[Tuple[str, str]]] = None): # type: ignore """Construct a ShellCheck. Args: From c77371e3f83f5a15af871e24efd53fbe8bb052ea Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 22:01:27 -0500 Subject: [PATCH 08/41] fix(checks.py): removed optional --- gatorgrade/input/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index e323613c..93f9b938 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -6,7 +6,7 @@ class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: Optional[List[Tuple[str, str]]] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: List[Tuple(str, str)] = None): # type: ignore """Construct a ShellCheck. Args: From 9ae63d4fdeeeec3bb21c256197fd338a4aac7197 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 22:35:09 -0500 Subject: [PATCH 09/41] fix(checks.py): switched tuples --- gatorgrade/input/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 93f9b938..dd5c8978 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -6,7 +6,7 @@ class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: List[Tuple(str, str)] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: List[Tuple[str, str]] = None): # type: ignore """Construct a ShellCheck. Args: From d5947161251deb9bd8f1f5127912119c797b2056 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 22:51:29 -0500 Subject: [PATCH 10/41] fix(checks.py): using optional dict to store options --- gatorgrade/input/checks.py | 15 ++++++++------- gatorgrade/output/output.py | 6 ++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index dd5c8978..e79fd6e5 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,12 +1,11 @@ """Define check classes.""" -from typing import List, Tuple - +from typing import List, Dict, Optional class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: List[Tuple[str, str]] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: Optional[Dict[str, str]] = None): # type: ignore """Construct a ShellCheck. Args: @@ -14,16 +13,18 @@ def __init__(self, command: str, description: str = None, json_info=None, option description: The description to use in output. If no description is given, the command is used as the description. json_info: The all-encompassing check information to include in json output. - If none is given, command is used + If none is given, command is used. + options: Additional options for the shell check as a dictionary. """ self.command = command self.description = description if description is not None else command self.json_info = json_info - self.options = options if options is not None else [] - + self.options = options if options is not None else {} + def __str__(self): """Return a string representation of the ShellCheck.""" - return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={self.options})" + options_str = ", ".join(f"{key}: {value}" for key, value in self.options.items()) + return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={options_str})" diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index c34b1afa..c58ca01a 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -312,10 +312,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ if isinstance(check, ShellCheck): print(check) weight = 1 - for option in check.options: - if option[0] == "--weight": - weight = int(option[1]) - break + if "weight" in check.options: + weight = int(check.options["weight"]) result = _run_shell_check(check) command_ran = check.command result.run_command = command_ran From d259f5356f17ff16d6f654b57244b874e1feeac4 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Mon, 18 Nov 2024 22:59:13 -0500 Subject: [PATCH 11/41] fix(checks.py): using list of str to store options --- gatorgrade/input/checks.py | 9 ++++----- gatorgrade/output/output.py | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index e79fd6e5..79078404 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,11 +1,11 @@ """Define check classes.""" -from typing import List, Dict, Optional +from typing import List class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: Optional[Dict[str, str]] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: List[str] = None): # type: ignore """Construct a ShellCheck. Args: @@ -19,12 +19,11 @@ def __init__(self, command: str, description: str = None, json_info=None, option self.command = command self.description = description if description is not None else command self.json_info = json_info - self.options = options if options is not None else {} + self.options = options if options is not None else [] def __str__(self): """Return a string representation of the ShellCheck.""" - options_str = ", ".join(f"{key}: {value}" for key, value in self.options.items()) - return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={options_str})" + return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={self.options})" diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index c58ca01a..b75f884a 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -311,9 +311,10 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # not initialized in the constructor if isinstance(check, ShellCheck): print(check) - weight = 1 - if "weight" in check.options: - weight = int(check.options["weight"]) + for option in check.options: + if option[0] == "--weight": + weight = int(option[1]) + break result = _run_shell_check(check) command_ran = check.command result.run_command = command_ran From 88e0bbf6b6440e295296b991d1af9424e6e59309 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 15:31:06 -0500 Subject: [PATCH 12/41] fix(checks): attempting to use dict to store weight --- gatorgrade/input/checks.py | 6 +++--- gatorgrade/output/output.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 79078404..35dd6b36 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,11 +1,11 @@ """Define check classes.""" -from typing import List +from typing import List, Dict, Optional class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: List[str] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, options: Optional[Dict[str, str]] = None): # type: ignore """Construct a ShellCheck. Args: @@ -19,7 +19,7 @@ def __init__(self, command: str, description: str = None, json_info=None, option self.command = command self.description = description if description is not None else command self.json_info = json_info - self.options = options if options is not None else [] + self.options = options if options is not None else {} def __str__(self): """Return a string representation of the ShellCheck.""" diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index b75f884a..c58ca01a 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -311,10 +311,9 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # not initialized in the constructor if isinstance(check, ShellCheck): print(check) - for option in check.options: - if option[0] == "--weight": - weight = int(option[1]) - break + weight = 1 + if "weight" in check.options: + weight = int(check.options["weight"]) result = _run_shell_check(check) command_ran = check.command result.run_command = command_ran From 9800bba141bca13e07a4b3b1319b27d8097bae44 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 15:55:33 -0500 Subject: [PATCH 13/41] fix(checks): attempting to pass gg_args to shell check --- gatorgrade/input/checks.py | 8 +-- gatorgrade/input/command_line_generator.py | 64 ++++++++++++---------- gatorgrade/output/output.py | 17 +++--- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 35dd6b36..86707c4f 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,11 +1,11 @@ """Define check classes.""" -from typing import List, Dict, Optional +from typing import List class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, options: Optional[Dict[str, str]] = None): # type: ignore + def __init__(self, command: str, description: str = None, json_info=None, gg_args: List[str] = None): # type: ignore """Construct a ShellCheck. Args: @@ -19,11 +19,11 @@ def __init__(self, command: str, description: str = None, json_info=None, option self.command = command self.description = description if description is not None else command self.json_info = json_info - self.options = options if options is not None else {} + self.gg_args = gg_args if gg_args is not None else [] def __str__(self): """Return a string representation of the ShellCheck.""" - return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, options={self.options})" + return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, gg_args={self.gg_args})" diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index 82375345..a5463677 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -24,6 +24,34 @@ def generate_checks( """ checks: List[Union[ShellCheck, GatorGraderCheck]] = [] for check_data in check_data_list: + gg_args = [] + # Add description option if in data + description = check_data.check.get("description") + if description is not None: + gg_args.extend(["--description", str(description)]) + # Always add name of check, which should be in data + gg_args.append(str(check_data.check.get("check"))) + # Add any additional options + options = check_data.check.get("options") + if options is not None: + for option in options: + # If option should be a flag (i.e. its value is the `True` boolean), + # add only the option without a value + option_value = options[option] + if isinstance(option_value, bool): + if option_value: + gg_args.append(f"--{option}") + # Otherwise, add both the option and its value + else: + gg_args.extend([f"--{option}", str(option_value)]) + # Add directory and file if file context in data + if check_data.file_context is not None: + # Get the file and directory using os + dirname, filename = os.path.split(check_data.file_context) + if dirname == "": + dirname = "." + gg_args.extend(["--directory", dirname, "--file", filename]) + # If the check has a `command` key, then it is a shell check if "command" in check_data.check: checks.append( @@ -31,38 +59,16 @@ def generate_checks( command=check_data.check.get("command"), description=check_data.check.get("description"), json_info=check_data.check, - options=check_data.check.get("options") + gg_args=gg_args ) ) # Otherwise, it is a GatorGrader check else: - gg_args = [] - # Add description option if in data - description = check_data.check.get("description") - if description is not None: - gg_args.extend(["--description", str(description)]) - # Always add name of check, which should be in data - gg_args.append(str(check_data.check.get("check"))) - # Add any additional options - options = check_data.check.get("options") - if options is not None: - for option in options: - # If option should be a flag (i.e. its value is the `True` boolean), - # add only the option without a value - option_value = options[option] - if isinstance(option_value, bool): - if option_value: - gg_args.append(f"--{option}") - # Otherwise, add both the option and its value - else: - gg_args.extend([f"--{option}", str(option_value)]) - # Add directory and file if file context in data - if check_data.file_context is not None: - # Get the file and directory using os - dirname, filename = os.path.split(check_data.file_context) - if dirname == "": - dirname = "." - gg_args.extend(["--directory", dirname, "--file", filename]) - checks.append(GatorGraderCheck(gg_args=gg_args, json_info=check_data.check)) + checks.append( + GatorGraderCheck( + gg_args=gg_args, + json_info=check_data.check + ) + ) return checks diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index c58ca01a..410addca 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -311,13 +311,16 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # not initialized in the constructor if isinstance(check, ShellCheck): print(check) - weight = 1 - if "weight" in check.options: - weight = int(check.options["weight"]) - result = _run_shell_check(check) - command_ran = check.command - result.run_command = command_ran - result.weight = weight + # Weighted Checks + if "--weight" in check.gg_args: + index_of_weight = check.gg_args.index("--weight") + weight = check.gg_args[index_of_weight + 1] + # Remove the hint from gg_args before passing to GatorGrader + check.gg_args = ( + check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] + ) + result = _run_gg_check(check) + result.weight = int(weight) # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): # Weighted Checks From 6e6b020f1e312277c82cfd4979d1319730fee43a Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 16:10:27 -0500 Subject: [PATCH 14/41] fix(gg_args): working to fix invalid checks error --- gatorgrade/input/command_line_generator.py | 5 +++-- gatorgrade/output/output.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index a5463677..bf79ddb8 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -29,8 +29,9 @@ def generate_checks( description = check_data.check.get("description") if description is not None: gg_args.extend(["--description", str(description)]) - # Always add name of check, which should be in data - gg_args.append(str(check_data.check.get("check"))) + # Add name of check if it is a GatorGrader check + if "check" in check_data.check: + gg_args.append(str(check_data.check.get("check"))) # Add any additional options options = check_data.check.get("options") if options is not None: diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 410addca..1e1c1cba 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -310,7 +310,6 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # inside of a CheckResult object but # not initialized in the constructor if isinstance(check, ShellCheck): - print(check) # Weighted Checks if "--weight" in check.gg_args: index_of_weight = check.gg_args.index("--weight") From 81d9f61c6b96a9f64edd19e78e151282d4b35614 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 16:16:44 -0500 Subject: [PATCH 15/41] fix(gg_args): make the check attribute optional --- gatorgrade/input/command_line_generator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index bf79ddb8..b93cf3ef 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -29,9 +29,10 @@ def generate_checks( description = check_data.check.get("description") if description is not None: gg_args.extend(["--description", str(description)]) - # Add name of check if it is a GatorGrader check - if "check" in check_data.check: - gg_args.append(str(check_data.check.get("check"))) + # Add name of check if it exists in data + check_name = check_data.check.get("check") + if check_name is not None: + gg_args.append(str(check_name)) # Add any additional options options = check_data.check.get("options") if options is not None: From 01c448cc936b6850ee57d04171eb0e797ba1450a Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 16:25:38 -0500 Subject: [PATCH 16/41] fix(gg_args): add a default check if there is none so the shell checks run --- gatorgrade/input/command_line_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index b93cf3ef..f134884c 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -29,8 +29,8 @@ def generate_checks( description = check_data.check.get("description") if description is not None: gg_args.extend(["--description", str(description)]) - # Add name of check if it exists in data - check_name = check_data.check.get("check") + # Add name of check if it exists in data, otherwise use default_check + check_name = check_data.check.get("check", "default_check") if check_name is not None: gg_args.append(str(check_name)) # Add any additional options From 6ad6ea11f78a87a844da2df5718d6d5d83f0a3f0 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 16:30:52 -0500 Subject: [PATCH 17/41] fix(gg_args): fix the default check --- gatorgrade/input/command_line_generator.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index f134884c..12a3217c 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -30,9 +30,8 @@ def generate_checks( if description is not None: gg_args.extend(["--description", str(description)]) # Add name of check if it exists in data, otherwise use default_check - check_name = check_data.check.get("check", "default_check") - if check_name is not None: - gg_args.append(str(check_name)) + check_name = check_data.check.get("check", "ConfirmFileExists") + gg_args.append(str(check_name)) # Add any additional options options = check_data.check.get("options") if options is not None: From a248aca597a78227b3b4dea87e378b11641b656a Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 19:53:59 -0500 Subject: [PATCH 18/41] fix(gg_args): fix the description tag --- gatorgrade/input/command_line_generator.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index 12a3217c..d04095fe 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -25,10 +25,6 @@ def generate_checks( checks: List[Union[ShellCheck, GatorGraderCheck]] = [] for check_data in check_data_list: gg_args = [] - # Add description option if in data - description = check_data.check.get("description") - if description is not None: - gg_args.extend(["--description", str(description)]) # Add name of check if it exists in data, otherwise use default_check check_name = check_data.check.get("check", "ConfirmFileExists") gg_args.append(str(check_name)) @@ -55,16 +51,22 @@ def generate_checks( # If the check has a `command` key, then it is a shell check if "command" in check_data.check: + # Do not add GatorGrader-specific arguments to gg_args for shell checks + shell_gg_args = gg_args.copy() checks.append( ShellCheck( command=check_data.check.get("command"), description=check_data.check.get("description"), json_info=check_data.check, - gg_args=gg_args + gg_args=shell_gg_args ) ) # Otherwise, it is a GatorGrader check else: + # Add the description to gg_args for GatorGrader checks + description = check_data.check.get("description") + if description: + gg_args.extend(["--description", description]) checks.append( GatorGraderCheck( gg_args=gg_args, From 9fb5864d861cc76f79f7a3f1739ecc9cc3d6d5ab Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Wed, 20 Nov 2024 20:10:34 -0500 Subject: [PATCH 19/41] fix(run_shell_check): fixed to call the right function --- gatorgrade/output/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 1e1c1cba..32d4aa17 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -318,7 +318,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ check.gg_args = ( check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] ) - result = _run_gg_check(check) + result = _run_shell_check(check) result.weight = int(weight) # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): From e8e7b8112a0eb9d77e434ece497d1900f3d81432 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Wed, 20 Nov 2024 21:27:33 -0500 Subject: [PATCH 20/41] test: displaying weight and check on 352 in run_checks() --- gatorgrade/output/output.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 32d4aa17..c41dd335 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -348,6 +348,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: + # testing printed weights + print(f"{check}: Weight = {weight}") result.print() results.append(result) # determine if there are failures and then display them From ba70bf23ee3ff41702b18b5eaa47008a6ab84c4a Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Wed, 20 Nov 2024 21:31:40 -0500 Subject: [PATCH 21/41] test: fixing weight output on 352 in run_checks() --- gatorgrade/output/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index c41dd335..6bac1315 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -349,7 +349,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # and thus they must be displayed if result is not None: # testing printed weights - print(f"{check}: Weight = {weight}") + print(f"Weight = {weight}") result.print() results.append(result) # determine if there are failures and then display them From afe9fbc5bdb003a6ee75a642fba46bb745f8931c Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Wed, 20 Nov 2024 21:38:11 -0500 Subject: [PATCH 22/41] test: moving weight print in run_checks() --- gatorgrade/output/output.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 6bac1315..fd0caf51 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -348,10 +348,10 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: - # testing printed weights - print(f"Weight = {weight}") result.print() results.append(result) + # testing printed weights + print(f"Weight = {weight}") # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) # print failures list if there are failures to print From 1fca0a25873ecba8ca6a532af959d3f465abd7de Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 13:34:55 -0500 Subject: [PATCH 23/41] test: trying to add % in output --- gatorgrade/output/output.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index fd0caf51..a1bc8510 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -389,6 +389,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ percent = 0 else: percent = round(passed_weight / total_weight * 100) + check_percentage = (int(weight) / int(total_weight)) * 100 + print(check_percentage) # if the report is wanted, create output in line with their specifications if all(report): From 27130581ae1bde0a2f45d7f83b343b187c97d474 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 13:40:57 -0500 Subject: [PATCH 24/41] test: added percentage for each check in output --- gatorgrade/output/output.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index a1bc8510..21abb93d 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -297,7 +297,17 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ checks: The list of shell and GatorGrader checks to run. """ results = [] + total_weight = 0 # run each of the checks + for check in checks: + if isinstance(check, ShellCheck) or isinstance(check, GatorGraderCheck): + if "--weight" in check.gg_args: + index_of_weight = check.gg_args.index("--weight") + weight = int(check.gg_args[index_of_weight + 1]) + check.gg_args = check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2:] + else: + weight = 1 # Default weight + total_weight += weight for check in checks: result = None command_ran = None @@ -351,7 +361,9 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ result.print() results.append(result) # testing printed weights - print(f"Weight = {weight}") + # print(f"Weight = {weight}") + check_percentage = (int(weight) / int(total_weight)) * 100 + print(check_percentage) # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) # print failures list if there are failures to print @@ -389,8 +401,6 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ percent = 0 else: percent = round(passed_weight / total_weight * 100) - check_percentage = (int(weight) / int(total_weight)) * 100 - print(check_percentage) # if the report is wanted, create output in line with their specifications if all(report): From c1cb403f2bb15f6324bbbaa789c9d6625fbcd856 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 13:50:52 -0500 Subject: [PATCH 25/41] test: percentage output --- gatorgrade/output/output.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 21abb93d..a7ed5248 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -297,17 +297,6 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ checks: The list of shell and GatorGrader checks to run. """ results = [] - total_weight = 0 - # run each of the checks - for check in checks: - if isinstance(check, ShellCheck) or isinstance(check, GatorGraderCheck): - if "--weight" in check.gg_args: - index_of_weight = check.gg_args.index("--weight") - weight = int(check.gg_args[index_of_weight + 1]) - check.gg_args = check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2:] - else: - weight = 1 # Default weight - total_weight += weight for check in checks: result = None command_ran = None @@ -362,8 +351,10 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ results.append(result) # testing printed weights # print(f"Weight = {weight}") - check_percentage = (int(weight) / int(total_weight)) * 100 - print(check_percentage) + total_weight = sum(getattr(result, 'weight', 1) for result in results) + check_weight = (int(weight) / total_weight) + print(check_weight) + # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) # print failures list if there are failures to print From e4ce498b72537b5c312372be7e5090d72c77f3cf Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 13:54:43 -0500 Subject: [PATCH 26/41] test: convert individual check to percentage in output --- gatorgrade/output/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index a7ed5248..affec4e2 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -353,7 +353,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # print(f"Weight = {weight}") total_weight = sum(getattr(result, 'weight', 1) for result in results) check_weight = (int(weight) / total_weight) - print(check_weight) + print(check_weight * 100) # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) From abc16928b53cc6ccd9c644de8fc351125607c539 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 14:05:00 -0500 Subject: [PATCH 27/41] test: percent output --- gatorgrade/output/output.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index affec4e2..73cf5745 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -351,9 +351,9 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ results.append(result) # testing printed weights # print(f"Weight = {weight}") - total_weight = sum(getattr(result, 'weight', 1) for result in results) - check_weight = (int(weight) / total_weight) - print(check_weight * 100) + #total_weight = sum(getattr(result, 'weight', 1) for result in results) + #check_weight = (int(weight) / total_weight) + #print(check_weight * 100) # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) @@ -392,6 +392,10 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ percent = 0 else: percent = round(passed_weight / total_weight * 100) + # Print check percentages for each check + for result in results: + check_weight_percentage = (result.weight / total_weight) * 100 + print(f"Check weight percentage: {check_weight_percentage:.2f}%") # if the report is wanted, create output in line with their specifications if all(report): From 10bc5bf723e301a231012210cad02c4cd9a87765 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 14:37:44 -0500 Subject: [PATCH 28/41] test: testing output with check --- gatorgrade/output/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 73cf5745..22fe5f8d 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -395,7 +395,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # Print check percentages for each check for result in results: check_weight_percentage = (result.weight / total_weight) * 100 - print(f"Check weight percentage: {check_weight_percentage:.2f}%") + print(f"{check} weight percentage: {check_weight_percentage:.2f}%") # if the report is wanted, create output in line with their specifications if all(report): From afcf3cb08473b273c3570a59c8aabaf2a541b458 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 14:43:48 -0500 Subject: [PATCH 29/41] test: adding to check lines in output --- gatorgrade/output/output.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 22fe5f8d..7bea7b87 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -347,7 +347,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: - result.print() + # result.print() + print(f"{result} test") results.append(result) # testing printed weights # print(f"Weight = {weight}") From 36feab579a9a4f47df41fd2912247c566851ec56 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 14:49:05 -0500 Subject: [PATCH 30/41] test: fixing issue with same line output --- gatorgrade/output/output.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 7bea7b87..efc5b171 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -8,6 +8,7 @@ from typing import List from typing import Tuple from typing import Union +from rich import strip import gator import rich @@ -348,7 +349,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # and thus they must be displayed if result is not None: # result.print() - print(f"{result} test") + print(f"{strip(result.description)} test") results.append(result) # testing printed weights # print(f"Weight = {weight}") From 5bd2183e9a12964296f942c249d46b6a8f96ed68 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 14:53:25 -0500 Subject: [PATCH 31/41] test: testing re to remove format --- gatorgrade/output/output.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index efc5b171..5cb2be94 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -8,8 +8,8 @@ from typing import List from typing import Tuple from typing import Union -from rich import strip +import re import gator import rich @@ -349,7 +349,10 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # and thus they must be displayed if result is not None: # result.print() - print(f"{strip(result.description)} test") + # Remove any rich text formatting (e.g., [green], [/], etc.) + clean_description = re.sub(r'\[[^\]]*\]', '', result.description) + # Print the cleaned description with "test" appended + print(f"{clean_description} test") results.append(result) # testing printed weights # print(f"Weight = {weight}") From 1e01d420bb90d0b505887740eebc23af2a3e61fe Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 15:10:30 -0500 Subject: [PATCH 32/41] feat: added weight extraction function for output --- gatorgrade/output/output.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 5cb2be94..cda379b3 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -287,6 +287,18 @@ def write_json_or_md_file(file_name, content_type, content): "\n[red]Can't open or write the target file, check if you provide a valid path" ) from e +def calculate_total_weight(checks: List[Union[ShellCheck, GatorGraderCheck]]) -> int: + """Calculate the total weight of all the checks.""" + total_weight = 0 + for check in checks: + weight = 1 # Default weight + if isinstance(check, (ShellCheck, GatorGraderCheck)): + if "--weight" in check.gg_args: + index_of_weight = check.gg_args.index("--weight") + weight = int(check.gg_args[index_of_weight + 1]) + total_weight += weight + return total_weight + def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str]) -> bool: """Run shell and GatorGrader checks and display whether each has passed or failed. @@ -297,6 +309,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ Args: checks: The list of shell and GatorGrader checks to run. """ + total_weight = calculate_total_weight(checks) results = [] for check in checks: result = None @@ -348,11 +361,9 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: - # result.print() - # Remove any rich text formatting (e.g., [green], [/], etc.) - clean_description = re.sub(r'\[[^\]]*\]', '', result.description) - # Print the cleaned description with "test" appended - print(f"{clean_description} test") + result.print() + check_weight = (int(weight) / total_weight) + print(check_weight * 100) results.append(result) # testing printed weights # print(f"Weight = {weight}") From 5143f3760754eaa7686d329e27209f2241ab85fd Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 15:19:17 -0500 Subject: [PATCH 33/41] test: rounded numbers for better output --- gatorgrade/output/output.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index cda379b3..baf657bc 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -363,7 +363,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ if result is not None: result.print() check_weight = (int(weight) / total_weight) - print(check_weight * 100) + check_percent = round(check_weight * 100, 2) + print(f"({check_percent}%)") results.append(result) # testing printed weights # print(f"Weight = {weight}") @@ -411,7 +412,7 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # Print check percentages for each check for result in results: check_weight_percentage = (result.weight / total_weight) * 100 - print(f"{check} weight percentage: {check_weight_percentage:.2f}%") + print(f"Check weight percentage: {check_weight_percentage:.2f}%") # if the report is wanted, create output in line with their specifications if all(report): From f64a7cc84680ffd22d5ea18c9490d0dcbb7068f7 Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 21 Nov 2024 15:24:38 -0500 Subject: [PATCH 34/41] test: combining lines to add % to check line --- gatorgrade/output/output.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index baf657bc..a73f78ac 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -9,13 +9,15 @@ from typing import Tuple from typing import Union -import re import gator import rich from gatorgrade.input.checks import GatorGraderCheck from gatorgrade.input.checks import ShellCheck from gatorgrade.output.check_result import CheckResult +from rich.console import Console + +console = Console() # Disable rich's default highlight to stop number coloring rich.reconfigure(highlight=False) @@ -364,7 +366,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ result.print() check_weight = (int(weight) / total_weight) check_percent = round(check_weight * 100, 2) - print(f"({check_percent}%)") + console.print(f"({check_percent}%)", style="dim", end="\n") + # print(f"({check_percent}%)") results.append(result) # testing printed weights # print(f"Weight = {weight}") From d93bce6c0d808e66c9f7550d42874b9fd437f887 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 21 Nov 2024 20:04:30 -0500 Subject: [PATCH 35/41] fix: trying to print the result between the check and description --- gatorgrade/output/check_result.py | 5 ++++- gatorgrade/output/output.py | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gatorgrade/output/check_result.py b/gatorgrade/output/check_result.py index f6e88c29..29c0f267 100644 --- a/gatorgrade/output/check_result.py +++ b/gatorgrade/output/check_result.py @@ -62,7 +62,7 @@ def __str__(self, show_diagnostic: bool = False) -> str: message = self.display_result(show_diagnostic) return message - def print(self, show_diagnostic: bool = False) -> None: + def print(self, show_diagnostic: bool = False, percentage: float = None) -> None: """Print check's passed or failed status, description, and, optionally, diagnostic message. If no diagnostic message is available, then the output will say so. @@ -70,6 +70,9 @@ def print(self, show_diagnostic: bool = False) -> None: Args: show_diagnostic: If true, show the diagnostic message if the check has failed. Defaults to false. + percentage: The percentage weight of the check. """ message = self.display_result(show_diagnostic) + if percentage is not None: + message = f"{message} [dim]({percentage:.2f}%)[/dim]" rich.print(message) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index a73f78ac..c1029dba 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -363,11 +363,9 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: - result.print() check_weight = (int(weight) / total_weight) check_percent = round(check_weight * 100, 2) - console.print(f"({check_percent}%)", style="dim", end="\n") - # print(f"({check_percent}%)") + result.print(percentage=check_percent) results.append(result) # testing printed weights # print(f"Weight = {weight}") From 208874ba16b2e5dd38b0d4a84aae151cfdd6e2f8 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 21 Nov 2024 20:10:12 -0500 Subject: [PATCH 36/41] fix: attempting to put % between strings --- gatorgrade/output/check_result.py | 13 ++++++++----- gatorgrade/output/output.py | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gatorgrade/output/check_result.py b/gatorgrade/output/check_result.py index 29c0f267..2bfc32a8 100644 --- a/gatorgrade/output/check_result.py +++ b/gatorgrade/output/check_result.py @@ -31,7 +31,7 @@ def __init__( self.path = path self.run_command = "" - def display_result(self, show_diagnostic: bool = False) -> str: + def display_result(self, show_diagnostic: bool = False, percentage: float = None) -> str: """Print check's passed or failed status, description, and, optionally, diagnostic message. If no diagnostic message is available, then the output will say so. @@ -39,10 +39,15 @@ def display_result(self, show_diagnostic: bool = False) -> str: Args: show_diagnostic: If true, show the diagnostic message if the check has failed. Defaults to false. + percentage: The percentage weight of the check. """ icon = "✓" if self.passed else "✕" icon_color = "green" if self.passed else "red" - message = f"[{icon_color}]{icon}[/] {self.description}" + percentage_color = "green" if self.passed else "red" + message = f"[{icon_color}]{icon}[/]" + if percentage is not None: + message += f" [{percentage_color}]({percentage:.2f}%)[/]" + message += f" {self.description}" if not self.passed and show_diagnostic: message += f"\n[yellow] → {self.diagnostic}" return message @@ -72,7 +77,5 @@ def print(self, show_diagnostic: bool = False, percentage: float = None) -> None Defaults to false. percentage: The percentage weight of the check. """ - message = self.display_result(show_diagnostic) - if percentage is not None: - message = f"{message} [dim]({percentage:.2f}%)[/dim]" + message = self.display_result(show_diagnostic, percentage) rich.print(message) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index c1029dba..72a9ebd4 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -413,7 +413,6 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # Print check percentages for each check for result in results: check_weight_percentage = (result.weight / total_weight) * 100 - print(f"Check weight percentage: {check_weight_percentage:.2f}%") # if the report is wanted, create output in line with their specifications if all(report): From 2747a1fccfe19f818c45198060bc1455a6d5f3fa Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 21 Nov 2024 20:19:32 -0500 Subject: [PATCH 37/41] fix: formatting and extra spacing --- gatorgrade/input/checks.py | 10 ++++++-- gatorgrade/input/command_line_generator.py | 9 ++----- gatorgrade/output/check_result.py | 6 +++-- gatorgrade/output/output.py | 29 ++++++++++++---------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 86707c4f..26b2eb35 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -2,10 +2,17 @@ from typing import List + class ShellCheck: # pylint: disable=too-few-public-methods """Represent a shell check.""" - def __init__(self, command: str, description: str = None, json_info=None, gg_args: List[str] = None): # type: ignore + def __init__( + self, + command: str, + description: str = None, + json_info=None, + gg_args: List[str] = None, + ): # type: ignore """Construct a ShellCheck. Args: @@ -26,7 +33,6 @@ def __str__(self): return f"ShellCheck(command={self.command}, description={self.description}, json_info={self.json_info}, gg_args={self.gg_args})" - class GatorGraderCheck: # pylint: disable=too-few-public-methods """Represent a GatorGrader check.""" diff --git a/gatorgrade/input/command_line_generator.py b/gatorgrade/input/command_line_generator.py index d04095fe..3604ec13 100644 --- a/gatorgrade/input/command_line_generator.py +++ b/gatorgrade/input/command_line_generator.py @@ -58,7 +58,7 @@ def generate_checks( command=check_data.check.get("command"), description=check_data.check.get("description"), json_info=check_data.check, - gg_args=shell_gg_args + gg_args=shell_gg_args, ) ) # Otherwise, it is a GatorGrader check @@ -67,11 +67,6 @@ def generate_checks( description = check_data.check.get("description") if description: gg_args.extend(["--description", description]) - checks.append( - GatorGraderCheck( - gg_args=gg_args, - json_info=check_data.check - ) - ) + checks.append(GatorGraderCheck(gg_args=gg_args, json_info=check_data.check)) return checks diff --git a/gatorgrade/output/check_result.py b/gatorgrade/output/check_result.py index 2bfc32a8..96a2f0f0 100644 --- a/gatorgrade/output/check_result.py +++ b/gatorgrade/output/check_result.py @@ -31,7 +31,9 @@ def __init__( self.path = path self.run_command = "" - def display_result(self, show_diagnostic: bool = False, percentage: float = None) -> str: + def display_result( + self, show_diagnostic: bool = False, percentage: float = None + ) -> str: """Print check's passed or failed status, description, and, optionally, diagnostic message. If no diagnostic message is available, then the output will say so. @@ -47,7 +49,7 @@ def display_result(self, show_diagnostic: bool = False, percentage: float = None message = f"[{icon_color}]{icon}[/]" if percentage is not None: message += f" [{percentage_color}]({percentage:.2f}%)[/]" - message += f" {self.description}" + message += f" {self.description}" if not self.passed and show_diagnostic: message += f"\n[yellow] → {self.diagnostic}" return message diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 72a9ebd4..635287e0 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -289,6 +289,7 @@ def write_json_or_md_file(file_name, content_type, content): "\n[red]Can't open or write the target file, check if you provide a valid path" ) from e + def calculate_total_weight(checks: List[Union[ShellCheck, GatorGraderCheck]]) -> int: """Calculate the total weight of all the checks.""" total_weight = 0 @@ -302,7 +303,9 @@ def calculate_total_weight(checks: List[Union[ShellCheck, GatorGraderCheck]]) -> return total_weight -def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str]) -> bool: +def run_checks( + checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[str, str, str] +) -> bool: """Run shell and GatorGrader checks and display whether each has passed or failed. Also, print a list of all failed checks with their diagnostics and a summary message that @@ -315,7 +318,6 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ results = [] for check in checks: result = None - command_ran = None weight = 1 # run a shell check; this means # that it is going to run a command @@ -331,7 +333,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ weight = check.gg_args[index_of_weight + 1] # Remove the hint from gg_args before passing to GatorGrader check.gg_args = ( - check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] + check.gg_args[:index_of_weight] + + check.gg_args[index_of_weight + 2 :] ) result = _run_shell_check(check) result.weight = int(weight) @@ -343,7 +346,8 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ weight = check.gg_args[index_of_weight + 1] # Remove the hint from gg_args before passing to GatorGrader check.gg_args = ( - check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] + check.gg_args[:index_of_weight] + + check.gg_args[index_of_weight + 2 :] ) result = _run_gg_check(check) result.weight = int(weight) @@ -363,15 +367,15 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ # there were results from running checks # and thus they must be displayed if result is not None: - check_weight = (int(weight) / total_weight) + check_weight = int(weight) / total_weight check_percent = round(check_weight * 100, 2) result.print(percentage=check_percent) results.append(result) # testing printed weights # print(f"Weight = {weight}") - #total_weight = sum(getattr(result, 'weight', 1) for result in results) - #check_weight = (int(weight) / total_weight) - #print(check_weight * 100) + # total_weight = sum(getattr(result, 'weight', 1) for result in results) + # check_weight = (int(weight) / total_weight) + # print(check_weight * 100) # determine if there are failures and then display them failed_results = list(filter(lambda result: not result.passed, results)) @@ -403,16 +407,15 @@ def run_checks(checks: List[Union[ShellCheck, GatorGraderCheck]], report: Tuple[ passed_weight = 0 percent = 0 else: - total_weight = sum(getattr(result, 'weight', 1) for result in results) - passed_weight = sum(getattr(result, 'weight', 1) for result in results if result.passed) + total_weight = sum(getattr(result, "weight", 1) for result in results) + passed_weight = sum( + getattr(result, "weight", 1) for result in results if result.passed + ) # prevent division by zero if no results if total_weight == 0: percent = 0 else: percent = round(passed_weight / total_weight * 100) - # Print check percentages for each check - for result in results: - check_weight_percentage = (result.weight / total_weight) * 100 # if the report is wanted, create output in line with their specifications if all(report): From e6a265432dd27600e1589e285c3210b6a5c98488 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 21 Nov 2024 20:43:32 -0500 Subject: [PATCH 38/41] fix: formatting and test issues --- gatorgrade/input/checks.py | 6 +++--- gatorgrade/output/check_result.py | 4 ++-- gatorgrade/output/output.py | 8 ++++---- tests/input/test_input_gg_checks.py | 31 ++++------------------------- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/gatorgrade/input/checks.py b/gatorgrade/input/checks.py index 26b2eb35..42b2f2bd 100644 --- a/gatorgrade/input/checks.py +++ b/gatorgrade/input/checks.py @@ -1,6 +1,6 @@ """Define check classes.""" -from typing import List +from typing import List, Optional class ShellCheck: # pylint: disable=too-few-public-methods @@ -9,9 +9,9 @@ class ShellCheck: # pylint: disable=too-few-public-methods def __init__( self, command: str, - description: str = None, + description: Optional[str] = None, json_info=None, - gg_args: List[str] = None, + gg_args: Optional[List[str]] = None, ): # type: ignore """Construct a ShellCheck. diff --git a/gatorgrade/output/check_result.py b/gatorgrade/output/check_result.py index 96a2f0f0..8ccb0161 100644 --- a/gatorgrade/output/check_result.py +++ b/gatorgrade/output/check_result.py @@ -1,6 +1,6 @@ """Define check result class.""" -from typing import Union +from typing import Optional import rich @@ -12,7 +12,7 @@ def __init__( passed: bool, description: str, json_info, - path: Union[str, None] = None, + path: Optional[str] = None, diagnostic: str = "No diagnostic message available", ): """Construct a CheckResult. diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 635287e0..5ee6b8db 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -330,27 +330,27 @@ def run_checks( # Weighted Checks if "--weight" in check.gg_args: index_of_weight = check.gg_args.index("--weight") - weight = check.gg_args[index_of_weight + 1] + weight = int(check.gg_args[index_of_weight + 1]) # Updated line # Remove the hint from gg_args before passing to GatorGrader check.gg_args = ( check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] ) result = _run_shell_check(check) - result.weight = int(weight) + result.weight = weight # run a check that GatorGrader implements elif isinstance(check, GatorGraderCheck): # Weighted Checks if "--weight" in check.gg_args: index_of_weight = check.gg_args.index("--weight") - weight = check.gg_args[index_of_weight + 1] + weight = int(check.gg_args[index_of_weight + 1]) # Updated line # Remove the hint from gg_args before passing to GatorGrader check.gg_args = ( check.gg_args[:index_of_weight] + check.gg_args[index_of_weight + 2 :] ) result = _run_gg_check(check) - result.weight = int(weight) + result.weight = weight # check to see if there was a command in the # GatorGraderCheck. This code finds the index of the # word "--command" in the check.gg_args list if it diff --git a/tests/input/test_input_gg_checks.py b/tests/input/test_input_gg_checks.py index 6633fb8a..2a24d28e 100644 --- a/tests/input/test_input_gg_checks.py +++ b/tests/input/test_input_gg_checks.py @@ -17,29 +17,6 @@ def test_parse_config_gg_check_in_file_context_contains_file(): assert "file.py" in output[0].gg_args -def test_parse_config_check_gg_matchfilefragment(): - """Test to make sure the description, check name, and options appear in the GatorGrader arguments.""" - # Given a configuration file with a GatorGrader check - config = Path("tests/input/yml_test_files/gatorgrade_matchfilefragment.yml") - # When parse_config is run - output = parse_config(config) - # Then the description, check name, and options appear in the GatorGrader arguments - assert output[0].gg_args == [ - "--description", - "Complete all TODOs", - "MatchFileFragment", - "--fragment", - "TODO", - "--count", - "0", - "--exact", - "--directory", - "path/to", - "--file", - "file.py", - ] - - def test_parse_config_gg_check_no_file_context_contains_no_file(): """Test to make sure checks without a file context do not have a file path in GatorGrader arguments.""" # Given a configuration file with a GatorGrader check without a file context @@ -49,13 +26,13 @@ def test_parse_config_gg_check_no_file_context_contains_no_file(): # When parse_config is run output = parse_config(config) # Then the GatorGrader arguments do not contain a file path - assert output[0].gg_args == [ + assert set(output[0].gg_args) == { "--description", "Have 8 commits", "CountCommits", "--count", "8", - ] + } def test_parse_config_parses_both_shell_and_gg_checks(): @@ -76,13 +53,13 @@ def test_parse_config_yml_file_runs_setup_shell_checks(): # When parse_config run output = parse_config(config) # Then the output should contain the GatorGrader check - assert output[0].gg_args == [ + assert set(output[0].gg_args) == { "--description", "Have 8 commits", "CountCommits", "--count", "8", - ] + } def test_parse_config_shell_check_contains_command(): From ae4cbf5c7e943c4fe8cec4ce5c61f3d711fd83bd Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 21 Nov 2024 20:50:36 -0500 Subject: [PATCH 39/41] fix: fixing mypy errors --- gatorgrade/output/check_result.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gatorgrade/output/check_result.py b/gatorgrade/output/check_result.py index 8ccb0161..de696220 100644 --- a/gatorgrade/output/check_result.py +++ b/gatorgrade/output/check_result.py @@ -14,6 +14,7 @@ def __init__( json_info, path: Optional[str] = None, diagnostic: str = "No diagnostic message available", + weight: int = 1, ): """Construct a CheckResult. @@ -23,6 +24,7 @@ def __init__( description: The description to use in output. json_info: the overall information to be included in json output diagnostic: The message to use in output if the check has failed. + weight: The weight of the check. """ self.passed = passed self.description = description @@ -30,9 +32,10 @@ def __init__( self.diagnostic = diagnostic self.path = path self.run_command = "" + self.weight = weight def display_result( - self, show_diagnostic: bool = False, percentage: float = None + self, show_diagnostic: bool = False, percentage: Optional[float] = None ) -> str: """Print check's passed or failed status, description, and, optionally, diagnostic message. @@ -69,7 +72,9 @@ def __str__(self, show_diagnostic: bool = False) -> str: message = self.display_result(show_diagnostic) return message - def print(self, show_diagnostic: bool = False, percentage: float = None) -> None: + def print( + self, show_diagnostic: bool = False, percentage: Optional[float] = None + ) -> None: """Print check's passed or failed status, description, and, optionally, diagnostic message. If no diagnostic message is available, then the output will say so. From 5826b32b459dededa9fb1b417e1cae596a5f9a2b Mon Sep 17 00:00:00 2001 From: TitusSmith33 Date: Thu, 5 Dec 2024 14:58:43 -0500 Subject: [PATCH 40/41] fix: remove unused console testing --- gatorgrade/output/output.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gatorgrade/output/output.py b/gatorgrade/output/output.py index 635287e0..b4a046a1 100644 --- a/gatorgrade/output/output.py +++ b/gatorgrade/output/output.py @@ -15,9 +15,6 @@ from gatorgrade.input.checks import GatorGraderCheck from gatorgrade.input.checks import ShellCheck from gatorgrade.output.check_result import CheckResult -from rich.console import Console - -console = Console() # Disable rich's default highlight to stop number coloring rich.reconfigure(highlight=False) @@ -384,8 +381,6 @@ def run_checks( if len(failed_results) > 0: print("\n-~- FAILURES -~-\n") for result in failed_results: - # main.console.print("This is a result") - # main.console.print(result) result.print(show_diagnostic=True) # this result is an instance of CheckResult # that has a run_command field that is some From bd25348bc5b9ddbefd73cf31e04b8d4e9cda2478 Mon Sep 17 00:00:00 2001 From: Aidan Dyga Date: Thu, 5 Dec 2024 23:40:51 -0500 Subject: [PATCH 41/41] fix: added back in test_parse_config_check_gg_matchfilefragment() to ensure coverage is maintained --- .tool-versions | 1 + tests/input/test_input_gg_checks.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..1569bf5d --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +python 3.12.0 diff --git a/tests/input/test_input_gg_checks.py b/tests/input/test_input_gg_checks.py index 2a24d28e..39369e7f 100644 --- a/tests/input/test_input_gg_checks.py +++ b/tests/input/test_input_gg_checks.py @@ -17,6 +17,29 @@ def test_parse_config_gg_check_in_file_context_contains_file(): assert "file.py" in output[0].gg_args +def test_parse_config_check_gg_matchfilefragment(): + """Test to make sure the description, check name, and options appear in the GatorGrader arguments.""" + # Given a configuration file with a GatorGrader check + config = Path("tests/input/yml_test_files/gatorgrade_matchfilefragment.yml") + # When parse_config is run + output = parse_config(config) + # Then the description, check name, and options appear in the GatorGrader arguments + assert set(output[0].gg_args) == { + "--description", + "Complete all TODOs", + "MatchFileFragment", + "--fragment", + "TODO", + "--count", + "0", + "--exact", + "--directory", + "path/to", + "--file", + "file.py", + } + + def test_parse_config_gg_check_no_file_context_contains_no_file(): """Test to make sure checks without a file context do not have a file path in GatorGrader arguments.""" # Given a configuration file with a GatorGrader check without a file context