Many functions are language-specific for each Actions class. However, many are more general, but do not have consistent naming conventions.
In addition to the existing functions in Actions, here are the functions that all language-specific actions child classes should have:
def run_generated_test(generated_test: str, test_file: Path, overwrite=True) -> dict:
"""
param generated_test: string output from the model of a generated test suite/test case
param test_file: the path to the file where the generated test should be saved
overwrite: whether to overwrite or append the generated_test string if the test_file path already exists
"""
# save the generated test in the correct location (+correct formatting given overwrite)
# execute the test
# return the results of the test execution as a dict
def save_generated_test(generated_test: str, test_file=None: Path, overwrite=True) -> Path:
"""Saves the generated test at the correct location, with the correct formatting"""
def execute_test(test_file: Path) -> dict:
"""Given the path to the generated test, run it and return the results"""
The logic from evaluate_generated_test in scripts/test_generation_eval.py should exist in run_generated_test (but should be separated by language)
In each language class,run_generated_test should probably call 2 helper functions: save_generated_test and execute_test. Focus on JS and Python for now. C# is a bit more complicated, and Java already has a run_generated_test function. In Python, execute_test_file should be renamed to execute_test.
Javascript and Typescript Implementation Detail:
Consider adding temporary_file_content_change to plum/utils/helpers.py to use for JS/TS.
If the test framework is Mocha, you'll append the test directly to the file where the function is and run it. Then, once you've gotten the result, you'll remove the appended test.
If the test framework is Jest, you'll create a new file with the .test addendum. If your original filename was code.js, your new filename will be code.test.js, and it will be the contents of code.js with the generated test appended at the end.
All this logic is coded out in scripts/test_generation_eval.py. This is just an additional reminder
Many functions are language-specific for each Actions class. However, many are more general, but do not have consistent naming conventions. In addition to the existing functions in Actions, here are the functions that all language-specific actions child classes should have:
The logic from evaluate_generated_test in scripts/test_generation_eval.py should exist in run_generated_test (but should be separated by language)
In each language class,
run_generated_test
should probably call 2 helper functions:save_generated_test
andexecute_test
. Focus on JS and Python for now. C# is a bit more complicated, and Java already has arun_generated_test
function. In Python,execute_test_file
should be renamed toexecute_test
.Javascript and Typescript Implementation Detail:
temporary_file_content_change
to plum/utils/helpers.py to use for JS/TS.code.js
, your new filename will becode.test.js
, and it will be the contents of code.js with the generated test appended at the end.