patch 8.2.1002: test may fail when run directly

Problem:    Test may fail when run directly.
Solution:   Check if g:run_nr exists. (Christian Brabandt, closes #6285)
diff --git a/src/testdir/term_util.vim b/src/testdir/term_util.vim
index 7c071bb..7a73adb 100644
--- a/src/testdir/term_util.vim
+++ b/src/testdir/term_util.vim
@@ -28,10 +28,12 @@
 " The second argument is the minimum time to wait in msec, 10 if omitted.
 func TermWait(buf, ...)
   let wait_time = a:0 ? a:1 : 10
-  if g:run_nr == 2
-    let wait_time *= 4
-  elseif g:run_nr > 2
-    let wait_time *= 10
+  if exists('g:run_nr')
+    if g:run_nr == 2
+      let wait_time *= 4
+    elseif g:run_nr > 2
+      let wait_time *= 10
+    endif
   endif
   call term_wait(a:buf, wait_time)