Skip to content

Commit 0e49649

Browse files
pcloudsgitster
authored andcommitted
t/helper: merge test-chmtime into test-tool
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent efd71f8 commit 0e49649

33 files changed

+94
-89
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ X =
652652

653653
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
654654

655-
TEST_PROGRAMS_NEED_X += test-chmtime
655+
TEST_BUILTINS_OBJS += test-chmtime.o
656+
656657
TEST_PROGRAMS_NEED_X += test-ctype
657658
TEST_PROGRAMS_NEED_X += test-config
658659
TEST_PROGRAMS_NEED_X += test-date

t/helper/test-chmtime.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
*
66
* The mtime can be changed to an absolute value:
77
*
8-
* test-chmtime =<seconds> file...
8+
* test-tool chmtime =<seconds> file...
99
*
1010
* Relative to the current time as returned by time(3):
1111
*
12-
* test-chmtime =+<seconds> (or =-<seconds>) file...
12+
* test-tool chmtime =+<seconds> (or =-<seconds>) file...
1313
*
1414
* Or relative to the current mtime of the file:
1515
*
16-
* test-chmtime <seconds> file...
17-
* test-chmtime +<seconds> (or -<seconds>) file...
16+
* test-tool chmtime <seconds> file...
17+
* test-tool chmtime +<seconds> (or -<seconds>) file...
1818
*
1919
* Examples:
2020
*
2121
* To just print the mtime use --verbose and set the file mtime offset to 0:
2222
*
23-
* test-chmtime -v +0 file
23+
* test-tool chmtime -v +0 file
2424
*
2525
* To set the mtime to current time:
2626
*
27-
* test-chmtime =+0 file
27+
* test-tool chmtime =+0 file
2828
*
2929
*/
30+
#include "test-tool.h"
3031
#include "git-compat-util.h"
3132
#include <utime.h>
3233

@@ -56,7 +57,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
5657
return 1;
5758
}
5859

59-
int cmd_main(int argc, const char **argv)
60+
int cmd__chmtime(int argc, const char **argv)
6061
{
6162
static int verbose;
6263

t/helper/test-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct test_cmd {
77
};
88

99
static struct test_cmd cmds[] = {
10+
{ "chmtime", cmd__chmtime },
1011
};
1112

1213
int cmd_main(int argc, const char **argv)

t/helper/test-tool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#ifndef __TEST_TOOL_H__
22
#define __TEST_TOOL_H__
33

4+
int cmd__chmtime(int argc, const char **argv);
5+
46
#endif

t/lib-git-svn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ rawsvnrepo="$svnrepo"
4949
svnrepo="file://$svnrepo"
5050

5151
poke() {
52-
test-chmtime +1 "$1"
52+
test-tool chmtime +1 "$1"
5353
}
5454

5555
# We need this, because we should pass empty configuration directory to

t/t1700-split-index.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,25 +332,25 @@ test_expect_success 'shared index files expire after 2 weeks by default' '
332332
git update-index --add ten &&
333333
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
334334
just_under_2_weeks_ago=$((5-14*86400)) &&
335-
test-chmtime =$just_under_2_weeks_ago .git/sharedindex.* &&
335+
test-tool chmtime =$just_under_2_weeks_ago .git/sharedindex.* &&
336336
: >eleven &&
337337
git update-index --add eleven &&
338338
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
339339
just_over_2_weeks_ago=$((-1-14*86400)) &&
340-
test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
340+
test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
341341
: >twelve &&
342342
git update-index --add twelve &&
343343
test $(ls .git/sharedindex.* | wc -l) -le 2
344344
'
345345

346346
test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
347347
git config splitIndex.sharedIndexExpire "16.days.ago" &&
348-
test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
348+
test-tool chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
349349
: >thirteen &&
350350
git update-index --add thirteen &&
351351
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
352352
just_over_16_days_ago=$((-1-16*86400)) &&
353-
test-chmtime =$just_over_16_days_ago .git/sharedindex.* &&
353+
test-tool chmtime =$just_over_16_days_ago .git/sharedindex.* &&
354354
: >fourteen &&
355355
git update-index --add fourteen &&
356356
test $(ls .git/sharedindex.* | wc -l) -le 2
@@ -359,13 +359,13 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
359359
test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"' '
360360
git config splitIndex.sharedIndexExpire never &&
361361
just_10_years_ago=$((-365*10*86400)) &&
362-
test-chmtime =$just_10_years_ago .git/sharedindex.* &&
362+
test-tool chmtime =$just_10_years_ago .git/sharedindex.* &&
363363
: >fifteen &&
364364
git update-index --add fifteen &&
365365
test $(ls .git/sharedindex.* | wc -l) -gt 2 &&
366366
git config splitIndex.sharedIndexExpire now &&
367367
just_1_second_ago=-1 &&
368-
test-chmtime =$just_1_second_ago .git/sharedindex.* &&
368+
test-tool chmtime =$just_1_second_ago .git/sharedindex.* &&
369369
: >sixteen &&
370370
git update-index --add sixteen &&
371371
test $(ls .git/sharedindex.* | wc -l) -le 2

t/t2022-checkout-paths.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ test_expect_success 'do not touch files that are already up-to-date' '
6868
git add file1 file2 &&
6969
git commit -m base &&
7070
echo modified >file1 &&
71-
test-chmtime =1000000000 file2 &&
71+
test-tool chmtime =1000000000 file2 &&
7272
git update-index -q --refresh &&
7373
git checkout HEAD -- file1 file2 &&
7474
echo one >expect &&
7575
test_cmp expect file1 &&
7676
echo "1000000000 file2" >expect &&
77-
test-chmtime -v +0 file2 >actual &&
77+
test-tool chmtime -v +0 file2 >actual &&
7878
test_cmp expect actual
7979
'
8080

t/t3306-notes-prune.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success 'setup: create a few commits with notes' '
2222
git commit -m 3rd &&
2323
COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
2424
test -f $COMMIT_FILE &&
25-
test-chmtime =+0 $COMMIT_FILE &&
25+
test-tool chmtime =+0 $COMMIT_FILE &&
2626
git notes add -m "Note #3"
2727
'
2828

t/t3404-rebase-interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,13 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
711711
test_expect_success 'avoid unnecessary reset' '
712712
git checkout master &&
713713
git reset --hard &&
714-
test-chmtime =123456789 file3 &&
714+
test-tool chmtime =123456789 file3 &&
715715
git update-index --refresh &&
716716
HEAD=$(git rev-parse HEAD) &&
717717
set_fake_editor &&
718718
git rebase -i HEAD~4 &&
719719
test $HEAD = $(git rev-parse HEAD) &&
720-
MTIME=$(test-chmtime -v +0 file3 | sed 's/[^0-9].*$//') &&
720+
MTIME=$(test-tool chmtime -v +0 file3 | sed 's/[^0-9].*$//') &&
721721
test 123456789 = $MTIME
722722
'
723723

t/t3418-rebase-continue.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test_expect_success 'interactive rebase --continue works with touched file' '
2424
git checkout master &&
2525
2626
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
27-
test-chmtime =-60 F1 &&
27+
test-tool chmtime =-60 F1 &&
2828
git rebase --continue
2929
'
3030

@@ -36,7 +36,7 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
3636
test_must_fail git rebase --onto master master topic &&
3737
echo "Resolved" >F2 &&
3838
git add F2 &&
39-
test-chmtime =-60 F1 &&
39+
test-tool chmtime =-60 F1 &&
4040
git rebase --continue
4141
'
4242

0 commit comments

Comments
 (0)