Skip to content

Commit d57683d

Browse files
committed
Add tsx test to docker.
1 parent 900154b commit d57683d

File tree

8 files changed

+41
-5
lines changed

8 files changed

+41
-5
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ services:
5656
SERIAL_LIBRARY_PATH: $METACALL_PATH/build
5757
DETOUR_LIBRARY_PATH: $METACALL_PATH/build
5858
PORT_LIBRARY_PATH: $METACALL_PATH/build
59+
NODE_PATH: /usr/lib/node_modules
5960
depends_on:
6061
- deps
6162

source/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,6 @@ add_subdirectory(metacall_function_test)
172172
add_subdirectory(metacall_cobol_test)
173173
add_subdirectory(metacall_file_test)
174174
add_subdirectory(metacall_typescript_test)
175-
# add_subdirectory(metacall_typescript_tsx_test) # TODO: Implement dependency management for React and ReactDOM
175+
add_subdirectory(metacall_typescript_tsx_test)
176176
add_subdirectory(metacall_lua_test)
177177
add_subdirectory(metacall_rpc_test)

source/tests/metacall_typescript_tsx_test/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ if(NOT OPTION_BUILD_LOADERS OR NOT OPTION_BUILD_LOADERS_NODE OR NOT OPTION_BUILD
44
return()
55
endif()
66

7+
#
8+
# External dependencies
9+
#
10+
11+
set(NODEJS_EXECUTABLE_ONLY ON)
12+
13+
find_package(NodeJS 10.22.0)
14+
15+
if(NOT NODEJS_FOUND)
16+
message(STATUS "NodeJS executable not found")
17+
return()
18+
endif()
19+
20+
# Detect if React is available
21+
execute_process(
22+
COMMAND ${NODEJS_EXECUTABLE} -e "require('react'); require('react-dom')"
23+
RESULT_VARIABLE NODEJS_REACT_FOUND
24+
ERROR_QUIET
25+
OUTPUT_QUIET
26+
)
27+
28+
if("${NODEJS_REACT_FOUND}" EQUAL "1")
29+
message(WARNING "NodeJS React not found, skipping the TypeScript X templating test")
30+
return()
31+
endif()
32+
733
#
834
# Executable name and options
935
#

tools/deps/hooks/env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
source ../../hooks/env
2424

2525
# Base arguments
26-
METACALL_INSTALL_OPTIONS="root base python ruby netcore2 nodejs file rapidjson funchook swig" # v8rep51 pack and coverage not needed in DockerHub
26+
METACALL_INSTALL_OPTIONS="root base python ruby netcore2 nodejs typescript file rapidjson funchook swig" # v8rep51 pack and coverage not needed in DockerHub
2727

2828
# Base environment variables
2929
DEBIAN_FRONTEND=noninteractive

tools/dev/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ ENV LOADER_LIBRARY_PATH=$METACALL_PATH/build \
3838
SERIAL_LIBRARY_PATH=$METACALL_PATH/build \
3939
DETOUR_LIBRARY_PATH=$METACALL_PATH/build \
4040
PORT_LIBRARY_PATH=$METACALL_PATH/build \
41-
DEBIAN_FRONTEND=noninteractive
41+
DEBIAN_FRONTEND=noninteractive \
42+
NODE_PATH=/usr/lib/node_modules
4243

4344
# Define working directory
4445
WORKDIR $METACALL_PATH

tools/metacall-clear.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ sub_nodejs(){
9696
# TypeScript
9797
sub_typescript(){
9898
echo "clean typescript"
99+
100+
# Clear React dependencies of tests
101+
npm uninstall -g react@latest
102+
npm uninstall -g react-dom@latest
99103
}
100104

101105
# File

tools/metacall-environment.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ sub_nodejs(){
275275

276276
# TypeScript
277277
sub_typescript(){
278-
echo "configure typesecript"
278+
echo "configure typescript"
279+
280+
# Install React dependencies in order to run the tests
281+
npm i react@latest -g
282+
npm i react-dom@latest -g
279283
}
280284

281285
# File

tools/runtime/hooks/env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
source ../../hooks/env
2424

2525
# Core arguments
26-
METACALL_RUNTIME_OPTIONS="root base python ruby netcore2 nodejs file ports clean" # v8
26+
METACALL_RUNTIME_OPTIONS="root base python ruby netcore2 nodejs typescript file ports clean" # v8
2727

2828
# Core environment variables
2929
DEBIAN_FRONTEND=noninteractive

0 commit comments

Comments
 (0)