From: "Ingo Brückl" <ib@wupperonline.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>
Cc: Johannes Sixt <j6t@kdbg.org>
Cc: Edward Thomson <ethomson@edwardthomson.com>
Subject: [PATCH v2 2/3] Make test t3700-add.sh more robust
Date: Fri, 29 Jul 2016 23:11:36 +0200 [thread overview]
Message-ID: <579bc6ca.3f2601c7.bm001@wupperonline.de> (raw)
Don't rely on chmod to work on the underlying platform (although it
wouldn't harm the result of the '--chmod=-x' test). Directly check the
result of the --chmod option.
Add a test_mode_in_index helper function in order to check for success.
Signed-off-by: Ingo Brückl <ib@wupperonline.de>
---
t/t3700-add.sh | 20 ++++----------------
t/test-lib-functions.sh | 14 ++++++++++++++
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 494f5b8..c08ec9e 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -332,25 +332,13 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
test_i18ncmp expect.err actual.err
'
-test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
+test_expect_success 'git add --chmod=[+-]x stages correctly' '
rm -f foo1 &&
echo foo >foo1 &&
git add --chmod=+x foo1 &&
- case "$(git ls-files --stage foo1)" in
- 100755" "*foo1) echo pass;;
- *) echo fail; git ls-files --stage foo1; (exit 1);;
- esac
-'
-
-test_expect_success 'git add --chmod=-x stages an executable file with -x' '
- rm -f xfoo1 &&
- echo foo >xfoo1 &&
- chmod 755 xfoo1 &&
- git add --chmod=-x xfoo1 &&
- case "$(git ls-files --stage xfoo1)" in
- 100644" "*xfoo1) echo pass;;
- *) echo fail; git ls-files --stage xfoo1; (exit 1);;
- esac
+ test_mode_in_index 100755 foo1 &&
+ git add --chmod=-x foo1 &&
+ test_mode_in_index 100644 foo1
'
test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 4f7eadb..0e6652b 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -990,3 +990,17 @@ test_copy_bytes () {
}
' - "$1"
}
+
+# Test the file mode "$1" of the file "$2" in the index.
+test_mode_in_index () {
+ case "$(git ls-files --stage "$2")" in
+ $1\ *"$2")
+ echo pass
+ ;;
+ *)
+ echo fail
+ git ls-files --stage "$2"
+ return 1
+ ;;
+ esac
+}
--
2.9.2
next reply other threads:[~2016-07-29 21:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 21:11 Ingo Brückl [this message]
2016-07-29 22:03 ` [PATCH v2 2/3] Make test t3700-add.sh more robust Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=579bc6ca.3f2601c7.bm001@wupperonline.de \
--to=ib@wupperonline.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox