mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
test-backend: Clean up leak data import files after test-suite run.
This is a simple, non-intrusive way of removing the bulk of the clutter from `var/<uuid>/test-backend` after running `test-backend`. Ideally, we'll replace this logic with proper tearDown methods.
This commit is contained in:
@@ -16,6 +16,7 @@ import ujson
|
|||||||
import httplib2
|
import httplib2
|
||||||
import httpretty
|
import httpretty
|
||||||
import requests
|
import requests
|
||||||
|
import shutil
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -456,6 +457,21 @@ def main() -> None:
|
|||||||
# an important clue as to why tests fail.
|
# an important clue as to why tests fail.
|
||||||
report_slow_tests()
|
report_slow_tests()
|
||||||
|
|
||||||
|
# We now cleanup files leaked by certain tests that don't clean up
|
||||||
|
# after themselves. Ideally, this cleanup would happen in in the
|
||||||
|
# tearDown() methods for the relevant test classes, but this at least
|
||||||
|
# prevents a disk leak.
|
||||||
|
from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path
|
||||||
|
for path in glob.glob(os.path.join(get_or_create_dev_uuid_var_path('test-backend'),
|
||||||
|
"test-*-import-*")):
|
||||||
|
try:
|
||||||
|
if os.path.isdir(path):
|
||||||
|
shutil.rmtree(path)
|
||||||
|
else:
|
||||||
|
os.remove(path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Ideally, we'd check for any leaked test databases here;
|
# Ideally, we'd check for any leaked test databases here;
|
||||||
# but that needs some hackery with database names.
|
# but that needs some hackery with database names.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user