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

[PATCH v2 6/8] pack-object & index-pack: add test for --threads warning under NO_PTHREADS

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 16, 2017, 22:21 UTC
Message-ID
<20170416222102.2320-7-avarab@gmail.com>
In-Reply-To
<20170416222102.2320-1-avarab@gmail.com>

Add a test for the warning that's emitted when --threads or pack.threads is provided under NO_PTHREADS. This uses the new PTHREADS prerequisite.

The assertion for !GETTEXT_POISON in the latter test is currently redundant, since unlike index-pack the pack-objects warnings aren't i18n'd. However they might be changed to be i18n'd in the future, and there's no harm in future-proofing the test.

There's an existing bug in the implementation of pack-objects which this test currently tests for as-is. Details about the bug & the fix are included in a follow-up change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5300-pack-object.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 43a672c345..6bb6a8981b 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -421,6 +421,40 @@ test_expect_success 'index-pack <pack> works in non-repo' '
 	test_path_is_file foo.idx
 '
 
+test_expect_success !PTHREADS,!GETTEXT_POISON 'index-pack --threads=N or pack.threads=N warns when no pthreads' '
+	test_must_fail git index-pack --threads=2 2>err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 1 warnings &&
+	grep "no threads support, ignoring --threads=2" err &&
+	test_must_fail git -c pack.threads=2 index-pack 2>err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 1 warnings &&
+	grep "no threads support, ignoring pack\.threads" err &&
+	test_must_fail git -c pack.threads=2 index-pack --threads=4 2>err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 2 warnings &&
+	grep "no threads support, ignoring --threads=4" err &&
+	grep "no threads support, ignoring pack\.threads" err
+'
+
+test_expect_success !PTHREADS,!GETTEXT_POISON 'pack-objects --threads=N or pack.threads=N warns when no pthreads' '
+	git pack-objects --threads=2 --stdout --all </dev/null >/dev/null 2>err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 1 warnings &&
+	grep "no threads support, ignoring --threads" err &&
+	git -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&
+	cat err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 2 warnings &&
+	grep "no threads support, ignoring --threads" err &&
+	grep "no threads support, ignoring pack\.threads" err &&
+	git -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&
+	grep ^warning: err >warnings &&
+	test_line_count = 2 warnings &&
+	grep "no threads support, ignoring --threads" err &&
+	grep "no threads support, ignoring pack\.threads" err
+'
+
 #
 # WARNING!
 #
-- 
2.11.0
Previous: Ævar Arnfjörð Bjarmason
Message 9 of 9 in “grep threading cleanup & tests”
  1. 0/8 grep threading cleanup & testsÆvar Arnfjörð Bjarmason, Apr 16, 2017
  2. 1/8 grep: assert that threading is enabled when calling grep_{lock,unlock}Ævar Arnfjörð Bjarmason, Apr 16, 2017
  3. 2/8 grep: add tests for --threads=N and grep.threadsÆvar Arnfjörð Bjarmason, Apr 16, 2017
  4. 3/8 grep: don't redundantly compile throwaway patterns under threadingÆvar Arnfjörð Bjarmason, Apr 16, 2017
  5. 4/8 grep: skip pthreads overhead when using one threadÆvar Arnfjörð Bjarmason, Apr 16, 2017
  6. 5/8 tests: add a PTHREADS prerequisiteÆvar Arnfjörð Bjarmason, Apr 16, 2017
  7. 8/8 grep: given --threads with NO_PTHREADS=YesPlease, warnÆvar Arnfjörð Bjarmason, Apr 16, 2017
  8. 7/8 pack-objects: fix buggy warning about threads under NO_PTHREADS=YesPleaseÆvar Arnfjörð Bjarmason, Apr 16, 2017
  9. 6/8 pack-object & index-pack: add test for --threads warning under NO_PTHREADSÆvar Arnfjörð Bjarmason, Apr 16, 2017

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.