Skip to content

Commit 49f180a

Browse files
authored
Added new environment variable to tests - TESTS_SKIP_BEFORE (#4317)
1 parent ff1aaf5 commit 49f180a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

tests/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ be it `make`, `run-test.sh`, `until-fail.sh`, etc.
186186
with `TESTS=0000`.
187187
See [../src/rdunittest.c](../src/rdunittest.c) for
188188
unit test names.
189+
* `TESTS_SKIP_BEFORE=0nnn` - skip tests before this test. Tests are skipped
190+
even if they are part of `TESTS` variable.
191+
Usage: `TESTS_SKIP_BEFORE=0030`. All the tests
192+
until test 0030 are skipped.
189193

190194

191195
Let's say that you run the full test suite and get a failure in test 0061,

tests/test.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ int test_rusage = 0; /**< Check resource usage */
7777
* <1.0: CPU is faster than base line system. */
7878
double test_rusage_cpu_calibration = 1.0;
7979
static const char *tests_to_run = NULL; /* all */
80+
static const char *skip_tests_till = NULL; /* all */
8081
static const char *subtests_to_run = NULL; /* all */
8182
static const char *tests_to_skip = NULL; /* none */
8283
int test_write_report = 0; /**< Write test report file */
@@ -1341,6 +1342,13 @@ static void run_tests(int argc, char **argv) {
13411342
skip_silent = rd_true;
13421343
} else if (tests_to_skip && strstr(tests_to_skip, testnum))
13431344
skip_reason = "included in TESTS_SKIP list";
1345+
else if (skip_tests_till) {
1346+
if (!strcmp(skip_tests_till, testnum))
1347+
skip_tests_till = NULL;
1348+
else
1349+
skip_reason =
1350+
"ignoring test before TESTS_SKIP_BEFORE";
1351+
}
13441352

13451353
if (!skip_reason) {
13461354
run_test(test, argc, argv);
@@ -1666,6 +1674,8 @@ int main(int argc, char **argv) {
16661674
subtests_to_run = test_getenv("SUBTESTS", NULL);
16671675
tests_to_skip = test_getenv("TESTS_SKIP", NULL);
16681676
tmpver = test_getenv("TEST_KAFKA_VERSION", NULL);
1677+
skip_tests_till = test_getenv("TESTS_SKIP_BEFORE", NULL);
1678+
16691679
if (!tmpver)
16701680
tmpver = test_getenv("KAFKA_VERSION", test_broker_version_str);
16711681
test_broker_version_str = tmpver;
@@ -1840,11 +1850,14 @@ int main(int argc, char **argv) {
18401850
if (test_concurrent_max > 1)
18411851
test_timeout_multiplier += (double)test_concurrent_max / 3;
18421852

1843-
TEST_SAY("Tests to run : %s\n", tests_to_run ? tests_to_run : "all");
1853+
TEST_SAY("Tests to run : %s\n",
1854+
tests_to_run ? tests_to_run : "all");
18441855
if (subtests_to_run)
1845-
TEST_SAY("Sub tests : %s\n", subtests_to_run);
1856+
TEST_SAY("Sub tests : %s\n", subtests_to_run);
18461857
if (tests_to_skip)
1847-
TEST_SAY("Skip tests : %s\n", tests_to_skip);
1858+
TEST_SAY("Skip tests : %s\n", tests_to_skip);
1859+
if (skip_tests_till)
1860+
TEST_SAY("Skip tests before: %s\n", skip_tests_till);
18481861
TEST_SAY("Test mode : %s%s%s\n", test_quick ? "quick, " : "",
18491862
test_mode, test_on_ci ? ", CI" : "");
18501863
TEST_SAY("Test scenario: %s\n", test_scenario);

0 commit comments

Comments
 (0)