<commit_before># Quickstart with Bazel

This tutorial describes how to set up your development environment with Bazel as
the build system, and how to get a simple fuzz test up and running. We recommend
this tutorial if you're new to FuzzTest or if you need a quick refresher. For a
more extensive showcase of the FuzzTest framework, consider doing the
[Codelab](tutorial.md).

## Prerequisites

To use FuzzTest, you'll need:

*   A Linux-based operating system
*   [Clang](https://clang.llvm.org/)
*   [Bazel](https://bazel.build/)

## Set up a Bazel workspace

First, create a directory where your project will reside:

```sh
$ mkdir -p my_workspace && cd my_workspace
```

In this directory, create a file named `WORKSPACE` to define a
[Bazel workspace](https://bazel.build/concepts/build-ref#workspace). The file
will configure FuzzTest along with its transitive dependencies as Bazel external
dependencies:

```
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

################################################################################
# Direct dependencies
################################################################################

git_repository(
    name = "com_google_fuzztest",
    # To use the latest version of FuzzTest, update this regularly to the latest
    # commit in the main branch: https://github.com/google/fuzztest/commits/main
    commit = "62cf00c7341eb05d128d0a3cbce79ac31dbda032",
    remote = "https://github.com/google/fuzztest.git",
)

http_archive(
    name = "com_google_googletest",
    sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
    strip_prefix = "googletest-release-1.12.1",
    url = "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
)

################################################################################
# Transitive dependencies
################################################################################

# Required by com_google_fuzztest.
http_archive(
    name = "com_googlesource_code_re2",
    sha256 = "f89c61410a072e5cbcf8c27e3a778da7d6fd2f2b5b1445cd4f4508bee946ab0f",
    strip_prefix = "re2-2022-06-01",
    url = "https://github.com/google/re2/archive/refs/tags/2022-06-01.tar.gz",
)

# Required by com_google_fuzztest.
http_archive(
    name = "com_google_absl",<commit_msg>Recommend using http_archive for consistency.<commit_after># Quickstart with Bazel

This tutorial describes how to set up your development environment with Bazel as
the build system, and how to get a simple fuzz test up and running. We recommend
this tutorial if you're new to FuzzTest or if you need a quick refresher. For a
more extensive showcase of the FuzzTest framework, consider doing the
[Codelab](tutorial.md).

## Prerequisites

To use FuzzTest, you'll need:

*   A Linux-based operating system
*   [Clang](https://clang.llvm.org/)
*   [Bazel](https://bazel.build/)

## Set up a Bazel workspace

First, create a directory where your project will reside:

```sh
$ mkdir -p my_workspace && cd my_workspace
```

In this directory, create a file named `WORKSPACE` to define a
[Bazel workspace](https://bazel.build/concepts/build-ref#workspace). The file
will configure FuzzTest along with its transitive dependencies as Bazel external
dependencies:

```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

################################################################################
# Direct dependencies
################################################################################

# To use the latest version of FuzzTest, update this regularly to the latest
# commit in the main branch: https://github.com/google/fuzztest/commits/main
FUZZTEST_COMMIT = "62cf00c7341eb05d128d0a3cbce79ac31dbda032"

http_archive(
    name = "com_google_fuzztest",
    strip_prefix = "fuzztest-" + FUZZTEST_COMMIT,
    url = "https://github.com/google/fuzztest/archive/" + FUZZTEST_COMMIT + ".zip",
)

http_archive(
    name = "com_google_googletest",
    sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
    strip_prefix = "googletest-release-1.12.1",
    url = "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
)

################################################################################
# Transitive dependencies
################################################################################

# Required by com_google_fuzztest.
http_archive(
    name = "com_googlesource_code_re2",
    sha256 = "f89c61410a072e5cbcf8c27e3a778da7d6fd2f2b5b1445cd4f4508bee946ab0f",
    strip_prefix = "re2-2022-06-01",
    url = "https://github.com/google/re2/archive/refs/tags/2022-06-01.tar.gz",
)

# Required by com_google_fuzztest.
http_archive(
    name = "com_google_absl",
{'fraction_non_alphanumeric': 0.2225886232481451, 'fraction_numerical': 0.053173948887056885, 'mean_word_length': 5.505361930294906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2063134', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1520, 'n_words': 366}