ts_test.conf 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. TS_TEST_EXTENSION=
  2. TS_TEST_EXTRA_SRCS_MASK=
  3. TS_TEST_CONFIG_PATH=
  4. TS_TEST_FOR_MOD=
  5. TS_TEST_NM=
  6. # We have to rename node_modules.tar to workspace_node_modules.tar,
  7. # so TS_TEST_JEST module has it's own unique output.
  8. # TS_TEST_JEST_FOR module has to output all files required for test run.
  9. TS_TEST_JEST_CMD=$TOUCH_UNIT \
  10. && ${cwd:BINDIR} $MOVE_FILE ${input:TS_TEST_NM} ${output:"workspace_node_modules.tar"} \
  11. ${kv;hide:"p TSJEST"} ${kv;hide:"pc magenta"}
  12. ### @usage: TS_TEST_JEST_FOR(Path)
  13. ###
  14. ### Defines testing module with jest test runner.
  15. ###
  16. ### @example
  17. ###
  18. ### TS_TEST_JEST_FOR(../)
  19. ### TS_TEST_SRCS(../src)
  20. ### TS_TEST_CONFIG(../jest.config.js)
  21. ### END()
  22. ###
  23. module TS_TEST_JEST_FOR: _TS_TEST_BASE {
  24. .CMD=TS_TEST_JEST_CMD
  25. # for multimodule peers we should choose NODE_MODULES
  26. SET(PEERDIR_TAGS NODE_MODULES)
  27. # compatibility with old TS_TEST_SRCS
  28. SET(TS_TEST_EXTENSION test.(ts|tsx|js|jsx))
  29. SET(TS_TEST_EXTRA_SRCS_MASK /**/__mocks__/*)
  30. _PEERDIR_TS_RESOURCE(nodejs pnpm jest)
  31. _TS_TEST_FOR_CONFIGURE(jest jest.config.js)
  32. }
  33. module _TS_TEST_BASE: _BARE_UNIT {
  34. # ignore SRCS macro
  35. .ALIASES=SRCS=_NOOP_MACRO
  36. # use this parser to get module args in $MODULE_ARGS_RAW
  37. .ARGS_PARSER=Raw
  38. .NODE_TYPE=Program
  39. # .fake tells builder to not materialize it in results
  40. SET(MODULE_SUFFIX .ts_test.fake)
  41. # include processor works only for TS tag
  42. SET(MODULE_TAG TS)
  43. # we read erm-packages.json during configuration, so we have to include it to configuration cache key
  44. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
  45. # parse module args
  46. _TS_TEST_FOR_ARGS($MODULE_ARGS_RAW)
  47. # we don't want to have TS outputs for tests
  48. DISABLE(TS_CONFIG_DEDUCE_OUT)
  49. }
  50. macro _TS_TEST_FOR_ARGS(FOR_MOD) {
  51. SET(TS_TEST_FOR_MOD $FOR_MOD)
  52. _SET_TS_TEST_FOR_VARS($FOR_MOD)
  53. }
  54. macro _SETUP_EXTRACT_NODE_MODULES_RECIPE(FOR_PATH) {
  55. DEPENDS(devtools/frontend_build_platform/nots/recipes/extract_node_modules)
  56. USE_RECIPE(devtools/frontend_build_platform/nots/recipes/extract_node_modules/recipe $FOR_PATH workspace_node_modules.tar)
  57. }
  58. macro _SETUP_EXTRACT_PEER_TARS_RECIPE(FOR_PATH) {
  59. DEPENDS(devtools/frontend_build_platform/nots/recipes/extract_peer_tars)
  60. USE_RECIPE(devtools/frontend_build_platform/nots/recipes/extract_peer_tars/recipe $FOR_PATH)
  61. }
  62. ### @usage: TS_TEST_CONFIG(Path)
  63. ###
  64. ### Macro sets the path to configuration file of the test runner.
  65. ###
  66. ### - Path - path to the config file.
  67. macro TS_TEST_CONFIG(Path) {
  68. SET(TS_TEST_CONFIG_PATH $Path)
  69. }
  70. _TS_TEST_SRCS_VALUE=
  71. _TS_TEST_EXTRA_SRCS_VALUE=
  72. ### @usage: TS_TEST_SRCS(DIRS...)
  73. ###
  74. ### Macro to define directories where the test source files should be located.
  75. ###
  76. ### - DIRS... - directories.
  77. macro TS_TEST_SRCS(DIRS...) {
  78. _GLOB(_TS_TEST_SRCS_VALUE ${suf=/**/*.$TS_TEST_EXTENSION:DIRS})
  79. SRCS($_TS_TEST_SRCS_VALUE)
  80. _GLOB(_TS_TEST_EXTRA_SRCS_VALUE ${suf=$TS_TEST_EXTRA_SRCS_MASK:DIRS})
  81. SRCS($_TS_TEST_EXTRA_SRCS_VALUE)
  82. }
  83. _TS_TEST_DATA_VALUE=
  84. _TS_TEST_DATA_DIRS_RENAME_VALUE=
  85. ### @usage: TS_TEST_DATA([RENAME] GLOBS...)
  86. ###
  87. ### Macro to add tests data (i.e. snapshots) used in testing to a bindir from curdir.
  88. ### Creates symbolic links to directories of files found by the specified globs.
  89. ###
  90. ### Parameters:
  91. ### - RENAME - adds ability to rename paths for tests data from curdir to bindir.
  92. ### For example if your tested module located on "module" path and tests data in "module/tests_data".
  93. ### Then you can be able to rename "tests_data" folder to something else - `RENAME tests_data:example`.
  94. ### As a result in your bindir will be created folder - "module/example" which is a symbolic link on "module/tests_data" in curdir.
  95. ### It is possible to specify multiple renaming rules in the following format "dir1:dir2;dir3/foo:dir4/bar", where "dir1" and "dir3" folders in curdir.
  96. ### - GLOBS... - globs to tests data files, symbolic links will be created to their folders. For example - "tests_data/**/*".
  97. macro TS_TEST_DATA(RENAME="", GLOBS...) {
  98. _GLOB(_TS_TEST_DATA_VALUE $GLOBS)
  99. SET(_TS_TEST_DATA_DIRS_RENAME_VALUE $RENAME)
  100. }