gambas-source-code/comp/src/gb.test/.src/TestSuite/TestCommand.class

104 lines
2.6 KiB
Text
Raw Normal View History

' Gambas class file
''' TestCommand stores the name of a testmodule and testmethods to be executed.
Export
Create Static
'' Name of the testmodule to be called
Public ModuleName As String
'' Name of testmethods in a testmodule to be called. If empty, all will be called.
Public Methods As New String[]
'' Finds the Command for the TestModule with name TestModuleName
Static Public Function _Find(Commands As TestCommand[], TestModuleName As String) As TestCommand
Dim Command As TestCommand
For Each Command In Commands
If Lower(Command.ModuleName) = Lower(TestModuleName) Then
Return Command
Endif
Next
End
'' Parses a string with comma separated tests and creates an array of TestCommands.
2020-04-10 11:15:17 +02:00
Static Public Function ParseCommands(Tests As String) As TestCommand[]
Dim asAll As String[]
Dim sCommand, sModulename, sMethodname As String
Dim Command As TestCommand
Dim Commands As New TestCommand[]
Dim i As Integer
If Tests <> Null Then
'Commands = New TestCommand[]
asAll = Split(Tests, ",", Null, True)
For i = 0 To asAll.Count - 1
asAll[i] = Trim(asAll[i])
Next
asAll.Sort
For Each sCommand In asAll
'just to be sure
sModulename = Null
sMethodname = Null
i = 0
Command = New TestCommand
With Command
If InStr(sCommand, ".") > 0 Then
sModulename = Trim(Left(sCommand, InStr(sCommand, ".") - 1))
sMethodname = Trim(Right(sCommand, Len(sCommand) - InStr(sCommand, ".")))
.ModuleName = sModulename
.Methods.Add(sMethodname)
Else
.ModuleName = Trim(sCommand)
Endif
End With
'If InStr(Command, ".") > 0 Then
If Not Commands.Exist(Command) Then
Commands.Add(Command)
Endif
For Each Commands
If Commands[i].ModuleName = sModulename And If Commands[i].Methods.Count > 0 Then
If Not Commands[i].Methods.Exist(sMethodname) Then
Commands[i].Methods.Add(sMethodname)
Endif
Endif
Inc i
Next
Next
For Each Command In Commands
Command.Methods = Command.Methods.Sort()
Next
Commands = Commands.Sort()
Endif
Return Commands
End
Public Function _compare(TC As TestCommand) As Integer
Dim ret As Integer
ret = Comp(ModuleName, TC.ModuleName, gb.Binary)
Return ret
2020-04-10 11:15:17 +02:00
End