Skip to content

Commit 3923edb

Browse files
committed
fix indentation issue
1 parent 32249ba commit 3923edb

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/mutahunter/core/hunter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ def process_test_result(self, result: Any, mutant: Mutant) -> None:
243243
error_output = result.stderr + result.stdout.lower()
244244
mutant.error_msg = error_output
245245
mutant.status = "KILLED"
246-
elif result.returncode == 2:
247-
self.logger.info(f"⏱️ Mutant {mutant.id} timed out ⏱️\n")
248-
mutant.error_msg = result.stderr
249-
mutant.status = "TIMEOUT"
250246
else:
251247
error_output = result.stderr + result.stdout
252248
self.logger.info(f"🔧 Mutant {mutant.id} caused a compile error 🔧\n")

src/mutahunter/core/mutator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,22 @@ def generate(self):
181181
temp_lines = original_lines.copy()
182182
# check if the temp_lines[i] ends with a newline character
183183
if temp_lines[i].endswith("\n"):
184+
# get indentation of the original line
185+
indentation_space = len(temp_lines[i]) - len(
186+
temp_lines[i].lstrip()
187+
)
188+
# add the indentation to the mutated line after lstripping
189+
mutated_line = " " * indentation_space + mutated_line.lstrip()
184190
temp_lines[i] = mutated_line + "\n"
185191
# updated change dict
186192
change["mutant_code"] = "".join(temp_lines)
187193
else:
194+
# get indentation of the original line
195+
indentation_space = len(temp_lines[i]) - len(
196+
temp_lines[i].lstrip()
197+
)
198+
# add the indentation to the mutated line after lstripping
199+
mutated_line = " " * indentation_space + mutated_line.lstrip()
188200
temp_lines[i] = mutated_line
189201
change["mutant_code"] = "".join(temp_lines)
190202
break

src/mutahunter/core/prompts/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Mutants(BaseModel):
2121
2222
## Function Block to Mutate
2323
Lines Covered: {{covered_lines}}. Only mutate lines that are covered by execution.
24-
Note that we have manually added line numbers for each line of code. Do not include line numbers in your mutation.
24+
Note that we have manually added line numbers for each line of code. Do not include line numbers in your mutation. Make sure indentation is preserverd when generating mutants.
2525
```{{language}}
2626
{{function_block}}
2727
```

0 commit comments

Comments
 (0)