patch 8.1.1581: shared functions for testing are disorganised

Problem:    Shared functions for testing are disorganised.
Solution:   Group finctions in script files. (Ozaki Kiichi, closes #4573)
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index ae023a7..53b7314 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -1,10 +1,12 @@
 " Functions shared by several tests.
 
 " Only load this script once.
-if exists('*WaitFor')
+if exists('*PythonProg')
   finish
 endif
 
+source view_util.vim
+
 " Get the name of the Python executable.
 " Also keeps it in s:python.
 func PythonProg()
@@ -327,31 +329,3 @@
   endif
   return 1
 endfunc
-
-" Get line "lnum" as displayed on the screen.
-" Trailing white space is trimmed.
-func Screenline(lnum)
-  let chars = []
-  for c in range(1, winwidth(0))
-    call add(chars, nr2char(screenchar(a:lnum, c)))
-  endfor
-  let line = join(chars, '')
-  return matchstr(line, '^.\{-}\ze\s*$')
-endfunc
-
-" Stops the shell running in terminal "buf".
-func Stop_shell_in_terminal(buf)
-  call term_sendkeys(a:buf, "exit\r")
-  let job = term_getjob(a:buf)
-  call WaitFor({-> job_status(job) == "dead"})
-endfunc
-
-" Gets the text of a terminal line, using term_scrape()
-func Get_terminal_text(bufnr, row)
-  let list = term_scrape(a:bufnr, a:row)
-  let text = ''
-  for item in list
-    let text .= item.chars
-  endfor
-  return text
-endfunc