Skip to content

Commit

Permalink
tests OPTIMIZE shorten path to the UNIX socket (#1581)
Browse files Browse the repository at this point in the history
* build: do not hard code test repository path in multiple places

* build: relocate test repositories to a shorter path

...to prevent errors when the generated paths are "too long", over 107
characters. Yes, I have these, of course.

* tests: shave a few more bytes from the socket paths
  • Loading branch information
jktjkt authored May 24, 2024
1 parent e8eed68 commit 6e3e4bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get_filename_component(ROOT_DIR "${CMAKE_SOURCE_DIR}" REALPATH)

# test directories that can be adjusted
if(NOT NP2_TEST_ROOT_DIR)
set(NP2_TEST_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/repositories)
set(NP2_TEST_ROOT_DIR ${PROJECT_BINARY_DIR}/repos)
endif()
if(NOT NP2_TEST_MODULE_DIR)
set(NP2_TEST_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules)
Expand Down Expand Up @@ -102,7 +102,7 @@ if(ENABLE_TESTS)
add_custom_target(test_clean
COMMAND ${TEST_KILL_SERVER_COMMAND}
COMMAND ${TEST_CLEAR_STATE_COMMAND}
COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/repositories
COMMAND rm -rf ${NP2_TEST_ROOT_DIR}
)
endif()

Expand Down
2 changes: 1 addition & 1 deletion tests/np2_test_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define NP_PID_FILE "np2.pid"

/* server socket path */
#define NP_SOCKET_FILE "np2.sock"
#define NP_SOCKET_FILE "s"

/* server ext data file */
#define NP_EXT_DATA_FILE "schema_mount.xml"
Expand Down
6 changes: 3 additions & 3 deletions tests/scripts/kill_np_server.sh.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
NP2_TESTS_BINARY_DIR="@CMAKE_CURRENT_BINARY_DIR@"
[ -z "$NP2_TESTS_BINARY_DIR" ] &&
NP2_TEST_ROOT_DIR="@NP2_TEST_ROOT_DIR@"
[ -z "$NP2_TEST_ROOT_DIR" ] &&
echo "Expected an argument with to the test directory" &&
exit 1

for pidfile in $NP2_TESTS_BINARY_DIR/repositories/*/np2.pid
for pidfile in $NP2_TEST_ROOT_DIR/*/np2.pid
do
[ -f "$pidfile" ] && kill "$(cat "$pidfile")"
done
Expand Down

0 comments on commit 6e3e4bd

Please sign in to comment.