1# Find all ebin directories and run the test.
2
3IF (NOT DEFINED TEST_TARGET)
4  SET (TEST_TARGET "$ENV{TEST_TARGET}")
5  IF ("${TEST_TARGET}" STREQUAL "")
6    SET (TEST_TARGET start)
7  ENDIF ("${TEST_TARGET}" STREQUAL "")
8ENDIF (NOT DEFINED TEST_TARGET)
9
10FILE (GLOB ebindirs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
11  deps/*/ebin deps/*/deps/*/ebin)
12# Bug in CMake?
13STRING (REGEX REPLACE "//" "/" ebindirs "${ebindirs}")
14
15STRING (RANDOM LENGTH 16 NODE_NAME_RANDOM)
16SET (NODE_NAME "test-${NODE_NAME_RANDOM}")
17
18# If you update the test command, please also update this echo command
19# (including the silly escaped quotes) so it displays what is
20# invoked. Yes, this is annoying.
21EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -E echo
22  "${ERL_EXECUTABLE}"
23  -pa ./ebin ${ebindirs} "${COUCHDB_BIN_DIR}/src/couchdb"
24  -pa "${COUCHDB_BIN_DIR}/src/mochiweb"
25  -pa "${COUCHDB_BIN_DIR}/src/ejson"
26  -noshell -kernel error_logger silent -shutdown_time 10000
27  -name "${NODE_NAME}"
28  -eval "\"application:start(sasl).\""
29  -eval "\"case t:${TEST_TARGET}() of ok -> init:stop(); _ -> init:stop(1) end.\"")
30
31EXECUTE_PROCESS(RESULT_VARIABLE _failure
32  COMMAND "${ERL_EXECUTABLE}"
33  -pa ./ebin ${ebindirs} "${COUCHDB_BIN_DIR}/src/couchdb"
34  -pa "${COUCHDB_BIN_DIR}/src/mochiweb"
35  -pa "${COUCHDB_BIN_DIR}/src/ejson"
36  -noshell -kernel error_logger silent -shutdown_time 10000
37  -name "${NODE_NAME}"
38  -eval "application:start(sasl)."
39  -eval "case t:${TEST_TARGET}() of ok -> init:stop(); _ -> init:stop(1) end.")
40IF (_failure)
41  MESSAGE (FATAL_ERROR "failed running tests")
42ENDIF (_failure)
43