diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index badf17e..1c0655d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,19 @@ jobs: steps: - uses: actions/checkout@v2 + - run: mdutil -s / + + - run: sudo mdutil -E / + - name: Install shunit2 run: brew install shunit2 + - name: Wait for spotlight to index our test Xcodes directory + run: ./bin/wait-for-spotlight + + - name: Run mdfind + run: mdfind -onlyin "$PWD/test/applications" "kMDItemCFBundleIdentifier='com.apple.dt.Xcode'" + - name: Run tests run: make test diff --git a/bin/wait-for-spotlight b/bin/wait-for-spotlight new file mode 100755 index 0000000..90bd141 --- /dev/null +++ b/bin/wait-for-spotlight @@ -0,0 +1,19 @@ +#!/bin/sh + +xcodes_path="$PWD/test/applications" + +while true; do + mdimport "$xcodes_path" + mdls "$xcodes_path" + + output="$(mdfind -onlyin "$xcodes_path" "kMDItemCFBundleIdentifier='com.apple.dt.Xcode'")" + + if [ -z "$output" ]; then + echo "mdfind did not find any Xcodes at $xcodes_path" + ls "$xcodes_path" + sleep 1 + else + echo "found '$output'" + break + fi +done diff --git a/share/chxcode/chxcode b/share/chxcode/chxcode index fa127d0..b54d1c2 100644 --- a/share/chxcode/chxcode +++ b/share/chxcode/chxcode @@ -23,9 +23,15 @@ system_xcode_version() { xcode_versions() { system_version=$(system_xcode_version) + versions=() for xcode in ${XCODES[*]}; do version=$(xcode_version "$xcode") + versions+=("$version") + done + + IFS=$'\n' versions=($(sort -n <<<"${versions[*]}")); unset IFS + for version in ${versions[*]}; do if [ "$version" = "$system_version" ]; then echo "* $version" else diff --git a/test/chxcode_test b/test/chxcode_test index 7bd29bb..934aff0 100644 --- a/test/chxcode_test +++ b/test/chxcode_test @@ -3,7 +3,7 @@ . ./test/helper test_exec_with_no_arguments() { - export DEVELOPER_DIR="$search_path/Xcode.app/Contents/Developer" + export DEVELOPER_DIR="$search_path/Xcode.app/Contents/Developer" xcodes=$(chxcode | tr '\n' ' ' | xargs)