ytest2.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import os
  2. import _common
  3. def dir_stmts(unit, dir):
  4. unit.onpeerdir(dir)
  5. unit.onsrcdir(os.sep.join([dir, 'tests']))
  6. def pytest_base(unit, args):
  7. related_prj_dir = args[0]
  8. related_prj_name = args[1]
  9. dir_stmts(unit, related_prj_dir)
  10. ytest_base(unit, related_prj_dir, related_prj_name, args[2:])
  11. unit.set(['ADDITIONAL_PATH', '--test-related-path ${ARCADIA_ROOT}/test'])
  12. def ytest_base(unit, related_prj_dir, related_prj_name, args):
  13. keywords = {"DEPENDS": -1, "DATA": -1}
  14. flat_args, spec_args = _common.sort_by_keywords(keywords, args)
  15. unit.set(['TEST-NAME', os.path.basename(flat_args[0])])
  16. unit.set(['SCRIPT-REL-PATH', flat_args[1]])
  17. unit.set(['SOURCE-FOLDER-PATH', related_prj_dir])
  18. unit.set(['BUILD-FOLDER-PATH', os.path.join('$B', related_prj_dir)])
  19. unit.set(['TESTED-BINARY-PATH', flat_args[0]])
  20. custom_deps = ' '.join(spec_args["DEPENDS"]) if "DEPENDS" in spec_args else ''
  21. unit.set(['CUSTOM-DEPENDENCIES', custom_deps])
  22. data_lst = spec_args.get('DATA', []) + (unit.get(['__test_data']) or '').split(' ')
  23. data_lst.sort()
  24. data = '\"' + ';'.join(data_lst) + '\"' if data_lst else ''
  25. unit.set(['TEST-DATA', data])
  26. related_dirs_list = [
  27. '{ARCADIA_ROOT}/devtools/${YA_ROOT}',
  28. '${ARCADIA_ROOT}/devtools/${YA_ROOT}',
  29. '$RELATED_TARGET_SRCDIR',
  30. ]
  31. related_dirs_value = []
  32. for rel in related_dirs_list:
  33. related_dirs_value.extend(['--test-related-path', rel])
  34. unit.set(['RELATED_DIRS', ' '.join(related_dirs_value)])
  35. unit.set(['TEST_KV', '${{kv;hide:"test_related_dirs {}"}}'.format(' '.join(related_dirs_list))])
  36. def on_unittest(unit, *args):
  37. related_prj_name = args[0]
  38. related_prj_dir = args[1][3:]
  39. unit.set(['TEST_TYPE', '${kv;hide:"test-type unittest"}'])
  40. ytest_base(unit, related_prj_dir, related_prj_name, args)
  41. def on_ytest(unit, *args):
  42. pytest_base(unit, args)
  43. def on_py_test(unit, *args):
  44. pytest_base(unit, args)