| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 98c49d8 commit a1d5209
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,12 +11,11 @@ on: | |||
| 11 | 11 | - v[0-9]+.x | |
| 12 | 12 | ||
| 13 | 13 | env: | |
| 14 | - FLAKY_TESTS: dontcare | ||
| 14 | + PYTHON_VERSION: '3.10' | ||
| 15 | + FLAKY_TESTS: keep_retrying | ||
| 15 | 16 | ||
| 16 | 17 | jobs: | |
| 17 | 18 | build-tarball: | |
| 18 | - env: | ||
| 19 | - PYTHON_VERSION: '3.10' | ||
| 20 | 19 | runs-on: ubuntu-latest | |
| 21 | 20 | steps: | |
| 22 | 21 | - uses: actions/checkout@v2 | |
@@ -71,4 +70,4 @@ jobs: | |||
| 71 | 70 | - name: Test | |
| 72 | 71 | run: | | |
| 73 | 72 | cd $TAR_DIR | |
| 74 | - make run-ci -j2 V=1 TEST_CI_ARGS="-p dots" | ||
| 73 | + make run-ci -j2 V=1 TEST_CI_ARGS="-p dots --measure-flakiness 9" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ on: | |||
| 13 | 13 | ||
| 14 | 14 | env: | |
| 15 | 15 | PYTHON_VERSION: '3.10' | |
| 16 | - FLAKY_TESTS: dontcare | ||
| 16 | + FLAKY_TESTS: keep_retrying | ||
| 17 | 17 | ||
| 18 | 18 | jobs: | |
| 19 | 19 | build-windows: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,4 +31,4 @@ jobs: | |||
| 31 | 31 | name: docs | |
| 32 | 32 | path: out/doc | |
| 33 | 33 | - name: Test | |
| 34 | - run: NODE=$(command -v node) make test-doc-ci TEST_CI_ARGS="-p actions" | ||
| 34 | + run: NODE=$(command -v node) make test-doc-ci TEST_CI_ARGS="-p actions --measure-flakiness 9" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ on: | |||
| 19 | 19 | ||
| 20 | 20 | env: | |
| 21 | 21 | PYTHON_VERSION: '3.10' | |
| 22 | - FLAKY_TESTS: dontcare | ||
| 22 | + FLAKY_TESTS: keep_retrying | ||
| 23 | 23 | ||
| 24 | 24 | jobs: | |
| 25 | 25 | test-asan: | |
@@ -40,4 +40,4 @@ jobs: | |||
| 40 | 40 | - name: Build | |
| 41 | 41 | run: make build-ci -j2 V=1 | |
| 42 | 42 | - name: Test | |
| 43 | - run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions -t 300" | ||
| 43 | + run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions -t 300 --measure-flakiness 9" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ on: | |||
| 13 | 13 | ||
| 14 | 14 | env: | |
| 15 | 15 | PYTHON_VERSION: '3.10' | |
| 16 | - FLAKY_TESTS: dontcare | ||
| 16 | + FLAKY_TESTS: keep_retrying | ||
| 17 | 17 | ||
| 18 | 18 | jobs: | |
| 19 | 19 | test-linux: | |
@@ -29,4 +29,4 @@ jobs: | |||
| 29 | 29 | - name: Build | |
| 30 | 30 | run: make build-ci -j2 V=1 CONFIG_FLAGS="--error-on-warn" | |
| 31 | 31 | - name: Test | |
| 32 | - run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions" | ||
| 32 | + run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ on: | |||
| 19 | 19 | ||
| 20 | 20 | env: | |
| 21 | 21 | PYTHON_VERSION: '3.10' | |
| 22 | - FLAKY_TESTS: dontcare | ||
| 22 | + FLAKY_TESTS: keep_retrying | ||
| 23 | 23 | ||
| 24 | 24 | jobs: | |
| 25 | 25 | test-macOS: | |
@@ -35,4 +35,4 @@ jobs: | |||
| 35 | 35 | - name: Build | |
| 36 | 36 | run: make build-ci -j2 V=1 CONFIG_FLAGS="--error-on-warn" | |
| 37 | 37 | - name: Test | |
| 38 | - run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions" | ||
| 38 | + run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,10 +96,11 @@ def get_module(name, path): | |||
| 96 | 96 | ||
| 97 | 97 | class ProgressIndicator(object): | |
| 98 | 98 | ||
| 99 | - def __init__(self, cases, flaky_tests_mode): | ||
| 99 | + def __init__(self, cases, flaky_tests_mode, measure_flakiness): | ||
| 100 | 100 | self.cases = cases | |
| 101 | 101 | self.serial_id = 0 | |
| 102 | 102 | self.flaky_tests_mode = flaky_tests_mode | |
| 103 | + self.measure_flakiness = measure_flakiness | ||
| 103 | 104 | self.parallel_queue = Queue(len(cases)) | |
| 104 | 105 | self.sequential_queue = Queue(len(cases)) | |
| 105 | 106 | for case in cases: | |
@@ -211,10 +212,22 @@ def RunSingle(self, parallel, thread_id): | |||
| 211 | 212 | if output.UnexpectedOutput(): | |
| 212 | 213 | if FLAKY in output.test.outcomes and self.flaky_tests_mode == DONTCARE: | |
| 213 | 214 | self.flaky_failed.append(output) | |
| 215 | + elif FLAKY in output.test.outcomes and self.flaky_tests_mode == KEEP_RETRYING: | ||
| 216 | + for _ in range(99): | ||
| 217 | + if not case.Run().UnexpectedOutput(): | ||
| 218 | + self.flaky_failed.append(output) | ||
| 219 | + break | ||
| 220 | + else: | ||
| 221 | + # If after 100 tries, the test is not passing, it's not flaky. | ||
| 222 | + self.failed.append(output) | ||
| 214 | 223 | else: | |
| 215 | 224 | self.failed.append(output) | |
| 216 | 225 | if output.HasCrashed(): | |
| 217 | 226 | self.crashed += 1 | |
| 227 | + if self.measure_flakiness: | ||
| 228 | + outputs = [case.Run() for _ in range(self.measure_flakiness)] | ||
| 229 | + # +1s are there because the test already failed once at this point. | ||
| 230 | + print(" failed {} out of {}".format(len([i for i in outputs if i.UnexpectedOutput()]) + 1, self.measure_flakiness + 1)) | ||
| 218 | 231 | else: | |
| 219 | 232 | self.succeeded += 1 | |
| 220 | 233 | self.remaining -= 1 | |
@@ -436,8 +449,8 @@ def Done(self): | |||
| 436 | 449 | ||
| 437 | 450 | class CompactProgressIndicator(ProgressIndicator): | |
| 438 | 451 | ||
| 439 | - def __init__(self, cases, flaky_tests_mode, templates): | ||
| 440 | - super(CompactProgressIndicator, self).__init__(cases, flaky_tests_mode) | ||
| 452 | + def __init__(self, cases, flaky_tests_mode, measure_flakiness, templates): | ||
| 453 | + super(CompactProgressIndicator, self).__init__(cases, flaky_tests_mode, measure_flakiness) | ||
| 441 | 454 | self.templates = templates | |
| 442 | 455 | self.last_status_length = 0 | |
| 443 | 456 | self.start_time = time.time() | |
@@ -492,29 +505,29 @@ def PrintProgress(self, name): | |||
| 492 | 505 | ||
| 493 | 506 | class ColorProgressIndicator(CompactProgressIndicator): | |
| 494 | 507 | ||
| 495 | - def __init__(self, cases, flaky_tests_mode): | ||
| 508 | + def __init__(self, cases, flaky_tests_mode, measure_flakiness): | ||
| 496 | 509 | templates = { | |
| 497 | 510 | 'status_line': "[%(mins)02i:%(secs)02i|\033[34m%%%(remaining) 4d\033[0m|\033[32m+%(passed) 4d\033[0m|\033[31m-%(failed) 4d\033[0m]: %(test)s", | |
| 498 | 511 | 'stdout': "\033[1m%s\033[0m", | |
| 499 | 512 | 'stderr': "\033[31m%s\033[0m", | |
| 500 | 513 | } | |
| 501 | - super(ColorProgressIndicator, self).__init__(cases, flaky_tests_mode, templates) | ||
| 514 | + super(ColorProgressIndicator, self).__init__(cases, flaky_tests_mode, measure_flakiness, templates) | ||
| 502 | 515 | ||
| 503 | 516 | def ClearLine(self, last_line_length): | |
| 504 | 517 | print("\033[1K\r", end='') | |
| 505 | 518 | ||
| 506 | 519 | ||
| 507 | 520 | class MonochromeProgressIndicator(CompactProgressIndicator): | |
| 508 | 521 | ||
| 509 | - def __init__(self, cases, flaky_tests_mode): | ||
| 522 | + def __init__(self, cases, flaky_tests_mode, measure_flakiness): | ||
| 510 | 523 | templates = { | |
| 511 | 524 | 'status_line': "[%(mins)02i:%(secs)02i|%%%(remaining) 4d|+%(passed) 4d|-%(failed) 4d]: %(test)s", | |
| 512 | 525 | 'stdout': '%s', | |
| 513 | 526 | 'stderr': '%s', | |
| 514 | 527 | 'clear': lambda last_line_length: ("\r" + (" " * last_line_length) + "\r"), | |
| 515 | 528 | 'max_length': 78 | |
| 516 | 529 | } | |
| 517 | - super(MonochromeProgressIndicator, self).__init__(cases, flaky_tests_mode, templates) | ||
| 530 | + super(MonochromeProgressIndicator, self).__init__(cases, flaky_tests_mode, measure_flakiness, templates) | ||
| 518 | 531 | ||
| 519 | 532 | def ClearLine(self, last_line_length): | |
| 520 | 533 | print(("\r" + (" " * last_line_length) + "\r"), end='') | |
@@ -946,8 +959,8 @@ def GetVm(self, arch, mode): | |||
| 946 | 959 | def GetTimeout(self, mode): | |
| 947 | 960 | return self.timeout * TIMEOUT_SCALEFACTOR[ARCH_GUESS or 'ia32'][mode] | |
| 948 | 961 | ||
| 949 | - def RunTestCases(cases_to_run, progress, tasks, flaky_tests_mode): | ||
| 950 | - progress = PROGRESS_INDICATORS[progress](cases_to_run, flaky_tests_mode) | ||
| 962 | + def RunTestCases(cases_to_run, progress, tasks, flaky_tests_mode, measure_flakiness): | ||
| 963 | + progress = PROGRESS_INDICATORS[progress](cases_to_run, flaky_tests_mode, measure_flakiness) | ||
| 951 | 964 | return progress.Run(tasks) | |
| 952 | 965 | ||
| 953 | 966 | # ------------------------------------------- | |
@@ -965,6 +978,7 @@ def RunTestCases(cases_to_run, progress, tasks, flaky_tests_mode): | |||
| 965 | 978 | SLOW = 'slow' | |
| 966 | 979 | FLAKY = 'flaky' | |
| 967 | 980 | DONTCARE = 'dontcare' | |
| 981 | + KEEP_RETRYING = 'keep_retrying' | ||
| 968 | 982 | ||
| 969 | 983 | class Expression(object): | |
| 970 | 984 | pass | |
@@ -1353,8 +1367,11 @@ def BuildOptions(): | |||
| 1353 | 1367 | result.add_option("--cat", help="Print the source of the tests", | |
| 1354 | 1368 | default=False, action="store_true") | |
| 1355 | 1369 | result.add_option("--flaky-tests", | |
| 1356 | - help="Regard tests marked as flaky (run|skip|dontcare)", | ||
| 1370 | + help="Regard tests marked as flaky (run|skip|dontcare|keep_retrying)", | ||
| 1357 | 1371 | default="run") | |
| 1372 | + result.add_option("--measure-flakiness", | ||
| 1373 | + help="When a test fails, re-run it x number of times", | ||
| 1374 | + default=0, type="int") | ||
| 1358 | 1375 | result.add_option("--skip-tests", | |
| 1359 | 1376 | help="Tests that should not be executed (comma-separated)", | |
| 1360 | 1377 | default="") | |
@@ -1426,7 +1443,7 @@ def ProcessOptions(options): | |||
| 1426 | 1443 | # tends to exaggerate the number of available cpus/cores. | |
| 1427 | 1444 | cores = os.environ.get('JOBS') | |
| 1428 | 1445 | options.j = int(cores) if cores is not None else multiprocessing.cpu_count() | |
| 1429 | - if options.flaky_tests not in [RUN, SKIP, DONTCARE]: | ||
| 1446 | + if options.flaky_tests not in [RUN, SKIP, DONTCARE, KEEP_RETRYING]: | ||
| 1430 | 1447 | print("Unknown flaky-tests mode %s" % options.flaky_tests) | |
| 1431 | 1448 | return False | |
| 1432 | 1449 | return True | |
@@ -1726,7 +1743,7 @@ def should_keep(case): | |||
| 1726 | 1743 | else: | |
| 1727 | 1744 | try: | |
| 1728 | 1745 | start = time.time() | |
| 1729 | - if RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests): | ||
| 1746 | + if RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests, options.measure_flakiness): | ||
| 1730 | 1747 | result = 0 | |
| 1731 | 1748 | else: | |
| 1732 | 1749 | result = 1 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments