quickSelfTest/RunUnitTests.st
author sr
Fri, 29 Sep 2017 14:10:12 +0200
changeset 348 e8c44ab3dbcd
parent 347 041a1411366c
child 349 ae0315df73cb
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
336
aaa1ed543bd0 *** empty log message ***
sr
parents: 330
diff changeset
     1
'From Smalltalk/X, Version:7.1.0.0 on 12-09-2017 at 13:33:27'                   !
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     2
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     4
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     5
"{ NameSpace: Smalltalk }"
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     6
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     7
Object subclass:#RunUnitTests
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     8
	instanceVariableNames:''
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
     9
	classVariableNames:''
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    10
	poolDictionaries:''
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    11
	category:'tests-Regression'
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    12
!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    13
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    14
!RunUnitTests class methodsFor:'documentation'!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    15
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    16
documentation
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    17
"
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    18
    documentation to be added.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    19
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    20
    [author:]
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    21
	sr
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    22
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    23
    [instance variables:]
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    24
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    25
    [class variables:]
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    26
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    27
    [see also:]
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    28
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    29
"
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    30
! !
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    31
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    32
!RunUnitTests class methodsFor:'actions'!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    33
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    34
run
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    35
    |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    36
     cmdArgs
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    37
     unitTestSuite
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    38
     eachClassName eachClass
347
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    39
     result index|
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    40
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    41
    doRunSpecificUnitTests := false.
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    42
    unitTestSuiteName := 'All Unit Tests'.
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    43
    excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    44
    corruptedUnitTestClassNames := self corruptedUnitTestClassNames.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    45
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    46
    cmdArgs := Smalltalk commandLineArguments.
347
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    47
    index := cmdArgs indexOf:'--settingsFile'.
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    48
    index > 0 ifTrue:[
348
e8c44ab3dbcd *** empty log message ***
sr
parents: 347
diff changeset
    49
	(cmdArgs at:index + 1) asFilename fileIn.
347
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    50
    ].
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    51
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    52
    (cmdArgs includes:'--runOnlyExpeccoUnitTests') ifTrue:[
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    53
	self logInfo:'configured to run expecco unit tests only'.
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    54
	doRunSpecificUnitTests := true.
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    55
	unitTestSuiteName := 'expecco Unit Tests'.
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    56
	excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco.
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    57
    ].
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    58
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    59
    doRunSpecificUnitTests ifFalse:[
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    60
	self logInfo:'configured to run all available unit tests'.
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    61
    ].
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    62
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    63
    self logInfo:'collecting unit test classes to run'.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    64
    unitTestSuite := TestSuite named:unitTestSuiteName.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    65
    (Smalltalk at: #'stx_goodies_regression') classNamesAndAttributes do:[:eachClassNameAndAttributes |
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    66
	eachClassNameAndAttributes isSymbol ifTrue:[
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    67
	    eachClassName := eachClassNameAndAttributes.
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    68
	] ifFalse:[
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    69
	    eachClassName := eachClassNameAndAttributes
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    70
		firstIfEmpty:nil.
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    71
	].
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    72
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    73
	(excludedUnitTestClassNames includes:eachClassName) ifFalse:[
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    74
	    (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[
347
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    75
		self
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    76
		    logWarning:('corrupted unit test class detected, please fix #%1'
347
041a1411366c *** empty log message ***
sr
parents: 346
diff changeset
    77
			bindWith:eachClassName).
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    78
	    ] ifFalse:[
348
e8c44ab3dbcd *** empty log message ***
sr
parents: 347
diff changeset
    79
			eachClassName notNil ifTrue:[
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    80
				eachClass := Smalltalk
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    81
					fileInClass:eachClassName
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    82
					package:'stx:goodies/regression'.
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    83
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    84
				eachClass notNil ifTrue:[
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    85
				eachClass isTestCaseLike ifTrue:[
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    86
					unitTestSuite addTest:eachClass suite.
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
    87
				].
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    88
		    ].
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    89
		].
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    90
	    ].
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    91
	].
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    92
    ].
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    93
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    94
    self
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    95
	logInfo:('%1 unit test classes collected'
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
    96
	    bindWith:unitTestSuite tests size).
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    97
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    98
    self logInfo:'starting unit tests'.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
    99
    result := unitTestSuite
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   100
	run:TestResultStX new
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   101
	beforeEachDo:[:test | self logInfo:'performing unit test ', test printString]
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   102
	afterEachDo:[:test| ]
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   103
	debug:(cmdArgs includes:'--debug').
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   104
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   105
    self logInfo:'generating report'.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   106
    TestResultReporter
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   107
	report:result
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   108
	format:#xml_jUnit
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   109
	as:'testresult.xml'.
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   110
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   111
    self logInfo:'summary:'.
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   112
    self logInfo:('%1 tests' bindWith:result runCount).
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   113
    self logInfo:('%1 passed' bindWith:result passedCount).
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   114
    self logInfo:('%1 failed' bindWith:result failureCount).
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   115
    self logInfo:('%1 errors' bindWith:result errorCount).
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   116
! !
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   117
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   118
!RunUnitTests class methodsFor:'constants'!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   119
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   120
corruptedUnitTestClassNames
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   121
    ^ #(
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   122
	#'RegressionTests::ExternalInterfaceTests'
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   123
	#'RegressionTests::HTTPServerTests'
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   124
	#'RegressionTests::DebuggerTest'
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
   125
	#'RegressionTests::ContextTest2'
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   126
    )
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   127
!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   128
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   129
excludedUnitTestClassNamesForAll
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   130
    ^ #()
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   131
!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   132
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   133
excludedUnitTestClassNamesForExpecco
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   134
    ^ self excludedUnitTestClassNamesForAll
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   135
	, #(
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   136
	    #'RegressionTests::BreakpointTests'
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   137
	    #'RegressionTests::SunitXMLOutputTest'
339
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   138
	    #'RegressionTests::CompilerTests2'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   139
	    #'RegressionTests::BehaviorLookupObjectTests'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   140
	    #'RegressionTests::ChangeSetTests'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   141
	    #'RegressionTests::MakefileTests'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   142
	    #'RegressionTests::MetaphoneStringComparatorTest'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   143
	    #'RegressionTests::STCCompilerTests'
91098756a1cf *** empty log message ***
sr
parents: 337
diff changeset
   144
	    #'RegressionTests::VMCrashTests'
340
0aba6d1a9337 *** empty log message ***
sr
parents: 339
diff changeset
   145
	    #'RegressionTests::SnapshotRestartTests'
341
4e6b03506e92 *** empty log message ***
sr
parents: 340
diff changeset
   146
	    #'RegressionTests::GraphicDrawingTest'
342
4419c83530aa *** empty log message ***
sr
parents: 341
diff changeset
   147
	    #'RegressionTests::OS_OLE_Tests'
346
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
   148
		#'RegressionTests::ExternalInterfaceTests'
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
   149
		#'RegressionTests::HTTPServerTests'
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
   150
		#'RegressionTests::DebuggerTest'
e59d3b6f2391 *** empty log message ***
sr
parents: 345
diff changeset
   151
		#'RegressionTests::ContextTest2'
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   152
	)
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   153
! !
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   154
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   155
!RunUnitTests class methodsFor:'logging'!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   156
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   157
log:aString
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   158
    type:aType
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   159
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   160
    Stdout
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   161
	showCR:('%1 [%2] : %3'
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   162
	    bindWith:Timestamp now printString
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   163
	    with:(aType printString asLowercase paddedTo:'warning' size)
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   164
	    with:aString).
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   165
!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   166
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   167
logInfo:aString
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   168
    self
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   169
	log:aString
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   170
	type:'INFO'
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   171
!
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   172
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   173
logWarning:aString
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   174
    self
337
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   175
	log:aString
8dcc6a1f364b *** empty log message ***
sr
parents: 336
diff changeset
   176
	type:'WARNING'
330
6a3fe7cea4e1 *** empty log message ***
sr
parents:
diff changeset
   177
! !