__init__.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. # coding: utf-8
  2. import re
  3. RESTART_TEST_INDICATOR = '##restart-test##'
  4. INFRASTRUCTURE_ERROR_INDICATOR = '##infrastructure-error##'
  5. RESTART_TEST_INDICATORS = [
  6. RESTART_TEST_INDICATOR,
  7. "network error",
  8. ]
  9. UID_PREFIX_DELIMITER = '-'
  10. # testing
  11. BIN_DIRECTORY = 'bin'
  12. CANON_DATA_DIR_NAME = "canondata"
  13. CANON_RESULT_FILE_NAME = "result.json"
  14. CANONIZATION_RESULT_FILE_NAME = "canonization_res.json"
  15. COMMON_CONTEXT_FILE_NAME = "common_test.context"
  16. CONSOLE_SNIPPET_LIMIT = 5000
  17. FAKE_OUTPUT_EXTS = frozenset([".mf", ".fake", ".cpf", ".cpsf"])
  18. LIST_NODE_LOG_FILE = "test_list.log"
  19. LIST_NODE_RESULT_FILE = "test_list.json"
  20. LIST_RESULT_NODE_LOG_FILE = "list_result.log"
  21. LIST_TRACE_FILE_NAME = "ytest_list.report.trace"
  22. MAX_FILE_SIZE = 1024 * 1024 * 2 # 2 MB
  23. MAX_TEST_RESTART_COUNT = 3
  24. NO_LISTED_TESTS = "NO_LISTED_TESTS"
  25. REPORT_SNIPPET_LIMIT = 12000
  26. SANITIZER_ERROR_RC = 100
  27. SUITE_CONTEXT_FILE_NAME = "test.context"
  28. TEST_LIST_FILE = "test_names_list.json"
  29. TEST_SUBTEST_SEPARATOR = '::'
  30. TESTING_OUT_DIR_NAME = "testing_out_stuff"
  31. TESTING_OUT_RAM_DRIVE_DIR_NAME = "ram_drive_output"
  32. TESTING_OUT_TAR_NAME = TESTING_OUT_DIR_NAME + ".tar.zstd"
  33. TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
  34. TRACE_FILE_NAME = "ytest.report.trace"
  35. TRUNCATING_IGNORE_FILE_LIST = {TRACE_FILE_NAME, SUITE_CONTEXT_FILE_NAME, "run_test.log"}
  36. YT_RUN_TEST_DIR_NAME = "yt_run_test"
  37. YT_RUN_TEST_TAR_NAME = "yt_run_test.tar"
  38. COVERAGE_CFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping", "-DCLANG_COVERAGE"]
  39. COVERAGE_LDFLAGS = ["-fprofile-instr-generate", "-fcoverage-mapping"]
  40. CANON_BACKEND_KEY = "{canondata_backend}"
  41. DEFAULT_CANONIZATION_BACKEND = "storage.yandex-team.ru/get-devtools"
  42. MDS_URI_PREFIX = 'https://storage.yandex-team.ru/get-devtools/'
  43. BACKEND_URI_PREFIX = 'https://' + CANON_BACKEND_KEY + '/'
  44. MDS_SCHEME = 'mds'
  45. CANON_MDS_RESOURCE_REGEX = re.compile(re.escape(MDS_URI_PREFIX) + r'(.*?)($|#)')
  46. CANON_BACKEND_RESOURCE_REGEX = re.compile(re.escape(BACKEND_URI_PREFIX) + r'(.*?)($|#)')
  47. CANON_SBR_RESOURCE_REGEX = re.compile(r'(sbr:/?/?(\d+))')
  48. MANDATORY_ENV_VAR_NAME = 'YA_MANDATORY_ENV_VARS'
  49. BUILD_FLAGS_ALLOWED_IN_CONTEXT = {
  50. 'AUTOCHECK',
  51. # Required for local test runs
  52. 'TESTS_REQUESTED',
  53. 'USE_ARCADIA_PYTHON',
  54. 'USE_SYSTEM_PYTHON',
  55. }
  56. STYLE_TEST_TYPES = [
  57. "classpath.clash",
  58. "clang_tidy",
  59. "eslint",
  60. "gofmt",
  61. "govet",
  62. "java.style",
  63. "ktlint",
  64. "py2_flake8",
  65. "flake8",
  66. "black",
  67. "ruff",
  68. "tsc_typecheck",
  69. ]
  70. REGULAR_TEST_TYPES = [
  71. "benchmark",
  72. "boost_test",
  73. "exectest",
  74. "fuzz",
  75. "g_benchmark",
  76. "go_bench",
  77. "go_test",
  78. "gtest",
  79. "hermione",
  80. "java",
  81. "jest",
  82. "py2test",
  83. "py3test",
  84. "pytest",
  85. "unittest",
  86. ]
  87. TEST_NODE_OUTPUT_RESULTS = [TESTING_OUT_TAR_NAME, YT_RUN_TEST_TAR_NAME]
  88. # kvm
  89. DEFAULT_RAM_REQUIREMENTS_FOR_KVM = 4
  90. MAX_RAM_REQUIREMENTS_FOR_KVM = 16
  91. # distbuild
  92. DISTBUILD_STATUS_REPORT_ENV_NAME = 'NODE_EXTENDED_STATUS_FILE_PATH'
  93. DEFAULT_TEST_NODE_TIMEOUT = 15 * 60
  94. TEST_NODE_FINISHING_TIME = 5 * 60
  95. # coverage
  96. COVERAGE_FUNCTION_ENTRIES_LIMIT = 2
  97. COVERAGE_PYTHON_EXTS = (".py", ".pyx", ".pxi", ".pxd")
  98. COVERAGE_RESOLVED_FILE_NAME_PATTERN = "coverage_resolved.{}.json"
  99. CPP_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("cpp")
  100. GO_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("go")
  101. JAVA_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("java")
  102. NLG_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("nlg")
  103. PYTHON2_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py2")
  104. PYTHON3_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("py3")
  105. TS_COVERAGE_RESOLVED_FILE_NAME = COVERAGE_RESOLVED_FILE_NAME_PATTERN.format("ts")
  106. COVERAGE_CLANG_ENV_NAME = 'LLVM_PROFILE_FILE'
  107. COVERAGE_GCOV_ENV_NAME = 'GCOV_PREFIX'
  108. COVERAGE_GO_ENV_NAME = 'GO_COVERAGE_PREFIX'
  109. COVERAGE_PYTHON_ENV_NAME = 'PYTHON_COVERAGE_PREFIX'
  110. COVERAGE_TS_ENV_NAME = 'TS_COVERAGE_PREFIX'
  111. COVERAGE_NLG_ENV_NAME = 'NLG_COVERAGE_FILENAME'
  112. COVERAGE_ENV_VARS = (
  113. COVERAGE_CLANG_ENV_NAME,
  114. COVERAGE_GCOV_ENV_NAME,
  115. COVERAGE_GO_ENV_NAME,
  116. COVERAGE_NLG_ENV_NAME,
  117. COVERAGE_PYTHON_ENV_NAME,
  118. COVERAGE_TS_ENV_NAME,
  119. )
  120. PYTHON_COVERAGE_PREFIX_FILTER_ENV_NAME = 'PYTHON_COVERAGE_PREFIX_FILTER'
  121. PYTHON_COVERAGE_EXCLUDE_REGEXP_ENV_NAME = 'PYTHON_COVERAGE_EXCLUDE_REGEXP'
  122. # TODO get rid of this list - resolve nodes should be added automatically depending on the lang of the target module and their deps
  123. CLANG_COVERAGE_TEST_TYPES = (
  124. "boost_test",
  125. "coverage_extractor",
  126. "exectest",
  127. "fuzz",
  128. "gtest",
  129. "go_test",
  130. # java tests might use shared libraries
  131. "java",
  132. "py2test",
  133. "py3test",
  134. "pytest",
  135. "unittest",
  136. )
  137. COVERAGE_TABLE_CHUNKS = 20
  138. COVERAGE_TESTS_TIMEOUT_FACTOR = 1.5
  139. COVERAGE_YT_PROXY = "hahn.yt.yandex.net"
  140. COVERAGE_YT_ROOT_PATH = "//home/codecoverage"
  141. COVERAGE_YT_TABLE_PREFIX = "datatable"
  142. # fuzzing
  143. CORPUS_DATA_FILE_NAME = 'corpus.json'
  144. CORPUS_DATA_ROOT_DIR = 'fuzzing'
  145. CORPUS_DIR_NAME = 'corpus'
  146. FUZZING_COVERAGE_ARGS = ['--sanitize-coverage=trace-div,trace-gep']
  147. FUZZING_COMPRESSION_COEF = 1.1
  148. FUZZING_DEFAULT_TIMEOUT = 3600
  149. FUZZING_FINISHING_TIME = 600
  150. FUZZING_TIMEOUT_RE = re.compile(r'(^|\s)-max_total_time=(?P<max_time>\d+)')
  151. GENERATED_CORPUS_DIR_NAME = 'mined_corpus'
  152. MAX_CORPUS_RESOURCES_ALLOWED = 5
  153. # hermione
  154. HERMIONE_REPORT_DIR_NAME = "hermione-report"
  155. HERMIONE_REPORT_TAR_NAME = HERMIONE_REPORT_DIR_NAME + ".tar"
  156. HERMIONE_REPORT_INDEX_FILE_NAME = "index.html"
  157. HERMIONE_REPORT_DB_URLS_FILE_NAME = "databaseUrls.json"
  158. HERMIONE_TESTS_READ_FILE_NAME = "tests.json"
  159. HERMIONE_TESTS_READ_STDOUT_FILE_NAME = "read_tests.out"
  160. HERMIONE_TESTS_READ_STDERR_FILE_NAME = "read_tests.err"
  161. HERMIONE_TESTS_RUN_FILE_NAME = "test_results.jsonl"
  162. HERMIONE_TESTS_RUN_STDOUT_FILE_NAME = "run_tests.out"
  163. HERMIONE_TESTS_RUN_STDERR_FILE_NAME = "run_tests.err"
  164. # yt
  165. YT_OPERATION_ID_SUBSTITUTION = '$OPERATION_ID'
  166. YT_SANDBOX_ROOT_PREFIX = '$(YT_SANDBOX_ROOT)'
  167. # sandbox
  168. SANDBOX_RUN_TEST_YT_TOKEN_VALUE_NAME = 'YA_MAKE_SANDBOX_RUN_TEST_YT_TOKEN'
  169. # global resources
  170. ANDROID_AVD_ROOT = 'ANDROID_AVD_RESOURCE_GLOBAL'
  171. ANDROID_SDK_ROOT = 'ANDROID_SDK_RESOURCE_GLOBAL'
  172. COVERAGE_PUSH_TOOL_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL'
  173. COVERAGE_PUSH_TOOL_RESOURCE = 'COVERAGE_PUSH_TOOL_RESOURCE_GLOBAL'
  174. COVERAGE_PUSH_TOOL_LB_LOCAL = 'USE_SYSTEM_COVERAGE_PUSH_TOOL_LB'
  175. COVERAGE_PUSH_TOOL_LB_RESOURCE = 'COVERAGE_PUSH_TOOL_LB_RESOURCE_GLOBAL'
  176. FLAKE8_PY2_RESOURCE = 'FLAKE8_PY2_RESOURCE_GLOBAL'
  177. FLAKE8_PY3_RESOURCE = 'FLAKE8_PY3_RESOURCE_GLOBAL'
  178. GO_TOOLS_RESOURCE = 'GO_TOOLS_RESOURCE_GLOBAL'
  179. JSTYLE_RUNNER_LIB = 'JSTYLE_LIB_RESOURCE_GLOBAL'
  180. NODEJS_RESOURCE = 'NODEJS_RESOURCE_GLOBAL'
  181. NYC_RESOURCE = 'NYC_RESOURCE_GLOBAL'
  182. RUFF_RESOURCE = 'RUFF_RESOURCE_GLOBAL'
  183. # test_tool resource for host platform.
  184. # source - build/platform/test_tool/host.ya.make.inc.
  185. # always using this test_tool resource except 2 cases:
  186. # 1. when we use TEST_TOOL_TARGET
  187. # 2. when --test-tool-bin passed
  188. TEST_TOOL_HOST = 'TEST_TOOL_HOST_RESOURCE_GLOBAL'
  189. # path to locally built test_tool passed by --test-tool-bin opt
  190. TEST_TOOL_HOST_LOCAL = 'TEST_TOOL_HOST_LOCAL'
  191. # test_tool resource for target platform.
  192. # source - build/platform/test_tool/ya.make.
  193. # The only usage of this resource is running tests under ios emulator
  194. TEST_TOOL_TARGET = 'TEST_TOOL_TARGET_RESOURCE_GLOBAL'
  195. # path to locally built test_tool passed by --test-tool-bin opt
  196. # always same as TEST_TOOL_HOST_LOCAL
  197. # The only usage of this path is running tests under ios emulator
  198. TEST_TOOL_TARGET_LOCAL = 'TEST_TOOL_TARGET_LOCAL'
  199. XCODE_TOOLS_RESOURCE = 'XCODE_TOOLS_ROOT_RESOURCE_GLOBAL'
  200. WINE_TOOL = 'WINE_TOOL_RESOURCE_GLOBAL'
  201. WINE32_TOOL = 'WINE32_TOOL_RESOURCE_GLOBAL'
  202. class Enum(object):
  203. @classmethod
  204. def enumerate(cls):
  205. return [v for k, v in cls.__dict__.items() if not k.startswith("_")]
  206. class TestRequirements(Enum):
  207. Container = 'container'
  208. Cpu = 'cpu'
  209. DiskUsage = 'disk_usage'
  210. Dns = 'dns'
  211. Kvm = 'kvm'
  212. Network = 'network'
  213. Ram = 'ram'
  214. RamDisk = 'ram_disk'
  215. SbVault = 'sb_vault'
  216. YavSecret = 'yav'
  217. class TestRequirementsConstants(Enum):
  218. All = 'all'
  219. AllCpuValue = 50
  220. AllRamDiskValue = 50
  221. MinCpu = 1
  222. MinRam = 1
  223. MinRamDisk = 0
  224. @classmethod
  225. def is_all_cpu(cls, value):
  226. return value == cls.All
  227. @classmethod
  228. def get_cpu_value(cls, value):
  229. return cls.AllCpuValue if cls.is_all_cpu(value) else value
  230. @classmethod
  231. def is_all_ram_disk(cls, value):
  232. return value == cls.All
  233. @classmethod
  234. def get_ram_disk_value(cls, value):
  235. return cls.AllRamDiskValue if cls.is_all_ram_disk(value) else value
  236. class TestSize(Enum):
  237. Small = 'small'
  238. Medium = 'medium'
  239. Large = 'large'
  240. DefaultTimeouts = {
  241. Small: 60,
  242. Medium: 600,
  243. Large: 3600,
  244. }
  245. DefaultPriorities = {
  246. Small: -1,
  247. Medium: -2,
  248. Large: -3,
  249. }
  250. DefaultRequirements = {
  251. Small: {
  252. TestRequirements.Cpu: 1,
  253. TestRequirements.Ram: 8,
  254. # TestRequirements.Ram: 2,
  255. TestRequirements.RamDisk: 0,
  256. },
  257. Medium: {
  258. TestRequirements.Cpu: 1,
  259. TestRequirements.Ram: 8,
  260. # TestRequirements.Ram: 4,
  261. TestRequirements.RamDisk: 0,
  262. },
  263. Large: {
  264. TestRequirements.Cpu: 1,
  265. TestRequirements.Ram: 8,
  266. # TestRequirements.Ram: 8,
  267. TestRequirements.RamDisk: 0,
  268. },
  269. }
  270. MaxRequirements = {
  271. Small: {
  272. TestRequirements.Cpu: 4,
  273. TestRequirements.Ram: 32,
  274. # TestRequirements.Ram: 4,
  275. TestRequirements.RamDisk: 32,
  276. },
  277. Medium: {
  278. TestRequirements.Cpu: 4,
  279. # TestRequirements.Cpu: 8,
  280. TestRequirements.Ram: 32,
  281. # TestRequirements.Ram: 16,
  282. TestRequirements.RamDisk: 32,
  283. },
  284. Large: {
  285. TestRequirements.Cpu: 4,
  286. TestRequirements.Ram: 32,
  287. TestRequirements.RamDisk: 32,
  288. },
  289. }
  290. LargeMarker = "TL"
  291. MediumMarker = "TM"
  292. SmallMarker = "TS"
  293. SizeMarkers = (LargeMarker, MediumMarker, SmallMarker)
  294. SizeShorthandMap = {
  295. Large: LargeMarker,
  296. Medium: MediumMarker,
  297. Small: SmallMarker,
  298. }
  299. @classmethod
  300. def sizes(cls):
  301. return cls.DefaultTimeouts.keys()
  302. @classmethod
  303. def get_shorthand(cls, size):
  304. return cls.SizeShorthandMap[size]
  305. @classmethod
  306. def is_test_shorthand(cls, name):
  307. return name in cls.SizeMarkers
  308. @classmethod
  309. def get_default_timeout(cls, size):
  310. if size in cls.DefaultTimeouts:
  311. return cls.DefaultTimeouts[size]
  312. raise Exception("Unknown test size '{}'".format(size))
  313. @classmethod
  314. def get_default_priorities(cls, size):
  315. if size in cls.DefaultPriorities:
  316. return cls.DefaultPriorities[size]
  317. raise Exception("Unknown test size '{}'".format(size))
  318. @classmethod
  319. def get_default_requirements(cls, size):
  320. if size in cls.DefaultRequirements:
  321. return cls.DefaultRequirements[size]
  322. raise Exception("Unknown test size '{}'".format(size))
  323. @classmethod
  324. def get_max_requirements(cls, size):
  325. if size in cls.MaxRequirements:
  326. return cls.MaxRequirements[size]
  327. raise Exception("Unknown test size '{}'".format(size))
  328. class TestRunExitCode(Enum):
  329. Skipped = 2
  330. Failed = 3
  331. TimeOut = 10
  332. InfrastructureError = 12
  333. class YaTestTags(Enum):
  334. AlwaysMinimize = "ya:always_minimize"
  335. Dirty = "ya:dirty"
  336. DumpNodeEnvironment = "ya:dump_node_env"
  337. DumpTestEnvironment = "ya:dump_test_env"
  338. ExoticPlatform = "ya:exotic_platform"
  339. External = "ya:external"
  340. Fat = "ya:fat"
  341. ForceDistbuild = "ya:force_distbuild"
  342. ForceSandbox = "ya:force_sandbox"
  343. GoNoSubtestReport = "ya:go_no_subtest_report"
  344. GoTotalReport = "ya:go_total_report"
  345. HugeLogs = "ya:huge_logs"
  346. Manual = "ya:manual"
  347. MapRootUser = "ya:map_root_user"
  348. NoGracefulShutdown = "ya:no_graceful_shutdown"
  349. Norestart = "ya:norestart"
  350. Noretries = "ya:noretries"
  351. NotAutocheck = "ya:not_autocheck"
  352. Notags = "ya:notags"
  353. PerfTest = "ya:perftest"
  354. Privileged = "ya:privileged"
  355. ReportChunks = "ya:report_chunks"
  356. RunWithAsserts = "ya:relwithdebinfo"
  357. SandboxCoverage = "ya:sandbox_coverage"
  358. SequentialRun = "ya:sequential_run"
  359. TraceOutput = "ya:trace_output"
  360. YtRunner = "ya:yt"
  361. CopyData = "ya:copydata"
  362. CopyDataRO = "ya:copydataro"
  363. NoPstreeTrim = "ya:no_pstree_trim"
  364. class ServiceTags(Enum):
  365. AnyTag = "ya:anytag"
  366. class Status(object):
  367. GOOD, XFAIL, FAIL, XPASS, MISSING, CRASHED, TIMEOUT = range(1, 8)
  368. SKIPPED = -100
  369. NOT_LAUNCHED = -200
  370. CANON_DIFF = -300
  371. DESELECTED = -400
  372. INTERNAL = -int(2**31 - 1) # maxint
  373. FLAKY = -50
  374. # XFAILDIFF is internal status and should be replaced
  375. # with XFAIL or XPASS during verification stage of canon data
  376. XFAILDIFF = -90
  377. BY_NAME = {
  378. 'crashed': CRASHED,
  379. 'deselected': DESELECTED,
  380. 'diff': CANON_DIFF,
  381. 'fail': FAIL,
  382. 'flaky': FLAKY,
  383. 'good': GOOD,
  384. 'internal': INTERNAL,
  385. 'missing': MISSING,
  386. 'not_launched': NOT_LAUNCHED,
  387. 'skipped': SKIPPED,
  388. 'timeout': TIMEOUT,
  389. 'xfail': XFAIL,
  390. 'xfaildiff': XFAILDIFF,
  391. 'xpass': XPASS,
  392. }
  393. TO_STR = {
  394. CANON_DIFF: 'diff',
  395. CRASHED: 'crashed',
  396. DESELECTED: 'deselected',
  397. FAIL: 'fail',
  398. FLAKY: 'flaky',
  399. GOOD: 'good',
  400. INTERNAL: 'internal',
  401. MISSING: 'missing',
  402. NOT_LAUNCHED: 'not_launched',
  403. SKIPPED: 'skipped',
  404. TIMEOUT: 'timeout',
  405. XFAIL: 'xfail',
  406. XFAILDIFF: 'xfaildiff',
  407. XPASS: 'xpass',
  408. }
  409. class _Colors(object):
  410. _NAMES = [
  411. "blue",
  412. "cyan",
  413. "default",
  414. "green",
  415. "grey",
  416. "magenta",
  417. "red",
  418. "white",
  419. "yellow",
  420. ]
  421. _PREFIXES = ["", "light", "dark"]
  422. def __init__(self):
  423. self._table = {}
  424. for prefix in self._PREFIXES:
  425. for value in self._NAMES:
  426. name = value
  427. if prefix:
  428. name = "{}_{}".format(prefix, value)
  429. value = "{}-{}".format(prefix, value)
  430. self.__add_color(name.upper(), value)
  431. def __add_color(self, name, value):
  432. self._table[name] = value
  433. self.__setattr__(name, value)
  434. Colors = _Colors()
  435. class _Highlight(object):
  436. _MARKERS = {
  437. # special
  438. "RESET": "rst",
  439. "IMPORTANT": "imp",
  440. "UNIMPORTANT": "unimp",
  441. "BAD": "bad",
  442. "WARNING": "warn",
  443. "GOOD": "good",
  444. "PATH": "path",
  445. "ALTERNATIVE1": "alt1",
  446. "ALTERNATIVE2": "alt2",
  447. "ALTERNATIVE3": "alt3",
  448. }
  449. def __init__(self):
  450. # setting attributes because __getattr__ is much slower
  451. for attr, value in self._MARKERS.items():
  452. self.__setattr__(attr, value)
  453. Highlight = _Highlight()
  454. class _StatusColorMap(object):
  455. # There should be no XFAILDIFF, because it's internal status.
  456. # It should be replaced with XFAIL or XPASS during verification of canon data.
  457. _MAP = {
  458. 'crashed': Highlight.WARNING,
  459. 'deselected': Highlight.UNIMPORTANT,
  460. 'diff': Highlight.BAD,
  461. 'fail': Highlight.BAD,
  462. 'flaky': Highlight.ALTERNATIVE3,
  463. 'good': Highlight.GOOD,
  464. 'internal': Highlight.BAD,
  465. 'missing': Highlight.ALTERNATIVE1,
  466. 'not_launched': Highlight.BAD,
  467. 'skipped': Highlight.UNIMPORTANT,
  468. 'timeout': Highlight.BAD,
  469. 'xfail': Highlight.WARNING,
  470. 'xpass': Highlight.WARNING,
  471. }
  472. def __getitem__(self, item):
  473. return self._MAP[item]
  474. StatusColorMap = _StatusColorMap()