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

[PATCH 3/3] t/lib-bundle-uri: use local fake bundle URLs

From
Jeff King <peff@peff.net>
Date
Jun 26, 2024, 20:57 UTC
Message-ID
<20240626205745.GC1457138@coredump.intra.peff.net>
In-Reply-To
<20240626205355.GA1009060@coredump.intra.peff.net>

A few of the bundle URI tests point config at a fake bundle; they care only that the client has been configured with _some_ bundle, but it doesn't have to actually contain objects.

For the file:// tests, we use "$BUNDLE_URI_REPO_URI/fake.bdl", a non-existent file inside the actual remote repo. But for git:// and http:// tests, we use "https://example.com/fake.bdl". This works OK in practice, but it means we actually make a request to example.com (which returns a placeholder HTML response). That can be annoying when running the test suite on a spotty network (it doesn't produce a wrong result, since we expect it to fail, but it may introduce delays).

We can reduce our dependency on the outside world by using a local URL. It would work to just do "file://$PWD/fake.bdl" here, since the bundle code does not care about the actual location. But in the long run I suspect we may have more restrictions on which protocols can be passed around as bundle URIs. So instead, let's stick with the file:// repo's pattern and just point to a bogus name based on the remote repo's URL.

For http this makes perfect sense; we'll make a request to the local http server and find that there's nothing there. For git:// it's a little weird, as you wouldn't normally access a bundle file over git:// at all. But it's probably the most reasonable guess we can make for now, and anybody who tightens protocol selection later will know better what's the best path forward.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/lib-bundle-uri-protocol.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/lib-bundle-uri-protocol.sh b/t/lib-bundle-uri-protocol.sh
index a4a1af8d02..de09b6b02e 100644
--- a/t/lib-bundle-uri-protocol.sh
+++ b/t/lib-bundle-uri-protocol.sh
@@ -18,15 +18,15 @@ git)
 	start_git_daemon --export-all --enable=receive-pack
 	BUNDLE_URI_PARENT="$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent"
 	BUNDLE_URI_REPO_URI="$GIT_DAEMON_URL/parent"
-	BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl"
+	BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URI/fake.bdl"
 	test_set_prereq BUNDLE_URI_GIT
 	;;
 http)
 	. "$TEST_DIRECTORY"/lib-httpd.sh
 	start_httpd
 	BUNDLE_URI_PARENT="$HTTPD_DOCUMENT_ROOT_PATH/http_parent"
 	BUNDLE_URI_REPO_URI="$HTTPD_URL/smart/http_parent"
-	BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl"
+	BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URL/fake.bdl"
 	test_set_prereq BUNDLE_URI_HTTP
 	;;
 *)
-- 
2.45.2.1058.g2ff574fec9
Previous: Jeff King
Message 4 of 4 in “reduce test suite dependency on network”
  1. 0/3 reduce test suite dependency on networkJeff King, Jun 26, 2024
  2. 1/3 t5553: use local url for invalid fetchJeff King, Jun 26, 2024
  3. 2/3 t5551: do not confirm that bogus url cannot be usedJeff King, Jun 26, 2024
  4. 3/3 t/lib-bundle-uri: use local fake bundle URLsJeff King, Jun 26, 2024

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.