This repository contains the replication package of Tracto, a neuro-symbolic approach to generate concrete test oracles from Java projects.
Tracto stands for Transformer-based Concrete Test Oracle generation and reminds the sound of the italian word tratto that means line or way, which illustrates the way in which Tracto generates oracles, as if they were a line that is continuously drawn, little by little (token by token). Tracto generates oracles token by token, in a grammar-directed way, but supported by a neural module to guide the search of oracles toward optimal solutions.
./scripts/minercontains the scripts to mine the test cases after a given date, to perform experiments on unseen data, and avoid data leakeage../scripts/neural-modulecontains the scripts related to the neural module (fine-tuning and inference)../scripts/promptcontains the scripts to generate the prompts for the neural module (both for fine-tuning and inference)./scripts/symbolic-modulecontains the code related to the symbolic module.rqscontains the code and the data to replicate the experiments described in the related paper.
To set up and run the fine-tuned model and the vanilla models used in the experiments with Ollama, the following requirements must be satisfied:
Python ≥ 3.12Pip
The experiments were performed on a GPU Nvidia A-100 with 80GB of memory (vRAM) and 147GB of RAM.
In order to set up the environment is not strictly necessary, but recommended to create a venv or conda environment. In the following section we will provide the general information to configure the environment.
Follow the instructions to properly create and activate the environment
- Open a terminal and move to the
rootdirectory of the project. - Create the venv environment with
Python ≥ 3.10:The command will generate a venv environment withinpython3 -m venv .venv
.venv. - Activate the venv environment:
source .venv/bin/activate - Upgrade pip and setuptools to the latest version:
pip install --upgrade pip setuptools
Install the dependencies within the active venv environment, using the following command:
python3 -m pip install --upgrade -r requirements.txt --target=[path_to_repo]/.venv/lib/[python_version]/site-packageswhere:
path_to_repomust be substituted the absolute path to the replication package repositorypython_versionmust be substituted with the version of Python used in the environment (e.g.,python3.12)
The reader can find all the instructions to properly install and setup conda, on the official user guide.
We provide an example on how to install conda on Linux operating systems. The installation is relatively similar for macOS and Windows systems.
-
Open a terminal and type the following command to download the installer:
wget -P [path_to_destination_directory] [conda_download_http_link]
path_to_destination_directory- represents the destination path where the installer will be downloaded.conda_download_http_link- is the link of the installer. You can choose the installer here, copying the corresponding url.
-
Execute the installer:
bash [fullname_of_the_installer]
fullname_of_the_installer- is the whole name of the downloaded installer (it is a .sh file, like for example Miniconda3-py39_23.3.1-0-Linux-aarch64.sh)
-
Close and re-open the terminal at the end of the installation. Check conda has been successfully installated typing the command:
conda --version
-
Create a new conda environment named llm_prompts with Python version ≥ 3.10 and pip.
conda create --name tracto python=[python_version] pip
where:
python_versionmust be substituted with the version of Python used in the environment (e.g.,3.12)
-
Activate the conda environment
conda activate llm_prompts
-
Move to the
rootfolder of the repository -
Install all the required dependencies
pip install -r requirements.txt
-
Bash requirements
In order to run the bash scripts, the following requirements must be satisfied:
- jq
- zip
- unzip
- git