24anisha / plum

0 stars 0 forks source link

Standardize Actions ABC #3

Closed 24anisha closed 2 weeks ago

24anisha commented 1 month ago

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: