Skip to content

Commit

Permalink
add debugger tests + test fixes
Browse files Browse the repository at this point in the history
#927

Added two very simple debugger tests which open multiple debuggers.

Ensure jadeiteShell is updated in the TestCase instance after the test resource logs in

accelerator changes necessitate test changes

Better (I hope) closing of debuggers in tests. Certainly faster as delay decreased in tearDown code

Replaced some nil tests in the tests with isKindOf: because debugger tests do nasty things to windows to get rid of them.

Don't fail assertion of debugger semaphore in setUp method unless debuggers present

transcript test needed tab to be initialized lazily before test.
  • Loading branch information
Eric Winger authored and Eric Winger committed Oct 4, 2022
1 parent 7d7c130 commit 6fc74ef
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 30 deletions.
3 changes: 2 additions & 1 deletion sources/JadeiteAbstractTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ logoutOtherSession
(UserGlobals at: #otherSession) ifNotNil: [:sess | sess logout]'!

logoutThenLoginAs: theUser forceClose: aBoolean
^JadeiteTestResource current logoutThenLoginAs: theUser forceClose: aBoolean!
JadeiteTestResource current logoutThenLoginAs: theUser forceClose: aBoolean.
jadeiteShell := JadeiteTestResource current jadeiteShell. !

methodListPresenter
^self projectsPresenter methodListPresenter!
Expand Down
3 changes: 1 addition & 2 deletions sources/JadeiteBreakpointBrowserTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ test_additionalAccelerators

self testsIssue: #issue329 withTitle: 'Need accelerator key tests'.
self openBreakpointBrowser.
self assert: (breakpointBrowser additionalAccelerators includes: #(#editSaveMethod 'Ctrl+S')).
self assert: breakpointBrowser additionalAccelerators size equals: 2 "should fail if we add a new one"!
self assert: breakpointBrowser additionalAccelerators size equals: 1 "should fail if we add a new one"!

test_breakpointAdditionsUpdateAutomatically
| treeModel indicators |
Expand Down
4 changes: 4 additions & 0 deletions sources/JadeiteDebugger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ createSchematicWiring
send: #onCharAdded:
to: self search!

debuggerClosed: anObject
debuggerClosed := anObject!

debuggerService
"for test usage"
^debuggerService!
Expand Down Expand Up @@ -734,6 +737,7 @@ copyFrameString!menu handlers!private! !
copyStack!menu handlers!private! !
createComponents!public! !
createSchematicWiring!public! !
debuggerClosed:!accessing!private! !
debuggerService!accessing!private! !
disableBreakpointsWhile:!private! !
displayUncompilableSourceIn:!private! !
Expand Down
56 changes: 47 additions & 9 deletions sources/JadeiteDebuggerDataCuratorTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ JadeiteDebuggerDataCuratorTestCase comment: ''!
!JadeiteDebuggerDataCuratorTestCase methodsFor!

cleanupProcesses
debugger
ifNotNil:
(debugger isKindOf: JadeiteDebugger)
ifTrue:
[debugger debuggerService processes do:
[:processService |
session executeString: '[(Object _objectForOop: ' , processService oop printString
Expand All @@ -28,9 +28,10 @@ closeDebuggers
session removeEventsTriggeredFor: each.

[
[each view destroy.
[self destroy: each.
semaphore signal.
SessionManager inputState prod] on: ProcessTermination
SessionManager inputState prod]
on: ProcessTermination
do:
[:ex |
"A debugger wants to terminate the current process!!!!"
Expand All @@ -47,8 +48,10 @@ closeDebuggers
JadeiteMethodListBrowser allInstances
do: [:browser | self assert: (browser view isKindOf: DeafObject)].
JadeiteBrowser allInstances do: [:browser | self assert: (browser view isKindOf: DeafObject)].
JadeiteDebugger allInstances
do: [:theDebugger | self assert: (theDebugger view isKindOf: DeafObject)].
JadeiteDebugger allInstances do:
[:theDebugger |
(theDebugger view isKindOf: DeafObject) ifFalse: [(Delay forMilliseconds: 50) wait].
self assert: (theDebugger view isKindOf: DeafObject)].
MemoryManager current collectGarbage.
(Delay forMilliseconds: 50) wait.
self purgeInstances: JadeiteBrowser.
Expand Down Expand Up @@ -173,6 +176,12 @@ openDebuggerOn: aString
getDebugger;
yourself!

openSecondDebuggerOn: aString
self
debuggerDo: [process := [session executeString: aString] forkAt: Processor activePriority + 1];
getSecondDebugger;
yourself!

pressButtonIn: view
view
postMessage: 16r204
Expand All @@ -198,7 +207,7 @@ purgeInstances: aClass
[count := count + 1.
MemoryManager current collectGarbage.
SessionManager inputState pumpMessages.
(Delay forMilliseconds: 50) wait.
(Delay forMilliseconds: 1) wait.
aClass allInstances isEmpty ifTrue: [^self]]].
aClass allInstances do:
[:each |
Expand Down Expand Up @@ -301,7 +310,7 @@ tearDown
JadeiteDebugger semaphore: nil.
TestMessageBox disableJadeiteTestMessageBox. "in case the test has gotten stuck while enabled"
self assert: (session isKindOf: GciSession).
super tearDown!
super tearDown.!

terminateGsProcess
| string |
Expand Down Expand Up @@ -363,7 +372,33 @@ test_doubleClickWhenClassNotResolvable

test_globalAdditionalAccelerators
self openDebuggerOn: 'self halt'.
self assert: (self primaryTestWindow additionalAccelerators includes: #(#raiseConsole 'Ctrl+F7'))! !
self assert: (self primaryTestWindow additionalAccelerators includes: #(#raiseConsole 'Ctrl+F7'))!

test_multipleDebuggersBasic
| sourceDocument |
self testsIssue: #issue927 withTitle: '[3.2.9] Concurrent debuggers can hang Jadeite'.
self openDebuggerOn: '''abc'' halt size'.

[sourceDocument := debugger methodSourcePresenter documentPresenter.
sourceDocument value: '123'.
sourceDocument view selectAll.
[debugger methodSourcePresenter jadeDebug] fork.
self getSecondDebugger.
self assert: secondDebugger methodSourcePresenter documentPresenter value equals: 'nil halt. 123']
ensure:
["the not nil tests are to avoid trying to resume if the test was stopped prematurely"
secondDebugger ifNotNil: [self debuggerDo: [secondDebugger resumeProcess]].
debugger ifNotNil: [self debuggerDo: [debugger resumeProcess]]]!

test_multipleDebuggersOpenedIndependently
self testsIssue: #issue927 withTitle: '[3.2.9] Concurrent debuggers can hang Jadeite'.
self openDebuggerOn: '| foo | foo := ''abc''. self halt. foo := foo size'.
self openSecondDebuggerOn: '| foo | foo := ''def''. self halt. foo := foo size'.
2 timesRepeat:
[self debuggerDo: [secondDebugger stepOver].
self debuggerDo: [debugger stepOver]].
self assert: debugger frameListPresenter list notEmpty.
self assert: secondDebugger frameListPresenter list notEmpty! !
!JadeiteDebuggerDataCuratorTestCase categoriesForMethods!
cleanupProcesses!private!support! !
closeDebuggers!private!support! !
Expand All @@ -377,6 +412,7 @@ keyDownEscapeIn:!private!support!tests! !
menuItemIsEnabled:!private!support! !
methodListBrowser!private!support! !
openDebuggerOn:!private!support! !
openSecondDebuggerOn:!private!support! !
pressButtonIn:!private!support!tests! !
primaryTestWindow!accessing!public! !
purgeInstances:!private!support! !
Expand All @@ -392,5 +428,7 @@ terminateGsProcess!private!running!support! !
test_browseMenuOptionEnablement!public!tests! !
test_doubleClickWhenClassNotResolvable!public!tests! !
test_globalAdditionalAccelerators!public!tests! !
test_multipleDebuggersBasic!public!tests! !
test_multipleDebuggersOpenedIndependently!public!tests! !
!

3 changes: 2 additions & 1 deletion sources/JadeiteDebuggerTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ setUp
super setUp.
self closeDebuggers.
JadeiteDebugger debuggerClass: JadeiteDebugger.
JadeiteDebugger allInstances isEmpty ifTrue: [JadeiteDebugger semaphore: nil].
self assertIsNil: JadeiteDebugger semaphore.
self assert: session notNil.
session := GciSession current.
Expand All @@ -59,7 +60,7 @@ setUp
JadeiteLoginShell allInstances size > 1
ifTrue:
["Running tests will not stop on assert. (Debugging tests does) Need to do a hard halt to determine how a test can login as the wrong user"
(Delay forSeconds: 1) wait. "give it a second to cleanup"
(Delay forSeconds: 1) wait. "give it a second to cleanup"
JadeiteLoginShell allInstances size > 1
ifTrue: [self haltTestForHardToCatchErrors: 'Multiple JadeiteLoginShells found']]!

Expand Down
11 changes: 6 additions & 5 deletions sources/JadeiteProjectBrowserDictionaryDataCuratorTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ test_projectListMenuItemsEnabled
query := CommandQuery commandDescription: item source: self projectListPresenter view.
self projectsPresenter queryCommand: query.
(('*Refresh*' match: item text)
or: [('*Load Git Project*' match: item text) or: ['*Create*' match: item text]])
or: [('Load Project*' match: item text) or: [('*Create*' match: item text) or: ['Browse' = item text]]])
ifTrue: [self assert: query isEnabled]
ifFalse: [self deny: query isEnabled]].
self projectListPresenter resetSelection.
Expand All @@ -690,10 +690,11 @@ test_projectListMenuItemsEnabled
| query |
query := CommandQuery commandDescription: item source: self projectListPresenter view.
self projectsPresenter queryCommand: query.
(('*Refresh*' match: item text)
or: [('*Load Git Project*' match: item text) or: ['*Create*' match: item text]])
ifTrue: [self assert: query isEnabled]
ifFalse: [self deny: query isEnabled]]!
(('*Refresh*' match: item text) or:
[('Load Project*' match: item text)
or: [('*Create*' match: item text) or: ['Browse' = item text]]])
ifTrue: [self assert: query isEnabled]
ifFalse: [self deny: query isEnabled]]!

test_projectSingleSelection
self testsIssue: #issue217 withTitle: 'Eliminate Dictionary Browser'.
Expand Down
21 changes: 12 additions & 9 deletions sources/JadeiteProjectBrowserLowerTabsTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1180,15 +1180,18 @@ test_sunitOnlyRunTestMethods
saveMethod: 'nonTestMethod ^123'
in: 'RowanSample1Test'
category: 'deleteMe'.
[self selectMethodsNamed: #(#nonTestMethod #test1).
self projectsPresenter jadeDebug.
self assert: self projectsPresenter isSunitTabSelected.
self assert: self projectsPresenter sunitPresenter methodListPresenter selections size equals: 1.
self assert: self projectsPresenter sunitPresenter methodListPresenter selections first selector equals: #test1.
self assert: self projectsPresenter sunitPresenter textResultPresenter value equals: '1 run, 1 passed, 0 failures, 0 errors'.
] ensure:
[self selectMethodNamed: #nonTestMethod.
self projectsPresenter removeMethods: self classListPresenter selections]!

[self selectMethodsNamed: #(#nonTestMethod #test1).
self projectsPresenter runMethodTests.
self assert: self projectsPresenter isSunitTabSelected.
self assert: self projectsPresenter sunitPresenter methodListPresenter selections size equals: 1.
self assert: self projectsPresenter sunitPresenter methodListPresenter selections first selector
equals: #test1.
self assert: self projectsPresenter sunitPresenter textResultPresenter value
equals: '1 run, 1 passed, 0 failures, 0 errors']
ensure:
[self selectMethodNamed: #nonTestMethod.
self projectsPresenter removeMethods: self classListPresenter selections]!

test_sunitResetTestResultOnClassChange
"reset test results when classes changed"
Expand Down
10 changes: 7 additions & 3 deletions sources/JadeiteTestResource.cls
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ isAvailable
issueCommand: service
^JadePresenter issueCommands: (Array with: service) session: self session!

jadeiteShell
^jadeiteShell!

loadProjectFromFile: fileString projectsHome: projectsHomePath customConditionalAttributes: attributes componentNames: componentNames
| projectService |
projectService := RowanProjectService new.
Expand Down Expand Up @@ -140,7 +143,7 @@ logoutThenLoginAs: userName forceClose: forceClose
jadeiteShell loginWithoutErrorHandling.!

openProjectsBrowser
(projectsBrowser isNil or: [projectsBrowser isOpen not])
((projectsBrowser isKindOf: JadeiteBrowser) not or: [projectsBrowser isOpen not])
ifTrue: [projectsBrowser := self openWindow: [self transcript openJadeiteProjectsBrowser]].
projectsBrowser := projectsBrowser topShell.
^projectsBrowser!
Expand Down Expand Up @@ -216,8 +219,8 @@ switchTransactionModeTo: aSymbol
tearDown
super tearDown.
self logoutThenLoginAs: 'SystemUser' forceClose: false.
projectsBrowser
ifNotNil:
(projectsBrowser isKindOf: JadeiteBrowser)
ifTrue:
[(projectsBrowser currentCard projectListPresenter list
detect: [:service | service name = self sampleProject1Name]
ifNone: [])
Expand Down Expand Up @@ -268,6 +271,7 @@ ensureRowanSampleProjectsLoaded!private!setup teardown! !
hasValidSession!public!testing! !
isAvailable!public!testing! !
issueCommand:!public!setup teardown! !
jadeiteShell!accessing!private! !
loadProjectFromFile:projectsHome:customConditionalAttributes:componentNames:!private!setup teardown! !
loadProjectNamed:!private!setup teardown! !
loginWithRetry:!private!support! !
Expand Down
1 change: 1 addition & 0 deletions sources/JadeiteTranscriptTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ test_displayConfigOptions

| gemFailSafeNscEnumerate configurationPresenter readStream workspace lastLine |
self testsIssue: #issue854 withTitle: 'https://github.com/GemTalk/Jadeite/issues/854'.
(transcript view viewNamed: 'cardContainer') tabs selectionByIndex: 4. "My Session tab needs to be lazily initialized"
configurationPresenter := transcript mySessionPresenter configurationReportPresenter.
gemFailSafeNscEnumerate := configurationPresenter list
detect: [:array | array first = 'GemFailSafeNscEnumerate'].
Expand Down

0 comments on commit 6fc74ef

Please sign in to comment.