|
1 | 1 | #! /usr/bin/env bats |
2 | 2 |
|
3 | 3 | load environment |
| 4 | +load "$_GO_CORE_DIR/lib/portability" |
4 | 5 |
|
5 | 6 | # By default, the test will try to clone its own repo to avoid flakiness due to |
6 | 7 | # an external dependency. However, doing so causes a failure on Travis, since it |
@@ -42,9 +43,8 @@ CLONE_DIR= |
42 | 43 | setup() { |
43 | 44 | test_filter |
44 | 45 | export GO_SCRIPT_BASH_{VERSION,REPO_URL,DOWNLOAD_URL} |
45 | | - NATIVE_LOCAL_URL="$(git_for_windows_native_path "$LOCAL_DOWNLOAD_URL")" |
46 | | - CLONE_DIR="$(git_for_windows_native_path "$TEST_GO_SCRIPTS_DIR")" |
47 | | - CLONE_DIR+='/go-script-bash' |
| 46 | + @go.native_file_path_or_url 'NATIVE_LOCAL_URL' "$LOCAL_DOWNLOAD_URL" |
| 47 | + @go.native_file_path_or_url 'CLONE_DIR' "$TEST_GO_SCRIPTS_DIR/go-script-bash" |
48 | 48 | EXPECTED_URL="$FULL_DOWNLOAD_URL" |
49 | 49 |
|
50 | 50 | if [[ -z "$TEST_USE_REAL_URL" ]]; then |
@@ -75,31 +75,6 @@ assert_go_core_unpacked() { |
75 | 75 | restore_bats_shell_options "$result" |
76 | 76 | } |
77 | 77 |
|
78 | | -# Converts a Unix path or 'file://' URL to a Git for Windows native path. |
79 | | -# |
80 | | -# This is useful when passing file paths or URLs to native programs on Git for |
81 | | -# Windows, or validating the output of such programs, to ensure portability. |
82 | | -# The resulting path will contain forward slashes. |
83 | | -# |
84 | | -# Prints both converted and unconverted paths and URLs to standard output. |
85 | | -# |
86 | | -# Arguments: |
87 | | -# path: Path or 'file://' URL to convert |
88 | | -git_for_windows_native_path() { |
89 | | - local path="$1" |
90 | | - local protocol="${path%%://*}" |
91 | | - |
92 | | - if [[ ! "$(git --version)" =~ windows ]] || |
93 | | - [[ "$protocol" != "$path" && "$protocol" != 'file' ]]; then |
94 | | - printf '%s' "$path" |
95 | | - elif [[ "$protocol" == 'file' ]]; then |
96 | | - printf 'file://' |
97 | | - cygpath -m "${path#file://}" |
98 | | - else |
99 | | - cygpath -m "$path" |
100 | | - fi |
101 | | -} |
102 | | - |
103 | 78 | # This mimics the tarball provided by GitHub. |
104 | 79 | # |
105 | 80 | # This could probably become a general-purpose utility one day. |
|
0 commit comments