Skip to content

Commit f3b5b07

Browse files
luked99gitster
authored andcommitted
git-p4: tests: use test-chmtime in place of touch
Using "touch" for P4EDITOR means that the tests can be a bit racy, since git-p4 checks the timestamp has been updated and fails if the timestamp is not updated. Use test-chmtime instead, which is designed for this. Signed-off-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2dade7a commit f3b5b07

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

t/t9803-git-p4-shell-metachars.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_expect_success 'shell metachars in filenames' '
2828
echo f2 >"file with spaces" &&
2929
git add "file with spaces" &&
3030
git commit -m "add files" &&
31-
P4EDITOR=touch git p4 submit
31+
P4EDITOR="test-chmtime +5" git p4 submit
3232
) &&
3333
(
3434
cd "$cli" &&
@@ -47,7 +47,7 @@ test_expect_success 'deleting with shell metachars' '
4747
git rm foo\$bar &&
4848
git rm file\ with\ spaces &&
4949
git commit -m "remove files" &&
50-
P4EDITOR=touch git p4 submit
50+
P4EDITOR="test-chmtime +5" git p4 submit
5151
) &&
5252
(
5353
cd "$cli" &&

t/t9813-git-p4-preserve-users.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ test_expect_success 'preserve users' '
5353
git commit --author "Alice <[email protected]>" -m "a change by alice" file1 &&
5454
git commit --author "Bob <[email protected]>" -m "a change by bob" file2 &&
5555
git config git-p4.skipSubmitEditCheck true &&
56-
P4EDITOR=touch P4USER=alice P4PASSWD=secret git p4 commit --preserve-user &&
56+
P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret &&
57+
export P4EDITOR P4USER P4PASSWD &&
58+
git p4 commit --preserve-user &&
5759
p4_check_commit_author file1 alice &&
5860
p4_check_commit_author file2 bob
5961
)
@@ -69,7 +71,7 @@ test_expect_success 'refuse to preserve users without perms' '
6971
git config git-p4.skipSubmitEditCheck true &&
7072
echo "username-noperms: a change by alice" >>file1 &&
7173
git commit --author "Alice <[email protected]>" -m "perms: a change by alice" file1 &&
72-
P4EDITOR=touch P4USER=bob P4PASSWD=secret &&
74+
P4EDITOR="test-chmtime +5" P4USER=bob P4PASSWD=secret &&
7375
export P4EDITOR P4USER P4PASSWD &&
7476
test_must_fail git p4 commit --preserve-user &&
7577
! git diff --exit-code HEAD..p4/master
@@ -87,7 +89,7 @@ test_expect_success 'preserve user where author is unknown to p4' '
8789
git commit --author "Bob <[email protected]>" -m "preserve: a change by bob" file1 &&
8890
echo "username-unknown: a change by charlie" >>file1 &&
8991
git commit --author "Charlie <[email protected]>" -m "preserve: a change by charlie" file1 &&
90-
P4EDITOR=touch P4USER=alice P4PASSWD=secret &&
92+
P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret &&
9193
export P4EDITOR P4USER P4PASSWD &&
9294
test_must_fail git p4 commit --preserve-user &&
9395
! git diff --exit-code HEAD..p4/master &&

0 commit comments

Comments
 (0)