Last active
July 15, 2020 18:25
-
-
Save thedeveloperr/acec01fce528d0564cc8f74972641b47 to your computer and use it in GitHub Desktop.
[Zulip test-backend spam producing test finder script] It finds test that produce spam, in this case logs of code under test. Developed for issue https://github.com/zulip/zulip/issues/1587. #zulip_dev_utility script #zulip_dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Developed for https://github.com/zulip/zulip/issues/1587 | |
# Usage, run following command in vagrant: ./tools/test-backend --parallel=1 |& python find-test-file-producing-spam.py >> spam_to_remove.txt | |
valid_line_patterns = [ | |
"^Running ", # Example: Running zerver.tests.test_attachments.AttachmentsTests.test_delete_unauthenticated | |
"^\*\* Test is TOO slow: ", # Example: ** Test is TOO slow: analytics.tests.test_counts.TestRealmActiveHumans.test_end_to_end (0.581 s) | |
"^----------------------------------------------------------------------", # Example: ---------------------------------------------------------------------- | |
"^INFO: URL coverage report is in", # Example: INFO: URL coverage report is in var/url_coverage.txt | |
"^INFO: Try running:", # Example: INFO: Try running: ./tools/create-test-api-docs | |
"^-- Running tests in", # Example: -- Running tests in parallel mode with 4 processes | |
"^OK", # Example: OK | |
"^Ran [0-9]+ tests in", # Example: Ran 2139 tests in 115.659s | |
"^Destroying test database for alias ", # Destroying test database for alias 'default'... | |
"^Using existing clone", | |
"^\*\* Skipping " | |
] | |
compiled_line_patterns = [] | |
import re | |
for pattern in valid_line_patterns: | |
compiled_line_patterns.append(re.compile(pattern)) | |
import sys | |
prevLine = "" | |
for line in sys.stdin: | |
printFlag = True | |
for compiled_pattern in compiled_line_patterns: | |
if compiled_pattern.match(line): | |
printFlag = False | |
if printFlag: | |
if prevLine != "": | |
print("test:", prevLine, "spam:", line) | |
else: | |
print(line) | |
prevLine = "" | |
else: | |
if "Running " in line: | |
prevLine = line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment