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
15# If you update the test command, please also update this echo command
16# (including the silly escaped quotes) so it displays what is
17# invoked. Yes, this is annoying.
18EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -E echo
19  "${ERL_EXECUTABLE}"
20  -pa ./ebin ${ebindirs} "${COUCHDB_BIN_DIR}/src/couchdb"
21  -pa "${COUCHDB_BIN_DIR}/src/mochiweb"
22  -pa "${COUCHDB_BIN_DIR}/src/ejson"
23  -noshell -kernel error_logger silent -shutdown_time 10000
24  -eval "\"application:start(sasl).\""
25  -eval "\"case t:${TEST_TARGET}() of ok -> init:stop(); _ -> init:stop(1) end.\"")
26
27EXECUTE_PROCESS(RESULT_VARIABLE _failure
28  COMMAND "${ERL_EXECUTABLE}"
29  -pa ./ebin ${ebindirs} "${COUCHDB_BIN_DIR}/src/couchdb"
30  -pa "${COUCHDB_BIN_DIR}/src/mochiweb"
31  -pa "${COUCHDB_BIN_DIR}/src/ejson"
32  -noshell -kernel error_logger silent -shutdown_time 10000
33  -eval "application:start(sasl)."
34  -eval "case t:${TEST_TARGET}() of ok -> init:stop(); _ -> init:stop(1) end.")
35IF (_failure)
36  MESSAGE (FATAL_ERROR "failed running tests")
37ENDIF (_failure)
38