aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/testing/recipe
diff options
context:
space:
mode:
authorexprmntr <exprmntr@yandex-team.ru>2022-02-10 16:46:50 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:50 +0300
commita6396ea4e82c2605dcf9a11ebc4c289d0b1c734c (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/python/testing/recipe
parent078ddb2fb76387cae14e8c3ceb5a896009a5a539 (diff)
downloadydb-a6396ea4e82c2605dcf9a11ebc4c289d0b1c734c.tar.gz
Restoring authorship annotation for exprmntr <exprmntr@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/testing/recipe')
-rw-r--r--library/python/testing/recipe/__init__.py158
-rw-r--r--library/python/testing/recipe/ya.make10
2 files changed, 84 insertions, 84 deletions
diff --git a/library/python/testing/recipe/__init__.py b/library/python/testing/recipe/__init__.py
index 4e9c736dc7..5ef9c5c189 100644
--- a/library/python/testing/recipe/__init__.py
+++ b/library/python/testing/recipe/__init__.py
@@ -1,21 +1,21 @@
from __future__ import print_function
-import os
-import sys
+import os
+import sys
import json
import logging
-import argparse
-
-from yatest_lib.ya import Ya
-
-RECIPE_START_OPTION = "start"
-RECIPE_STOP_OPTION = "stop"
-
-ya = None
-collect_cores = None
-sanitizer_extra_checks = None
-
-
+import argparse
+
+from yatest_lib.ya import Ya
+
+RECIPE_START_OPTION = "start"
+RECIPE_STOP_OPTION = "stop"
+
+ya = None
+collect_cores = None
+sanitizer_extra_checks = None
+
+
def _setup_logging(level=logging.DEBUG):
root_logger = logging.getLogger()
root_logger.setLevel(level)
@@ -29,74 +29,74 @@ def _setup_logging(level=logging.DEBUG):
root_logger.addHandler(stdout_handler)
-def get_options():
- parser = argparse.ArgumentParser()
- parser.add_argument("--show-cwd", action="store_true", dest="show_cwd", default=False, help="show recipe cwd")
+def get_options():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--show-cwd", action="store_true", dest="show_cwd", default=False, help="show recipe cwd")
parser.add_argument("--test-debug", action="store_true", dest="test_debug", default=False, help="test debug mode")
- parser.add_argument("--test-stderr", action="store_true", dest="test_stderr", default=False, help="test stderr")
- parser.add_argument("--pdb", action="store_true", dest="pdb", default=False, help="run pdb on error")
- parser.add_argument("--sanitizer-extra-checks", dest="sanitizer_extra_checks", action="store_true", default=False, help="enables extra checks for tests built with sanitizers")
- parser.add_argument("--collect-cores", dest="collect_cores", action="store_true", default=False, help="allows core dump file recovering during test")
-
- args, opts = parser.parse_known_args()
-
- global ya, sanitizer_extra_checks, collect_cores
+ parser.add_argument("--test-stderr", action="store_true", dest="test_stderr", default=False, help="test stderr")
+ parser.add_argument("--pdb", action="store_true", dest="pdb", default=False, help="run pdb on error")
+ parser.add_argument("--sanitizer-extra-checks", dest="sanitizer_extra_checks", action="store_true", default=False, help="enables extra checks for tests built with sanitizers")
+ parser.add_argument("--collect-cores", dest="collect_cores", action="store_true", default=False, help="allows core dump file recovering during test")
+
+ args, opts = parser.parse_known_args()
+
+ global ya, sanitizer_extra_checks, collect_cores
_setup_logging()
- context = {
- "test_stderr": args.test_stderr,
- }
-
- ya = Ya(context=context)
-
- ya._data_root = "" # XXX remove
-
- sanitizer_extra_checks = args.sanitizer_extra_checks
- if sanitizer_extra_checks:
- for envvar in ['LSAN_OPTIONS', 'ASAN_OPTIONS']:
- if envvar in os.environ:
- os.environ.pop(envvar)
- if envvar + '_ORIGINAL' in os.environ:
- os.environ[envvar] = os.environ[envvar + '_ORIGINAL']
- collect_cores = args.collect_cores
-
- for recipe_option in RECIPE_START_OPTION, RECIPE_STOP_OPTION:
- if recipe_option in opts:
- return args, opts[opts.index(recipe_option):]
-
-
-def set_env(key, value):
- with open(ya.env_file, "a") as f:
- json.dump({key: value}, f)
- f.write("\n")
-
-
-def tty():
- if os.isatty(1):
- return
-
- f = open('/dev/tty', 'w+')
- fd = f.fileno()
- os.dup2(fd, 0)
- os.dup2(fd, 1)
- os.dup2(fd, 2)
-
-
-def declare_recipe(start, stop):
- parsed_args, argv = get_options()
-
- if parsed_args.show_cwd:
+ context = {
+ "test_stderr": args.test_stderr,
+ }
+
+ ya = Ya(context=context)
+
+ ya._data_root = "" # XXX remove
+
+ sanitizer_extra_checks = args.sanitizer_extra_checks
+ if sanitizer_extra_checks:
+ for envvar in ['LSAN_OPTIONS', 'ASAN_OPTIONS']:
+ if envvar in os.environ:
+ os.environ.pop(envvar)
+ if envvar + '_ORIGINAL' in os.environ:
+ os.environ[envvar] = os.environ[envvar + '_ORIGINAL']
+ collect_cores = args.collect_cores
+
+ for recipe_option in RECIPE_START_OPTION, RECIPE_STOP_OPTION:
+ if recipe_option in opts:
+ return args, opts[opts.index(recipe_option):]
+
+
+def set_env(key, value):
+ with open(ya.env_file, "a") as f:
+ json.dump({key: value}, f)
+ f.write("\n")
+
+
+def tty():
+ if os.isatty(1):
+ return
+
+ f = open('/dev/tty', 'w+')
+ fd = f.fileno()
+ os.dup2(fd, 0)
+ os.dup2(fd, 1)
+ os.dup2(fd, 2)
+
+
+def declare_recipe(start, stop):
+ parsed_args, argv = get_options()
+
+ if parsed_args.show_cwd:
print("Recipe \"{} {}\" working dir is {}".format(sys.argv[0], " ".join(argv), os.getcwd()))
-
- try:
- if argv[0] == RECIPE_START_OPTION:
- start(argv[1:])
- elif argv[0] == RECIPE_STOP_OPTION:
- stop(argv[1:])
- except Exception:
- if parsed_args.pdb:
- tty()
+
+ try:
+ if argv[0] == RECIPE_START_OPTION:
+ start(argv[1:])
+ elif argv[0] == RECIPE_STOP_OPTION:
+ stop(argv[1:])
+ except Exception:
+ if parsed_args.pdb:
+ tty()
import ipdb
ipdb.post_mortem()
- else:
- raise
+ else:
+ raise
diff --git a/library/python/testing/recipe/ya.make b/library/python/testing/recipe/ya.make
index be673f8289..dd323aa245 100644
--- a/library/python/testing/recipe/ya.make
+++ b/library/python/testing/recipe/ya.make
@@ -2,18 +2,18 @@ OWNER(
exprmntr
g:yatest
)
-
+
PY23_LIBRARY()
-
+
PY_SRCS(
__init__.py
ports.py
)
-
+
PEERDIR(
contrib/python/ipdb
library/python/testing/yatest_common
- library/python/testing/yatest_lib
+ library/python/testing/yatest_lib
)
-END()
+END()