diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index e478cd08625..bed6b44c714 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -45,7 +45,9 @@ test "$TEST_EXPENSIVE" = 1 && test_set_prereq EXPENSIVE test "$TEST_NO_DOCKER" != 1 && type docker && test_set_prereq DOCKER TEST_OS=$(uname -s | tr [a-z] [A-Z]) -test expr "$TEST_OS" : "CYGWIN_NT" >/dev/null && test_set_prereq POSIX + +# Set a prereq as error messages are often different on Windows/Cygwin +expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG if test "$TEST_VERBOSE" = 1; then echo '# TEST_VERBOSE='"$TEST_VERBOSE" diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index 135ebab4999..7bb98f0dd9a 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -19,8 +19,16 @@ test_expect_success "ipfs init fails" ' test_must_fail ipfs init 2> init_fail_out ' -test_expect_success POSIX "ipfs init output looks good" ' - echo "Error: failed to take lock at $IPFS_PATH: permission denied" > init_fail_exp && +# Under Windows/Cygwin the error message is different, +# so we use the STD_ERR_MSG prereq. +if test_have_prereq STD_ERR_MSG; then + init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied" +else + init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified." +fi + +test_expect_success "ipfs init output looks good" ' + echo "$init_err_msg" >init_fail_exp && test_cmp init_fail_exp init_fail_out '