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

[PATCH v14 16/16] test: run testcases with POSIX absolute paths on Windows

From
Jiang Xin <worldhello.net@gmail.com>
Date
Jun 24, 2013, 15:21 UTC
Message-ID
<7b6237d76d53c240daf4641a00a09af5135fbba7.1372087065.git.worldhello.net@gmail.com>
In-Reply-To
<cover.1372087065.git.worldhello.net@gmail.com>

Add new subcommand "mingw_path" in test-path-utils, so that we can get the expected absolute paths on Windows. For example:

    COMMAND LINE                        Linux  Windows
    ==================================  =====  ===============
    test-path-utils mingw_path /        /      C:/msysgit
    test-path-utils mingw_path /a/b/    /a/b/  C:/msysgit/a/b/

With this utility, most skipped test cases in t0060 can be runcorrectly on Windows.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
---
 t/t0060-path-utils.sh | 73 ++++++++++++++++++++++++++++++++++-----------------
 test-path-utils.c     |  5 ++++
 2 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 4deec..dac84 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -7,14 +7,39 @@ test_description='Test various path utilities'
 
 . ./test-lib.sh
 
+mingw_path() {
+	case $2 in
+	NO_MINGW)
+		echo "$1"
+		;;
+	*)
+		test-path-utils mingw_path "$1"
+		;;
+	esac
+}
+
+get_prereq_flag() {
+	case $1 in
+	POSIX)
+		echo $1
+		;;
+	*)
+		;;
+	esac
+}
+
 norm_path() {
-	test_expect_success $3 "normalize path: $1 => $2" \
-	"test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
+	expected=$(mingw_path "$2" "$3")
+	prereq=$(get_prereq_flag $3)
+	test_expect_success $prereq "normalize path: $1 => $2" \
+	"test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'"
 }
 
 relative_path() {
-	test_expect_success $4 "relative path: $1 $2 => $3" \
-	"test \"\$(test-path-utils relative_path '$1' '$2')\" = '$3'"
+	expected=$(mingw_path "$3" "$4")
+	prereq=$(get_prereq_flag $4)
+	test_expect_success $prereq "relative path: $1 $2 => $3" \
+	"test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'"
 }
 
 # On Windows, we are using MSYS's bash, which mangles the paths.
@@ -39,8 +64,8 @@ ancestor() {
 	 test \"\$actual\" = '$expected'"
 }
 
-# Absolute path tests must be skipped on Windows because due to path mangling
-# the test program never sees a POSIX-style absolute path
+# Some absolute path tests should be skipped on Windows due to path mangling
+# on POSIX-style absolute paths
 case $(uname -s) in
 *MINGW*)
 	;;
@@ -73,10 +98,10 @@ norm_path d1/s1//../s2/../../d2 d2
 norm_path d1/.../d2 d1/.../d2
 norm_path d1/..././../d2 d1/d2
 
-norm_path / / POSIX
-norm_path // / POSIX
-norm_path /// / POSIX
-norm_path /. / POSIX
+norm_path / /
+norm_path // / NO_MINGW
+norm_path /// / NO_MINGW
+norm_path /. /
 norm_path /./ / POSIX
 norm_path /./.. ++failed++ POSIX
 norm_path /../. ++failed++ POSIX
@@ -84,19 +109,19 @@ norm_path /./../.// ++failed++ POSIX
 norm_path /dir/.. / POSIX
 norm_path /dir/sub/../.. / POSIX
 norm_path /dir/sub/../../.. ++failed++ POSIX
-norm_path /dir /dir POSIX
-norm_path /dir// /dir/ POSIX
-norm_path /./dir /dir POSIX
-norm_path /dir/. /dir/ POSIX
-norm_path /dir///./ /dir/ POSIX
-norm_path /dir//sub/.. /dir/ POSIX
-norm_path /dir/sub/../ /dir/ POSIX
+norm_path /dir /dir
+norm_path /dir// /dir/
+norm_path /./dir /dir
+norm_path /dir/. /dir/
+norm_path /dir///./ /dir/
+norm_path /dir//sub/.. /dir/
+norm_path /dir/sub/../ /dir/
 norm_path //dir/sub/../. /dir/ POSIX
-norm_path /dir/s1/../s2/ /dir/s2/ POSIX
-norm_path /d1/s1///s2/..//../s3/ /d1/s3/ POSIX
-norm_path /d1/s1//../s2/../../d2 /d2 POSIX
-norm_path /d1/.../d2 /d1/.../d2 POSIX
-norm_path /d1/..././../d2 /d1/d2 POSIX
+norm_path /dir/s1/../s2/ /dir/s2/
+norm_path /d1/s1///s2/..//../s3/ /d1/s3/
+norm_path /d1/s1//../s2/../../d2 /d2
+norm_path /d1/.../d2 /d1/.../d2
+norm_path /d1/..././../d2 /d1/d2
 
 ancestor / / -1
 ancestor /foo / 0
@@ -197,8 +222,8 @@ relative_path /a	/a/b		../
 relative_path /		/a/b/		../../
 relative_path /a/c	/a/b/		../c
 relative_path /a/c	/a/b		../c
-relative_path /a/b	"<empty>"	/a/b	POSIX
-relative_path /a/b 	"<null>"	/a/b	POSIX
+relative_path /a/b	"<empty>"	/a/b
+relative_path /a/b 	"<null>"	/a/b
 relative_path "<empty>"	/a/b		./
 relative_path "<empty>"	"<empty>"	./
 relative_path "<empty>"	"<null>"	./
diff --git a/test-path-utils.c b/test-path-utils.c
index 95ef4..699ef 100644
--- a/test-path-utils.c
+++ b/test-path-utils.c
@@ -116,6 +116,11 @@ int main(int argc, char **argv)
 		return 0;
 	}
 
+	if (argc == 3 && !strcmp(argv[1], "mingw_path")) {
+		puts(argv[2]);
+		return 0;
+	}
+
 	if (argc == 4 && !strcmp(argv[1], "relative_path")) {
 		struct strbuf sb = STRBUF_INIT;
 		const char *abs, *base, *rel;
-- 
1.8.3.1.756.g41beab0
Previous: Jiang XinNext: Johannes Sixt
Message 31 of 33 in “t0060: skip a few relative_path tests on Windows”
  1. t0060: skip a few relative_path tests on WindowsJohannes Sixt, Jun 13, 2013
  2. Jiang XinJun 13, 2013
  3. 00/16 Interactive git-cleanJiang Xin, Jun 24, 2013
  4. 01/16 test: add test cases for relative_pathJiang Xin, Jun 24, 2013
  5. Junio C HamanoJun 24, 2013
  6. Jiang XinJun 25, 2013
  7. Junio C HamanoJun 25, 2013
  8. Jiang XinJun 25, 2013
  9. 02/16 path.c: refactor relative_path(), not only strip prefixJiang Xin, Jun 24, 2013
  10. 03/16 quote.c: remove path_relative, use relative_path insteadJiang Xin, Jun 24, 2013
  11. Junio C HamanoJun 24, 2013
  12. Jiang XinJun 25, 2013
  13. Junio C HamanoJun 25, 2013
  14. 04/16 Refactor quote_path_relative, remove unused paramsJiang Xin, Jun 24, 2013
  15. Junio C HamanoJun 24, 2013
  16. Jiang XinJun 25, 2013
  17. 05/16 Refactor write_name_quoted_relative, remove unused paramsJiang Xin, Jun 24, 2013
  18. Junio C HamanoJun 24, 2013
  19. Jiang XinJun 25, 2013
  20. 06/16 git-clean: refactor git-clean into two phasesJiang Xin, Jun 24, 2013
  21. Junio C HamanoJun 24, 2013
  22. 07/16 git-clean: add support for -i/--interactiveJiang Xin, Jun 24, 2013
  23. 08/16 git-clean: show items of del_list in columnsJiang Xin, Jun 24, 2013
  24. 09/16 git-clean: add colors to interactive git-cleanJiang Xin, Jun 24, 2013
  25. 10/16 git-clean: use a git-add-interactive compatible UIJiang Xin, Jun 24, 2013
  26. 11/16 git-clean: add filter by pattern interactive actionJiang Xin, Jun 24, 2013
  27. 12/16 git-clean: add select by numbers interactive actionJiang Xin, Jun 24, 2013
  28. 13/16 git-clean: add ask each interactive actionJiang Xin, Jun 24, 2013
  29. 14/16 git-clean: add documentation for interactive git-cleanJiang Xin, Jun 24, 2013
  30. 15/16 test: add t7301 for git-clean--interactiveJiang Xin, Jun 24, 2013
  31. 16/16 test: run testcases with POSIX absolute paths on WindowsJiang Xin, Jun 24, 2013
  32. Johannes SixtJun 24, 2013
  33. Jiang XinJun 25, 2013

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.