Skip to content

Commit ac9787b

Browse files
authored
Merge pull request #6 from noajshu/codex/optimize-test-runtime-and-document-changes
Add configurable test modes
2 parents 14542d1 + 7174ce4 commit ac9787b

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ Tesseract uses [Bazel](https://bazel.build/) as its build system. To build the d
6969
bazel build src:all
7070
```
7171

72+
## Running Tests
73+
74+
Unit tests are executed with Bazel. Run the quick test suite using:
75+
```bash
76+
bazel test //src:all
77+
```
78+
By default the tests use reduced parameters and finish in under 30 seconds.
79+
To run a more exhaustive suite with additional shots and larger distances, set:
80+
```bash
81+
TESSERACT_LONG_TESTS=1 bazel test //src:all
82+
```
83+
84+
7285
## Usage
7386

7487
The file `tesseract_main.cc` provides the main entry point for Tesseract Decoder. It can decode

src/tesseract.test.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "tesseract.h"
1616

1717
#include <vector>
18+
#include <cstdlib>
1819

1920
#include "gtest/gtest.h"
2021
#include "simplex.h"
@@ -79,10 +80,19 @@ bool simplex_test_compare(stim::DetectorErrorModel& dem,
7980
}
8081

8182
TEST(tesseract, Tesseract_simplex_test) {
82-
for (float p_err : {0.001, 0.003, 0.005}) {
83-
for (size_t distance : {3, 5}) {
84-
for (const size_t num_rounds : {2, 5, 10}) {
85-
const size_t num_shots = 1000 / num_rounds / distance;
83+
bool long_tests = std::getenv("TESSERACT_LONG_TESTS") != nullptr;
84+
auto p_errs = long_tests ? std::vector<float>{0.001f, 0.003f, 0.005f}
85+
: std::vector<float>{0.003f};
86+
auto distances = long_tests ? std::vector<size_t>{3, 5, 7}
87+
: std::vector<size_t>{3};
88+
auto rounds = long_tests ? std::vector<size_t>{2, 5, 10}
89+
: std::vector<size_t>{2};
90+
size_t base_shots = long_tests ? 1000 : 100;
91+
92+
for (float p_err : p_errs) {
93+
for (size_t distance : distances) {
94+
for (const size_t num_rounds : rounds) {
95+
const size_t num_shots = base_shots / num_rounds / distance;
8696
std::cout << "p_err = " << p_err << " distance = " << distance
8797
<< " num_rounds = " << num_rounds
8898
<< " num_shots = " << num_shots << std::endl;

0 commit comments

Comments
 (0)