Proposed fix for Issue #22, create new directory if the directory passed into the --mutantDir flag does not exists.#42
Open
Ethan-Heimer wants to merge 7 commits intoagroce:masterfrom
Open
Conversation
added 7 commits
March 21, 2026 22:57
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes in this PR
Given the discussion under Issue #22, this proposes a fix that will create the missing directory if the directory passed into the flag
--mutantDirdoes not exist. The code changes proposed occur after the--mutantDirflag has been parsed in thegenmutants.pyfile, where after the--mutantDirflag has been removed from theargslist, the following is ran to ensure the directory is created safely.Should an exception be raised while creating the missing directory, the program exits a bit more gracefully, with an error printed for the user, without leading into a crash later on in the program.
Changes have be made to the documentation printed by the
--helpflag was changed to reflect this new behavior by--mutantDiras well.Decisions made
It was ultimately decided that checking if the directory existed immediately after the the
--mutantDirflag was parsed was the best place for this check to happen. Code below this point tends to assume that the directory passed into--mutantDirexists, but that false assumption is what caused the crash to occur in the first place. Adding the check and creation guard at the earliest possible point where it would make since to do so allows the code following the parsing of--mutantDirto operate in with this assumption safely.New Features
In issue #22, you made a point that users could be reliant on the previous behavior. To account for this, I've proposed a solution that adds a new flag named
--legacyMutantDir. When this flag is used, the program skips checking to see of the directory passed into--mutantDirexists, therefore simulating the old--mutantDirbehavior for users who might need it.This also includes the proper documentation printed by the
--helpflag to explain the use-case of--legacyMutantDir.Testing
The unit tests for this change can be found in
/tests/mutantDir_tests.pyand tests for the following:Thank you for your time!
This is a submission to the final project for CS386. Group: Ethan Heimer and Ryan Menaugh. No AI was used to generate any code, and all tests passed on MacOS.