home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / SAMPLES / TSTSUITE / DRIVER.FT$ / DRIVER.bin
Encoding:
Text File  |  1992-02-03  |  5.0 KB  |  170 lines

  1. '******************************** DRIVER.FTS  *********************************
  2. 'Demonstrates: A sample FASTTEST test suite driver script - uses File list
  3. '              processing.
  4. '
  5. 'Required Files: FASTTEST.INC
  6. '
  7. 'Uses: FASTTEST.INC
  8. '
  9. 'Complexity Level: INTERMEDIATE
  10. '
  11. 'Notes:  Assumes one or more sub-directories containing test scripts exist.
  12. '        The directory layout for this sample is:
  13. '
  14. '           TSTSUITE            -   DRIVER.FTS, TSTSUITE.FTI, and log file.
  15. '           TSTSUITE\EDIT       -   EDITMENU.FTS, result file.
  16. '           TSTSUITE\FILE       -   FILEMENU.FTS, result file.
  17. '           TSTSUITE\SRCH       -   SRCHMENU.FTS, result file.
  18. '
  19. '       Writes log data to LOG_FILE.  Individual test scripts run from the
  20. '       driver will write detailed results to a result file in their directory.
  21. '******************************************************************************
  22.  
  23. Declare Function GetSubDirs() As Integer
  24. Declare Sub RunScripts(targetDir$)
  25. Declare Sub BackUpLogFile()
  26. Declare Sub PrintLogHeader()
  27. Declare SUb PrintLogFooter()
  28.  
  29. '******************************************************************************
  30. ' CONSTs
  31. '******************************************************************************
  32.  
  33. '  Directory / File constants
  34. Const MAX_DIRS = 3              'Number of sub directories to use
  35. Const PROG_NAME = "TESTDRVR "   'Name of MSTest executable
  36. Const PARENT_DIR = ".."         'Name of the parent directory
  37. Const PARAMS = " /RUN"
  38. Const LOG_FILE = "FTSUITE.LOG"
  39. Const BACKUP_FILE = "FTSUITE.BAK"
  40.  
  41. Global dirNames$(MAX_DIRS)      'Array of sub-directories
  42. Global currentTest$             'Name of currently running script
  43.  
  44.  
  45. '******************************************************************************
  46. ' Main program code
  47. '******************************************************************************
  48.  
  49. '$Include: 'FASTTEST.INC'
  50.  
  51.  
  52. ' Initialize log file
  53. xSetLogOptions LOG_DISK
  54. xSetLogFileName LOG_FILE
  55.  
  56. BackUpLogFile
  57. PrintLogHeader
  58.  
  59. '  Run scripts in each sub-directory
  60. numDirs = GetSubDirs
  61. For i = 0 To numDirs - 1
  62.    currentDir$ = DirNames$(i)
  63.    RunScripts currentDir$
  64. Next
  65.  
  66. '  Close log file
  67. PrintLogFooter
  68. End
  69.  
  70.  
  71. '******************************************************************************
  72. ' SUBs and FUNCTIONs
  73. '******************************************************************************
  74.  
  75.  
  76. '******************************************************************************
  77. 'SUB BackUpLogFile saves the last log file (if it exists).  If
  78. 'a backup log file already exists, it is deleted and replaced
  79. 'with the new backup.
  80. '******************************************************************************
  81. Sub BackUpLogFile Static
  82.  
  83.   IF BFileExists(LOG_FILE) THEN
  84.     IF BFileExists(BACKUP_FILE) THEN
  85.       Kill BACKUP_FILE
  86.     End If
  87.     Name LOG_FILE AS BACKUP_FILE
  88.   END IF
  89.  
  90. End Sub
  91.  
  92.  
  93. '******************************************************************************
  94. 'SUB PrintLogHeader prints a starting banner to the log file
  95. '******************************************************************************
  96. Sub PrintLogHeader () Static
  97.  
  98.   xLogBanner "MSTest FASTTEST Sample log file"
  99.   xLogBanner DateTime$
  100.  
  101. End Sub
  102.  
  103.  
  104. '******************************************************************************
  105. 'SUB PrintLogFooter prints an ending banner to the log file
  106. '******************************************************************************
  107. Sub PrintLogFooter () Static
  108.  
  109.   xLogBanner "FASTTEST Sample test complete"
  110.   xLogBanner DateTime$
  111.  
  112. End Sub
  113.  
  114.  
  115. '******************************************************************************
  116. ' FUNCTION GetSubDirs reads the names of the sub-directories which contain
  117. ' test scripts to be run from the file "testdirs.dat" into the array
  118. ' dirNames$() and returns an integer value which indicates the number of
  119. ' script sub-directories in the array
  120. '******************************************************************************
  121. Function GetSubDirs() Static As Integer
  122.  
  123.     Dim count as integer
  124.  
  125.     Open "testdirs.dat" For Input As #1
  126.  
  127.     While Not Eof(1) And count < MAX_DIRS
  128.       Line Input #1, a$
  129.       a$ = Ucase$(Ltrim$(Rtrim$(a$)))
  130.       If a$ <> "" Then
  131.         dirNames$(count) = Mid$(a$,1,12)
  132.         count = count + 1
  133.       End If
  134.     Wend
  135.  
  136.     Close #1
  137.  
  138.     GetSubDirs = count
  139.  
  140. End Function
  141.  
  142.  
  143. '******************************************************************************
  144. ' SUB RunScripts executes the test script files (those with a .MST
  145. ' extension) in the sub-directory specified by the currentDir$ parameter.
  146. '******************************************************************************
  147. Sub RunScripts (currentDir$) Static
  148.  
  149.     Chdir CurrentDir$
  150.  
  151.     Clearlist
  152.     Setfile "*.fts", On
  153.  
  154.     For currentTest$ In Filelist
  155.  
  156.       '  Log start of new script
  157.       Open PARENT_DIR + "\" + LOG_FILE For Append As #1
  158.       Print #1, "Running script: "; currentTest$
  159.       Close
  160.  
  161.       Run PROG_NAME + currentTest$ + PARAMS
  162.     NEXT
  163.  
  164.     Chdir PARENT_DIR
  165.  
  166. END SUB
  167.  
  168.  
  169.  
  170.