home *** CD-ROM | disk | FTP | other *** search
- '******************************** DRIVER.FTS *********************************
- 'Demonstrates: A sample FASTTEST test suite driver script - uses File list
- ' processing.
- '
- 'Required Files: FASTTEST.INC
- '
- 'Uses: FASTTEST.INC
- '
- 'Complexity Level: INTERMEDIATE
- '
- 'Notes: Assumes one or more sub-directories containing test scripts exist.
- ' The directory layout for this sample is:
- '
- ' TSTSUITE - DRIVER.FTS, TSTSUITE.FTI, and log file.
- ' TSTSUITE\EDIT - EDITMENU.FTS, result file.
- ' TSTSUITE\FILE - FILEMENU.FTS, result file.
- ' TSTSUITE\SRCH - SRCHMENU.FTS, result file.
- '
- ' Writes log data to LOG_FILE. Individual test scripts run from the
- ' driver will write detailed results to a result file in their directory.
- '******************************************************************************
-
- Declare Function GetSubDirs() As Integer
- Declare Sub RunScripts(targetDir$)
- Declare Sub BackUpLogFile()
- Declare Sub PrintLogHeader()
- Declare SUb PrintLogFooter()
-
- '******************************************************************************
- ' CONSTs
- '******************************************************************************
-
- ' Directory / File constants
- Const MAX_DIRS = 3 'Number of sub directories to use
- Const PROG_NAME = "TESTDRVR " 'Name of MSTest executable
- Const PARENT_DIR = ".." 'Name of the parent directory
- Const PARAMS = " /RUN"
- Const LOG_FILE = "FTSUITE.LOG"
- Const BACKUP_FILE = "FTSUITE.BAK"
-
- Global dirNames$(MAX_DIRS) 'Array of sub-directories
- Global currentTest$ 'Name of currently running script
-
-
- '******************************************************************************
- ' Main program code
- '******************************************************************************
-
- '$Include: 'FASTTEST.INC'
-
-
- ' Initialize log file
- xSetLogOptions LOG_DISK
- xSetLogFileName LOG_FILE
-
- BackUpLogFile
- PrintLogHeader
-
- ' Run scripts in each sub-directory
- numDirs = GetSubDirs
- For i = 0 To numDirs - 1
- currentDir$ = DirNames$(i)
- RunScripts currentDir$
- Next
-
- ' Close log file
- PrintLogFooter
- End
-
-
- '******************************************************************************
- ' SUBs and FUNCTIONs
- '******************************************************************************
-
-
- '******************************************************************************
- 'SUB BackUpLogFile saves the last log file (if it exists). If
- 'a backup log file already exists, it is deleted and replaced
- 'with the new backup.
- '******************************************************************************
- Sub BackUpLogFile Static
-
- IF BFileExists(LOG_FILE) THEN
- IF BFileExists(BACKUP_FILE) THEN
- Kill BACKUP_FILE
- End If
- Name LOG_FILE AS BACKUP_FILE
- END IF
-
- End Sub
-
-
- '******************************************************************************
- 'SUB PrintLogHeader prints a starting banner to the log file
- '******************************************************************************
- Sub PrintLogHeader () Static
-
- xLogBanner "MSTest FASTTEST Sample log file"
- xLogBanner DateTime$
-
- End Sub
-
-
- '******************************************************************************
- 'SUB PrintLogFooter prints an ending banner to the log file
- '******************************************************************************
- Sub PrintLogFooter () Static
-
- xLogBanner "FASTTEST Sample test complete"
- xLogBanner DateTime$
-
- End Sub
-
-
- '******************************************************************************
- ' FUNCTION GetSubDirs reads the names of the sub-directories which contain
- ' test scripts to be run from the file "testdirs.dat" into the array
- ' dirNames$() and returns an integer value which indicates the number of
- ' script sub-directories in the array
- '******************************************************************************
- Function GetSubDirs() Static As Integer
-
- Dim count as integer
-
- Open "testdirs.dat" For Input As #1
-
- While Not Eof(1) And count < MAX_DIRS
- Line Input #1, a$
- a$ = Ucase$(Ltrim$(Rtrim$(a$)))
- If a$ <> "" Then
- dirNames$(count) = Mid$(a$,1,12)
- count = count + 1
- End If
- Wend
-
- Close #1
-
- GetSubDirs = count
-
- End Function
-
-
- '******************************************************************************
- ' SUB RunScripts executes the test script files (those with a .MST
- ' extension) in the sub-directory specified by the currentDir$ parameter.
- '******************************************************************************
- Sub RunScripts (currentDir$) Static
-
- Chdir CurrentDir$
-
- Clearlist
- Setfile "*.fts", On
-
- For currentTest$ In Filelist
-
- ' Log start of new script
- Open PARENT_DIR + "\" + LOG_FILE For Append As #1
- Print #1, "Running script: "; currentTest$
- Close
-
- Run PROG_NAME + currentTest$ + PARAMS
- NEXT
-
- Chdir PARENT_DIR
-
- END SUB
-
-
-
-