Skip to content

sola-st/DiffTestGen

Repository files navigation

DiffTestGen: Change-Directed LLM-Based Testing for Exposing Behavioral Differences

DiffTestGen, a change-directed, LLM-based differential testing approach to expose behavioral differences introduced by code changes.

Set up

DiffTestGen uses two kinds of Docker containers:

  • A Visual Studio Code Dev Container for running DiffTestGen itself. See devcontainer.json.

  • Docker-in-docker containers for target projects to analyze with testora. These containers are created when creating the dev container. See postCreateCommands.sh.

To build the containers, follow these steps:

  1. Install Visual Studio Code and its "Dev Containers" extension.

  2. Open DiffTestGen in Visual Studio Code.

  3. In Visual Studio Code, build the Dev Container and reopen the project in the container (This will take a couple of minutes):

    Ctrl + Shift + P

    Dev Containers: Rebuild and Reopen in Container

To run DiffTestGen, create key files in the main directory:

  1. .openai_token with an OpenAI API key. This is required for invoking an LLM, which is an essential part of testora.

  2. .github_token with a (free to create) GitHub API key. This is required because DiffTestGen interacts with the GitHub API to retrieve details about the PRs to analyze.

Running DiffTestGen

Note: Since DiffTestGen is implemented on top of Testora, some implementation artifacts still retain the Testora name.

Main source file: testora.RegressionFinder. To run the main souce file, we provide two entry files (select one to run), each corresponds to a mode, database mode and local mode, respectively:

  1. [Database mode] Entry file testora.Entry allows to run in database mode, which fetches PRs to check from the database and applies the approach to each PR. The result logs will be write into the database. Assuming you have set up the database, to run it:

    python -m testora.Entry

    To check the status of PRs:

    python -m testora.evaluation.EvalTaskManager --status

    To download results:
    Once some or all PRs have been analyzed, download the results from the database:

    python -m testora.evaluation.EvalTaskManager --fetch

  2. [Local mode] Entry file testora.EntryLocal allows to run at local, without setting up the database. The result logs will be write into the root folder of this project. To run it:

    python -m testora.EntryLocal

Overall, to run DiffTestGen:

  1. We have multiple files starts with `Entry', each such `Entry'-prefix file uses a similar inner logic, but serves for a different purpose.
    • testora.Entry
      • To run DiffTestGen in database mode on Testora data.
      • Check code implementation for more detailed setting, supports running experiments for entire abaltion study or a specific configuration, e.g, DiffTestGen.
    • testora.EntryLocal
      • To run DiffTestGen at local on Testora data.
      • Also supports entire abaltion study or a specific configuration.
    • testora.EntryLocalChaCo
      • To run DiffTestGen at local on ChaCo data.
    • testora.EntryLocalClassification
      • To run classification on specified log files.
  2. Supports parallel running for these `Entry'-prefix files in different Dev Containers.

Inspecting Results in the Web UI

We provide a Web UI to inspect detailed logs.

  1. Launch the web server:

    python -m testora.webui.WebUI --files logs_*.json

  2. Visit http://localhost:4000/ in your browser.

  3. Click to inspect the detailed logs of a PR.

Results Reported in the Paper

Notes:

RQ1 Effectiveness and RQ2 Component Contributions

RQ3: Efficiency

RQ4: Usefulness

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages