Skip to content

Instantly share code, notes, and snippets.

@tosik
Last active October 1, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosik/10a1e6423e35f549996cf233c423d000 to your computer and use it in GitHub Desktop.
Save tosik/10a1e6423e35f549996cf233c423d000 to your computer and use it in GitHub Desktop.
run googletest filtered by current file name
function! RunTest()
let filter = substitute(expand('%:t'), "_test.cpp", "", "g")
let filter = substitute(l:filter, ".cpp", "", "g")
let filter = system("ruby -e \"print '" . l:filter . "'.split('_').collect(&:capitalize).join\"")
let lower_filter = tolower(l:filter[0]) . l:filter[1 : -1]
let output = system("make build-test && GTEST_FILTER=*" . l:filter . "*:*" . l:lower_filter . "* build/test")
echo "test finished"
cexpr l:output
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment