git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] ls-tree: add unit tests for arguments

From
Joshua Nelson <jyn514@gmail.com>
Date
Jul 3, 2018, 03:58 UTC
Message-ID
<20180703035802.24060-3-jyn514@gmail.com>
In-Reply-To
<20180703035802.24060-1-jyn514@gmail.com>
Signed-off-by: Joshua Nelson <jyn514@gmail.com>
---
 t/t3104-ls-tree-optional-args.sh | 43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 t/t3104-ls-tree-optional-args.sh
diff --git t/t3104-ls-tree-optional-args.sh t/t3104-ls-tree-optional-args.sh
new file mode 100644
index 000000000..5917563a7
--- /dev/null
+++ t/t3104-ls-tree-optional-args.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='ls-tree test (optional args)
+
+This test tries to run git-ls-tree with various combinations of options.'
+
+. ./test-lib.sh
+
+test_expect_success 'initial setup' '
+echo hi > test && cp test test2 && git add test test2 && git commit -m initial'
+
+# cat appends newlines after every file
+test_expect_success 'succeed when given no args' 'git ls-tree'
+
+test_expect_success 'succeed when given only --' 'git ls-tree'
+
+test_expect_success 'add second commit' '
+echo hi > test3 && git add test3 && git commit -m "commit 2"'
+
+test_expect_success 'succeed when given revision' '
+git ls-tree HEAD~1'
+
+test_expect_success 'succeed when given revision and --' '
+git ls-tree HEAD~1 --'
+
+test_expect_success 'succeed when given -- and file' '
+git ls-tree -- test3'
+
+test_expect_success 'do nothing when given bad files' '
+git ls-tree -- bad_files'
+
+test_expect_success 'succeed when given file from past revision' '
+git ls-tree HEAD~1 test'
+
+test_expect_success 'succeed when given only file' 'git ls-tree test'
+
+test_expect_success 'raise error when given bad args' '
+test_must_fail  git ls-tree HEAD HEAD --'
+
+test_expect_success 'raise error when given bad revision' '
+test_must_fail git ls-tree bad_revision --'
+
+test_done
-- 
2.18.GIT
Previous: Eric SunshineNext: Elijah Newren
Message 5 of 21 in “ls-tree: make <tree-ish> optional”
  1. 1/3 ls-tree: make <tree-ish> optionalJoshua Nelson, Jul 3, 2018
  2. 2/3 ls-tree: update usage infoJoshua Nelson, Jul 3, 2018
  3. Elijah NewrenJul 3, 2018
  4. Eric SunshineJul 3, 2018
  5. 3/3 ls-tree: add unit tests for argumentsJoshua Nelson, Jul 3, 2018
  6. Elijah NewrenJul 3, 2018
  7. Eric SunshineJul 3, 2018
  8. Elijah NewrenJul 3, 2018
  9. Junio C HamanoJul 3, 2018
  10. Elijah NewrenJul 3, 2018
  11. Joshua NelsonJul 3, 2018
  12. Junio C HamanoJul 6, 2018
  13. Joshua NelsonJul 6, 2018
  14. Junio C HamanoJul 6, 2018
  15. Eric SunshineJul 3, 2018
  16. Joshua NelsonJul 3, 2018
  17. ls-tree: make <tree-ish> optionalJoshua Nelson, Jul 3, 2018
  18. Joshua NelsonJul 4, 2018
  19. Eric SunshineJul 4, 2018
  20. Eric SunshineJul 4, 2018
  21. Eric SunshineJul 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.