gbtest refactoring

[GB.TEST]
* OPT: Reduce the number of occurences of '__Test.Load(TestModule)' from 4 to 2
This commit is contained in:
Christof Thalhofer 2020-05-26 12:50:39 +02:00
parent b0f6c7d475
commit 9ad850e90b
2 changed files with 16 additions and 15 deletions

View file

@ -19,7 +19,9 @@ Public Sub Main()
' ------------------------------------------------- These must succeed
Tests = asGood.Join(",")
Test.Main(Tests)
'Test.Main(Tests)
'Print Test.AllTests()
' ------------------------------------------------- This must not succeed
'Tests = "TestCrashes"
@ -37,7 +39,7 @@ Public Sub Main()
'Debug TestCommand.ToString(TestRunner.List("~/programming/gambas/gambas/comp/src/gb.test"))
'Tests = "TestInternals.InterpreterInterface"
'Test.Main(Tests)
Test.Main(Tests)
' ------------------------------------------------- Interpreter Interface
' Dim testclass As Class

View file

@ -176,8 +176,7 @@ Private Function RunTests()
If Not $Suite Then
' create as Suite with all tests
$Suite = New TestSuite
For Each sTestModule In GetAllTestModules()
TestModule = __Test.Load(sTestModule)
For Each TestModule In GetAllTestModules()
$Suite.AddAllTestCases(TestModule)
Next
Endif
@ -187,10 +186,10 @@ Private Function RunTests()
End
Private Function GetAllTestModules() As String[]
Private Function GetAllTestModules() As Class[]
Dim TestClass As Class
Dim TestModuleNames As New String[]
Dim TestModules As New Class[]
Dim sNames As New String[]
Dim sName As String
Dim hStat As ClassStat
@ -209,12 +208,10 @@ Private Function GetAllTestModules() As String[]
For Each sName In sNames
TestClass = __Test.Load(sName)
If Not TestClass Then Error.Raise(Subst$(("Could not load test module '&1'"), sName))
If TestModuleNames.Exist(sName) Then Continue
TestModuleNames.Add(sName)
TestModules.Add(TestClass)
Next
TestModuleNames.Sort
Return TestModuleNames
Return TestModules
Catch
Test.BailOut("Error in " & Error.Where & ": " & Error.Text)
@ -226,16 +223,16 @@ End
Public Function AllTestsCollection() As Collection
Dim sModules As String[]
Dim aoTestModules As Class[]
Dim sModule As String
Dim TestModule As Class
Dim cAlltests As New Collection
Dim oTestModule As Class
sModules = GetAllTestModules()
aoTestModules = GetAllTestModules()
For Each sModule In sModules
TestModule = __Test.Load(sModule)
cAlltests.Add(TestSuite.GetTestsFromTestModule(Testmodule), TestModule.Name)
For Each oTestModule In aoTestModules
cAlltests.Add(TestSuite.GetTestsFromTestModule(oTestModule), oTestModule.Name)
Next
Return cAlltests
@ -371,6 +368,8 @@ Private Sub PrintAllTests()
Print aTest.Join();
End
'Fill suite from String
Private Sub FromString(Tests As String)
Dim Commands As TestCommand[]