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

[PATCH 3/3] t7900: make macOS-specific test work on Windows

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Nov 27, 2020, 07:50 UTC
Message-ID
<20201127075054.31174-4-sunshine@sunshineco.com>
In-Reply-To
<20201127075054.31174-1-sunshine@sunshineco.com>

Although `git maintenance start` and `git maintenance stop` necessarily invoke platform-specific scheduling utilities, their related tests have been carefully crafted -- with one minor exception -- to work correctly on any platform, thus improving overall coverage. The exception is that the macOS-specific test fails on Windows due to unportable use of `$(id -u)` and comparison involving the value of $HOME which suffers from the typical shortcoming on that platform in which the same path may be represented two different ways depending upon its source (i.e. as a Windows path `C:/git-sdk-64/usr/src/git/foo` versus as a Unix path `/usr/src/git/foo`). Fix both problems and drop the !MINGW prerequisite from the macOS-specific test, thus allowing the test to run on Windows, as well.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t7900-maintenance.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index ef3aec3253..500eaae4fd 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -408,8 +408,10 @@ test_expect_success 'start preserves existing schedule' '
 	grep "Important information!" cron.txt
 '
 
-test_expect_success !MINGW 'start and stop macOS maintenance' '
-	uid=$(id -u) &&
+test_expect_success 'start and stop macOS maintenance' '
+	uid=$(test-tool getuid) &&
+	# ensure $HOME can be compared against hook arguments on all platforms
+	pfx=$(cd "$HOME" && pwd) &&
 
 	write_script print-args <<-\EOF &&
 	echo $* >>args
@@ -432,7 +434,7 @@ test_expect_success !MINGW 'start and stop macOS maintenance' '
 	rm -f expect &&
 	for frequency in hourly daily weekly
 	do
-		PLIST="$HOME/Library/LaunchAgents/org.git-scm.git.$frequency.plist" &&
+		PLIST="$pfx/Library/LaunchAgents/org.git-scm.git.$frequency.plist" &&
 		test_xmllint "$PLIST" &&
 		grep schedule=$frequency "$PLIST" &&
 		echo "bootout gui/$uid $PLIST" >>expect &&
@@ -446,7 +448,7 @@ test_expect_success !MINGW 'start and stop macOS maintenance' '
 	# stop does not unregister the repo
 	git config --get --global maintenance.repo "$(pwd)" &&
 
-	printf "bootout gui/$uid $HOME/Library/LaunchAgents/org.git-scm.git.%s.plist\n" \
+	printf "bootout gui/$uid $pfx/Library/LaunchAgents/org.git-scm.git.%s.plist\n" \
 		hourly daily weekly >expect &&
 	test_cmp expect args &&
 	ls "$HOME/Library/LaunchAgents" >actual &&
-- 
2.29.2.576.ga3fc446d84
Previous: Eric SunshineNext: Ævar Arnfjörð Bjarmason
Message 4 of 6 in “make macOS `git maintenance` test work on Windows”
  1. 0/3 make macOS `git maintenance` test work on WindowsEric Sunshine, Nov 27, 2020
  2. 1/3 t7900: fix test failures when invoked individually via --runEric Sunshine, Nov 27, 2020
  3. 2/3 test-tool: add `getuid` subcommandEric Sunshine, Nov 27, 2020
  4. 3/3 t7900: make macOS-specific test work on WindowsEric Sunshine, Nov 27, 2020
  5. Ævar Arnfjörð BjarmasonNov 27, 2020
  6. Eric SunshineNov 28, 2020

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.