* [PATCH 0/1] t: add tests for error conditions with --pathspec-from-file
@ 2019-12-30 15:38 Alexandr Miloslavskiy via GitGitGadget
2019-12-30 15:38 ` [PATCH 1/1] " Alexandr Miloslavskiy via GitGitGadget
0 siblings, 1 reply; 2+ messages in thread
From: Alexandr Miloslavskiy via GitGitGadget @ 2019-12-30 15:38 UTC (permalink / raw
To: git; +Cc: Phillip Wood, Alexandr Miloslavskiy, Junio C Hamano
This patch adds tests for various cases where using `--pathspec-from-file` would result in a git error, such as using incompatible options.
This branch is a follow-up for [1] where part of branch was merged into `master` via [2].
The idea for these tests is from [3] where another error condition was added together with a test.
[1] https://lore.kernel.org/git/pull.490.git.1576161385.gitgitgadget@gmail.com/
[2] https://public-inbox.org/git/pull.445.v4.git.1575381738.gitgitgadget@gmail.com/
[3] https://public-inbox.org/git/4401823b-8039-99b4-2436-ed2f1a571d78@gmail.com/
Alexandr Miloslavskiy (1):
t: add tests for error conditions with --pathspec-from-file
t/t2026-checkout-pathspec-file.sh | 17 +++++++++++++++++
t/t2072-restore-pathspec-file.sh | 18 ++++++++++++++++++
t/t3704-add-pathspec-file.sh | 25 +++++++++++++++++++++++++
t/t7107-reset-pathspec-file.sh | 30 +++++++++++++++++++++---------
t/t7526-commit-pathspec-file.sh | 27 ++++++++++++++++++++++++---
5 files changed, 105 insertions(+), 12 deletions(-)
base-commit: 0a76bd7381ec0dbb7c43776eb6d1ac906bca29e6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-502%2FSyntevoAlex%2F%230207(git)_2a_test_error_conditions-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-502/SyntevoAlex/#0207(git)_2a_test_error_conditions-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/502
--
gitgitgadget
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] t: add tests for error conditions with --pathspec-from-file
2019-12-30 15:38 [PATCH 0/1] t: add tests for error conditions with --pathspec-from-file Alexandr Miloslavskiy via GitGitGadget
@ 2019-12-30 15:38 ` Alexandr Miloslavskiy via GitGitGadget
0 siblings, 0 replies; 2+ messages in thread
From: Alexandr Miloslavskiy via GitGitGadget @ 2019-12-30 15:38 UTC (permalink / raw
To: git
Cc: Phillip Wood, Alexandr Miloslavskiy, Junio C Hamano,
Alexandr Miloslavskiy
From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Also move some old tests into the new tests: it doesn't seem reasonable
to have individual error condition tests.
Old test for `git commit` was corrected, previously it was instructed
to use stdin but wasn't provided with any stdin. While this works at
the moment, it's not exactly perfect.
Old tests for `git reset` were improved to test for a specific error
message.
Suggested-By: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
---
t/t2026-checkout-pathspec-file.sh | 17 +++++++++++++++++
t/t2072-restore-pathspec-file.sh | 18 ++++++++++++++++++
t/t3704-add-pathspec-file.sh | 25 +++++++++++++++++++++++++
t/t7107-reset-pathspec-file.sh | 30 +++++++++++++++++++++---------
t/t7526-commit-pathspec-file.sh | 27 ++++++++++++++++++++++++---
5 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh
index f62fd27440..0926312370 100755
--- a/t/t2026-checkout-pathspec-file.sh
+++ b/t/t2026-checkout-pathspec-file.sh
@@ -136,4 +136,21 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+
+ test_must_fail git checkout --pathspec-from-file=list --detach 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --detach" err &&
+
+ test_must_fail git checkout --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git checkout --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err
+'
+
test_done
diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh
index db58e83735..5c7abbbce3 100755
--- a/t/t2072-restore-pathspec-file.sh
+++ b/t/t2072-restore-pathspec-file.sh
@@ -136,4 +136,22 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&
+ test_i18ngrep -e "you must specify path(s) to restore" err
+'
+
test_done
diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh
index 3cfdb669b7..a1696e1a39 100755
--- a/t/t3704-add-pathspec-file.sh
+++ b/t/t3704-add-pathspec-file.sh
@@ -124,4 +124,29 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git add --pathspec-from-file=list --interactive 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git add --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git add --pathspec-from-file=list --edit 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --edit" err &&
+
+ test_must_fail git add --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git add --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ # This case succeeds, but still prints to stderr
+ git add --pathspec-from-file=empty_list 2>err &&
+ test_i18ngrep -e "Nothing specified, nothing added." err
+'
+
test_done
diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh
index 6b1a731fff..975a9a930a 100755
--- a/t/t7107-reset-pathspec-file.sh
+++ b/t/t7107-reset-pathspec-file.sh
@@ -128,15 +128,6 @@ test_expect_success 'quotes not compatible with --pathspec-file-nul' '
test_must_fail verify_expect
'
-test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' '
- restore_checkpoint &&
-
- git rm fileA.t &&
- echo fileA.t >list &&
- test_must_fail git reset --soft --pathspec-from-file=list &&
- test_must_fail git reset --hard --pathspec-from-file=list
-'
-
test_expect_success 'only touches what was listed' '
restore_checkpoint &&
@@ -152,4 +143,25 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
+test_expect_success 'error conditions' '
+ restore_checkpoint &&
+ echo fileA.t >list &&
+ git rm fileA.t &&
+
+ test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+ test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git reset --pathspec-file-nul 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
+ test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
+
+ test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
+ test_i18ngrep -e "fatal: Cannot do hard reset with paths" err
+'
+
test_done
diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh
index 4b58901ed6..336197449f 100755
--- a/t/t7526-commit-pathspec-file.sh
+++ b/t/t7526-commit-pathspec-file.sh
@@ -127,10 +127,31 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
-test_expect_success '--pathspec-from-file and --all cannot be used together' '
+test_expect_success 'error conditions' '
restore_checkpoint &&
- test_must_fail git commit --pathspec-from-file=- --all -m "Commit" 2>err &&
- test_i18ngrep "[-]-pathspec-from-file with -a does not make sense" err
+ echo fileA.t >list &&
+ >empty_list &&
+
+ test_must_fail git commit --pathspec-from-file=list --interactive -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git commit --pathspec-from-file=list --patch -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err &&
+
+ test_must_fail git commit --pathspec-from-file=list --all -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-from-file with -a does not make sense" err &&
+
+ test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err &&
+ test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+ test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err &&
+ test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+ test_must_fail git commit --pathspec-from-file=empty_list --include -m "Commit" 2>err &&
+ test_i18ngrep -e "No paths with --include/--only does not make sense." err &&
+
+ test_must_fail git commit --pathspec-from-file=empty_list --only -m "Commit" 2>err &&
+ test_i18ngrep -e "No paths with --include/--only does not make sense." err
'
test_done
--
gitgitgadget
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-30 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-30 15:38 [PATCH 0/1] t: add tests for error conditions with --pathspec-from-file Alexandr Miloslavskiy via GitGitGadget
2019-12-30 15:38 ` [PATCH 1/1] " Alexandr Miloslavskiy via GitGitGadget
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).