diff --git a/test/test-get-currentexe.c b/test/test-get-currentexe.c index 1dc85565..9dd26769 100644 --- a/test/test-get-currentexe.c +++ b/test/test-get-currentexe.c @@ -30,15 +30,25 @@ TEST_IMPL(get_currentexe) { char buffer[PATHMAX]; size_t size; char* match; + char* path; int r; size = sizeof(buffer) / sizeof(buffer[0]); r = uv_exepath(buffer, &size); ASSERT(!r); - match = strstr(buffer, executable_path); + /* uv_exepath can return an absolute path on darwin, so if the test runner + * was run with a relative prefix of "./", we need to strip that prefix off + * executable_path or we'll fail. */ + if (executable_path[0] == '.' && executable_path[1] == '/') { + path = executable_path + 2; + } else { + path = executable_path; + } + + match = strstr(buffer, path); /* Verify that the path returned from uv_exepath is a subdirectory of executable_path */ - ASSERT(match && !strcmp(match, executable_path)); + ASSERT(match && !strcmp(match, path)); ASSERT(size == strlen(buffer)); /* Negative tests */