aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/ytest2.py
blob: 0a34263c35aadc9026bf05ee180e9de83dcc21b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import _common


def dir_stmts(unit, dir):
    unit.onpeerdir(dir)
    unit.onsrcdir(os.sep.join([dir, 'tests']))


def pytest_base(unit, args):
    related_prj_dir = args[0]
    related_prj_name = args[1]
    dir_stmts(unit, related_prj_dir)
    ytest_base(unit, related_prj_dir, related_prj_name, args[2:])
    unit.set(['ADDITIONAL_PATH', '--test-related-path ${ARCADIA_ROOT}/test'])


def ytest_base(unit, related_prj_dir, related_prj_name, args):
    keywords = {"DEPENDS": -1, "DATA": -1}
    flat_args, spec_args = _common.sort_by_keywords(keywords, args)
    unit.set(['TEST-NAME', os.path.basename(flat_args[0])])
    unit.set(['SCRIPT-REL-PATH', flat_args[1]])
    unit.set(['SOURCE-FOLDER-PATH', related_prj_dir])
    unit.set(['BUILD-FOLDER-PATH', os.path.join('$B', related_prj_dir)])
    unit.set(['TESTED-BINARY-PATH', flat_args[0]])

    custom_deps = ' '.join(spec_args["DEPENDS"]) if "DEPENDS" in spec_args else ''
    unit.set(['CUSTOM-DEPENDENCIES', custom_deps])
    data_lst = spec_args.get('DATA', []) + (unit.get(['__test_data']) or '').split(' ')
    data_lst.sort()
    data = '\"' + ';'.join(data_lst) + '\"' if data_lst else ''
    unit.set(['TEST-DATA', data])

    related_dirs_list = ['{ARCADIA_ROOT}/devtools/${YA_ROOT}', '${ARCADIA_ROOT}/devtools/${YA_ROOT}', '$RELATED_TARGET_SRCDIR']
    related_dirs_value = []
    for rel in related_dirs_list:
        related_dirs_value.extend(['--test-related-path', rel])
    unit.set(['RELATED_DIRS', ' '.join(related_dirs_value)])
    unit.set(['TEST_KV', '${{kv;hide:"test_related_dirs {}"}}'.format(' '.join(related_dirs_list))])


def on_unittest(unit, *args):
    related_prj_name = args[0]
    related_prj_dir = args[1][3:]
    unit.set(['TEST_TYPE', '${kv;hide:"test-type unittest"}'])
    ytest_base(unit, related_prj_dir, related_prj_name, args)


def on_ytest(unit, *args):
    pytest_base(unit, args)


def on_py_test(unit, *args):
    pytest_base(unit, args)