aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/ts/ts_test.conf
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /build/conf/ts/ts_test.conf
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'build/conf/ts/ts_test.conf')
-rw-r--r--build/conf/ts/ts_test.conf115
1 files changed, 115 insertions, 0 deletions
diff --git a/build/conf/ts/ts_test.conf b/build/conf/ts/ts_test.conf
new file mode 100644
index 0000000000..8c4cca245f
--- /dev/null
+++ b/build/conf/ts/ts_test.conf
@@ -0,0 +1,115 @@
+TS_TEST_EXTENSION=
+TS_TEST_EXTRA_SRCS_MASK=
+
+TS_TEST_CONFIG_PATH=
+TS_TEST_FOR_MOD=
+TS_TEST_NM=
+
+# We have to rename node_modules.tar to workspace_node_modules.tar,
+# so TS_TEST_JEST module has it's own unique output.
+# TS_TEST_JEST_FOR module has to output all files required for test run.
+TS_TEST_JEST_CMD=$TOUCH_UNIT \
+ && ${cwd:BINDIR} $MOVE_FILE ${input:TS_TEST_NM} ${output:"workspace_node_modules.tar"} \
+ ${kv;hide:"p TSJEST"} ${kv;hide:"pc magenta"}
+
+### @usage: TS_TEST_JEST_FOR(Path)
+###
+### Defines testing module with jest test runner.
+###
+### @example
+###
+### TS_TEST_JEST_FOR(../)
+### TS_TEST_SRCS(../src)
+### TS_TEST_CONFIG(../jest.config.js)
+### END()
+###
+module TS_TEST_JEST_FOR: _TS_TEST_BASE {
+ .CMD=TS_TEST_JEST_CMD
+
+ # for multimodule peers we should choose NODE_MODULES
+ SET(PEERDIR_TAGS NODE_MODULES)
+
+ # compatibility with old TS_TEST_SRCS
+ SET(TS_TEST_EXTENSION test.(ts|tsx|js|jsx))
+ SET(TS_TEST_EXTRA_SRCS_MASK /**/__mocks__/*)
+
+ _PEERDIR_TS_RESOURCE(nodejs pnpm jest)
+ _TS_TEST_FOR_CONFIGURE(jest jest.config.js)
+}
+
+module _TS_TEST_BASE: _BARE_UNIT {
+ # ignore SRCS macro
+ .ALIASES=SRCS=_NOOP_MACRO
+ # use this parser to get module args in $MODULE_ARGS_RAW
+ .ARGS_PARSER=Raw
+ .NODE_TYPE=Program
+
+
+ # .fake tells builder to not materialize it in results
+ SET(MODULE_SUFFIX .ts_test.fake)
+ # include processor works only for TS tag
+ SET(MODULE_TAG TS)
+ # we read erm-packages.json during configuration, so we have to include it to configuration cache key
+ SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
+
+ # parse module args
+ _TS_TEST_FOR_ARGS($MODULE_ARGS_RAW)
+ # setup toolchain vars
+ _SET_EXTERNAL_RESOURCES()
+}
+
+macro _TS_TEST_FOR_ARGS(FOR_MOD) {
+ SET(TS_TEST_FOR_MOD $FOR_MOD)
+ _SET_TS_TEST_FOR_VARS($FOR_MOD)
+}
+
+macro _SETUP_EXTRACT_NODE_MODULES_RECIPE(FOR_PATH) {
+ DEPENDS(devtools/frontend_build_platform/nots/recipes/extract_node_modules)
+ USE_RECIPE(devtools/frontend_build_platform/nots/recipes/extract_node_modules/recipe $FOR_PATH workspace_node_modules.tar)
+}
+
+
+### @usage: TS_TEST_CONFIG(Path)
+###
+### Macro sets the path to configuration file of the test runner.
+###
+### - Path - path to the config file.
+macro TS_TEST_CONFIG(Path) {
+ SET(TS_TEST_CONFIG_PATH $Path)
+}
+
+
+_TS_TEST_SRCS_VALUE=
+_TS_TEST_EXTRA_SRCS_VALUE=
+### @usage: TS_TEST_SRCS(DIRS...)
+###
+### Macro to define directories where the test source files should be located.
+###
+### - DIRS... - directories.
+macro TS_TEST_SRCS(DIRS...) {
+ _GLOB(_TS_TEST_SRCS_VALUE ${suf=/**/*.$TS_TEST_EXTENSION:DIRS})
+ SRCS($_TS_TEST_SRCS_VALUE)
+
+ _GLOB(_TS_TEST_EXTRA_SRCS_VALUE ${suf=$TS_TEST_EXTRA_SRCS_MASK:DIRS})
+ SRCS($_TS_TEST_EXTRA_SRCS_VALUE)
+}
+
+
+_TS_TEST_DATA_VALUE=
+_TS_TEST_DATA_DIRS_RENAME_VALUE=
+### @usage: TS_TEST_DATA([RENAME] GLOBS...)
+###
+### Macro to add tests data (i.e. snapshots) used in testing to a bindir from curdir.
+### Creates symbolic links to directories of files found by the specified globs.
+###
+### Parameters:
+### - RENAME - adds ability to rename paths for tests data from curdir to bindir.
+### For example if your tested module located on "module" path and tests data in "module/tests_data".
+### Then you can be able to rename "tests_data" folder to something else - `RENAME tests_data:example`.
+### As a result in your bindir will be created folder - "module/example" which is a symbolic link on "module/tests_data" in curdir.
+### 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.
+### - GLOBS... - globs to tests data files, symbolic links will be created to their folders. For example - "tests_data/**/*".
+macro TS_TEST_DATA(RENAME="", GLOBS...) {
+ _GLOB(_TS_TEST_DATA_VALUE $GLOBS)
+ SET(_TS_TEST_DATA_DIRS_RENAME_VALUE $RENAME)
+} \ No newline at end of file