Skip to content

Commit 24a64ea

Browse files
committed
Merge branch 'kl/test-fixes' into maint-2.46
A flakey test and incorrect calls to strtoX() functions have been fixed. * kl/test-fixes: t6421: fix test to work when repo dir contains d0 set errno=0 before strtoX calls
2 parents 710ef8a + ec60bb9 commit 24a64ea

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

builtin/get-tar-commit-id.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv UNUSED, const char *prefix
3535
if (header->typeflag[0] != TYPEFLAG_GLOBAL_HEADER)
3636
return 1;
3737

38+
errno = 0;
3839
len = strtol(content, &end, 10);
3940
if (errno == ERANGE || end == content || len < 0)
4041
return 1;

ref-filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
16281628
timestamp = parse_timestamp(eoemail + 2, &zone, 10);
16291629
if (timestamp == TIME_MAX)
16301630
goto bad;
1631+
errno = 0;
16311632
tz = strtol(zone, NULL, 10);
16321633
if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
16331634
goto bad;

t/helper/test-json-writer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ static void get_i(struct line *line, intmax_t *s_in)
415415

416416
get_s(line, &s);
417417

418+
errno = 0;
418419
*s_in = strtol(s, &endptr, 10);
419420
if (*endptr || errno == ERANGE)
420421
die("line[%d]: invalid integer value", line->nr);
@@ -427,6 +428,7 @@ static void get_d(struct line *line, double *s_in)
427428

428429
get_s(line, &s);
429430

431+
errno = 0;
430432
*s_in = strtod(s, &endptr);
431433
if (*endptr || errno == ERANGE)
432434
die("line[%d]: invalid float value", line->nr);

t/helper/test-trace2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static int get_i(int *p_value, const char *data)
2626
if (!data || !*data)
2727
return MyError;
2828

29+
errno = 0;
2930
*p_value = strtol(data, &endptr, 10);
3031
if (*endptr || errno == ERANGE)
3132
return MyError;

t/t6421-merge-partial-clone.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ test_expect_merge_algorithm failure success 'Objects downloaded for single relev
230230
grep fetch_count trace.output | cut -d "|" -f 9 | tr -d " ." >actual &&
231231
test_cmp expect actual &&
232232
233-
# Check the number of fetch commands exec-ed
234-
grep d0.*fetch.negotiationAlgorithm trace.output >fetches &&
233+
# Check the number of fetch commands exec-ed by filtering trace to
234+
# child_start events by the top-level program (2nd field == d0)
235+
grep " d0 .* child_start .*fetch.negotiationAlgorithm" trace.output >fetches &&
235236
test_line_count = 2 fetches &&
236237
237238
git rev-list --objects --all --missing=print |
@@ -318,8 +319,9 @@ test_expect_merge_algorithm failure success 'Objects downloaded when a directory
318319
grep fetch_count trace.output | cut -d "|" -f 9 | tr -d " ." >actual &&
319320
test_cmp expect actual &&
320321
321-
# Check the number of fetch commands exec-ed
322-
grep d0.*fetch.negotiationAlgorithm trace.output >fetches &&
322+
# Check the number of fetch commands exec-ed by filtering trace to
323+
# child_start events by the top-level program (2nd field == d0)
324+
grep " d0 .* child_start .*fetch.negotiationAlgorithm" trace.output >fetches &&
323325
test_line_count = 1 fetches &&
324326
325327
git rev-list --objects --all --missing=print |
@@ -422,8 +424,9 @@ test_expect_merge_algorithm failure success 'Objects downloaded with lots of ren
422424
grep fetch_count trace.output | cut -d "|" -f 9 | tr -d " ." >actual &&
423425
test_cmp expect actual &&
424426
425-
# Check the number of fetch commands exec-ed
426-
grep d0.*fetch.negotiationAlgorithm trace.output >fetches &&
427+
# Check the number of fetch commands exec-ed by filtering trace to
428+
# child_start events by the top-level program (2nd field == d0)
429+
grep " d0 .* child_start .*fetch.negotiationAlgorithm" trace.output >fetches &&
427430
test_line_count = 4 fetches &&
428431
429432
git rev-list --objects --all --missing=print |

0 commit comments

Comments
 (0)