Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yiyuanlu/3059270 to your computer and use it in GitHub Desktop.
Save yiyuanlu/3059270 to your computer and use it in GitHub Desktop.
Xcode 4.3 and xcodebuild Unit Tests
map ,xt :call RunBuildCommand("export RUN_SIMULATOR_TESTS=YES;xcodebuild -sdk iphonesimulator -configuration Debug -target testprojTests")<CR>
function! RunBuildCommand(cmd)
let l:BuildLog = "build/vim.log"
if bufname("%") != ""
silent write
endif
echo "Building... "
let l:StartTime = reltime()
exec "silent !" . a:cmd . " >" . l:BuildLog . " 2>&1"
" xcodebuild does NOT set exit code properly, so check the build log
exec "silent !grep -q '^\*\* BUILD FAILED' " . l:BuildLog
redraw!
if !v:shell_error
set errorformat=
\%f:%l:%c:{%*[^}]}:\ error:\ %m,
\%f:%l:%c:{%*[^}]}:\ fatal\ error:\ %m,
\%f:%l:%c:{%*[^}]}:\ warning:\ %m,
\%f:%l:%c:\ error:\ %m,
\%f:%l:%c:\ fatal\ error:\ %m,
\%f:%l:%c:\ warning:\ %m,
\%f:%l:\ Error:\ %m,
\%f:%l:\ error:\ %m,
\%f:%l:\ fatal\ error:\ %m,
\%f:%l:\ warning:\ %m
execute "cfile! " . l:BuildLog
else
echo "Building... OK - " . reltimestr(reltime(l:StartTime)) . " seconds"
endif
exec "silent!export RUN_SIMULATOR_TESTS=NO"
endfunction
# /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests
# around line 93
if [ "${TEST_HOST}" != "" ]; then
if [ "${RUN_SIMULATOR_TESTS}" = "YES" ]; then
export OTHER_TEST_FLAGS="-RegisterForSystemEvents"
RunTestsForApplication "${TEST_HOST}" "${TEST_BUNDLE_PATH}"
else
Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
fi
else
# If no TEST_HOST is specified, assume we're running the test bundle.
RunTestsForBundle "${TEST_BUNDLE_PATH}"
fi
if [ "${RUN_SIMULATOR_TESTS}" = "YES" ]; then
echo "overriding TEST_AFTER_BUILD since RUN_SIMULATOR_TESTS is set"
export TEST_AFTER_BUILD=YES
fi
# Run the unit tests in this test bundle.
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment