Skip to content

Commit 1f280a0

Browse files
authored
Normalize directory names in run-test262 (#971)
Otherwise find_error() won't match entries in test262_errors.txt when the path to `-d <path>` ends with one or more trailing slashes. Fixes: #970
1 parent da67188 commit 1f280a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

run-test262.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,22 @@ static int add_test_file(const char *filename)
405405

406406
static void find_test_files(const char *path);
407407

408+
static bool ispathsep(int c)
409+
{
410+
return c == '/' || c == '\\';
411+
}
412+
408413
static void consider_test_file(const char *path, const char *name, int is_dir)
409414
{
415+
size_t pathlen;
410416
char s[1024];
411417

412418
if (str_equal(name, ".") || str_equal(name, ".."))
413419
return;
414-
snprintf(s, sizeof(s), "%s/%s", path, name);
420+
pathlen = strlen(path);
421+
while (pathlen > 0 && ispathsep(path[pathlen-1]))
422+
pathlen--;
423+
snprintf(s, sizeof(s), "%.*s/%s", (int)pathlen, path, name);
415424
if (is_dir)
416425
find_test_files(s);
417426
else

0 commit comments

Comments
 (0)