patch 8.0.0933: terminal test tries to start GUI when it's not possible

Problem:    Terminal test tries to start GUI when it's not possible.
Solution:   Check if the GUI can run. (James McCoy, closes #1971)
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index 790b07b..a305c90 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -215,3 +215,7 @@
   endif
   return 1
 endfunc
+
+func CanRunGui()
+  return has('gui') && ($DISPLAY != "" || has('gui_running'))
+endfunc