Skip to content

Commit

Permalink
Merge pull request #217 from macta/publish-test-results
Browse files Browse the repository at this point in the history
Publish test results
  • Loading branch information
macta authored Mar 25, 2019
2 parents 975356d + cad5af6 commit 42f3eeb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
5 changes: 3 additions & 2 deletions dev/src/ExercismTests/ExercismExerciseTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ ExercismExerciseTest >> testSolutionSources [
sources := TestmanyTest exercise solutionSources.

classes := {Testmany. TestOtherClass}.
classNames := classes collect: [ :c | c name, '.st' ].
classNames := (classes collect: [ :c | c name, '.st' ]) copyWithFirst: 'TestResults.txt'.

self assertCollection: sources keys asSet equals: classNames asSet.

(sources at: classNames first) should includeSubstring: '#name : #', classes first name.
(sources at: classNames first) should includeSubstring: 'Tested on:'.
(sources at: classNames second) should includeSubstring: '#name : #', classes first name.
(sources at: classNames last) should includeSubstring: '#name : #', classes last name.
]

Expand Down
6 changes: 5 additions & 1 deletion dev/src/ExercismTools/ClyExercismFetchCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ ClyExercismFetchCommand >> execute [

submission ifNotNil: [
UIManager default inform: 'Success, Happy Coding'.
self browser selectClass: submission exercise testCase ]
submission exercise
ifNil: [
ExDomainError signal: 'Missing exercise meta-data' ]
ifNotNil: [ :exercise |
self browser selectClass: exercise testCase ]]
]
on: ExDomainError do: [ :ex |
self reportError: ex for: (submission ifNotNil: [ :s | s exerciseId ]) ]
Expand Down
11 changes: 9 additions & 2 deletions dev/src/ExercismTools/ExercismExercise.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,19 @@ ExercismExercise >> solutionId [

{ #category : #accessing }
ExercismExercise >> solutionSources [
| sources |
"Answer a Dictionary of filename to source code mappings for the solution that will be saved on Exercism"

| sources testResult resultDictionary |

sources := ExTonelWriter new mappedSnapshot: self exercisePackageTag snapshot.

testResult := [ self testCase suite run] on: Error do: [ TestResult new ].
resultDictionary := OrderedDictionary new
at: 'TestResults.txt' put: testResult exercismSummary;
yourself.

^ (self solutionClasses collect: [ :c | c name ])
inject: Dictionary new
inject: resultDictionary
into: [ :result :c |
result
at: c , '.st' put: (sources at: c);
Expand Down
2 changes: 1 addition & 1 deletion dev/src/ExercismTools/ExercismManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ExercismManager class >> isUserMode [
"Answer true if exercism is loaded in a clean image with no dev tools"

^ ((IceRepository registry collect: [ :repo | repo name ])) asArray
= #('iceberg' 'pharo' 'pharo-exercism')
= #('iceberg' 'pharo' 'pharo-smalltalk')
and: [ (RPackageOrganizer default
packageNamed: 'ExercismDev'
ifAbsent: [ nil ]) isNil ]
Expand Down
2 changes: 1 addition & 1 deletion dev/src/ExercismTools/ExercismTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ExercismTest class >> createExerciseAfter: anotherTestCase [
^ (ExercismExercise for: self)
unlockedBy:
((anotherTestCase notNil and: [ anotherTestCase isObsolete not ])
ifTrue: [ anotherTestCase exercise ]
ifTrue: [ [anotherTestCase exercise] on: SubclassResponsibility do: [ nil ] ]
ifFalse: [ nil ]);
yourself
]
Expand Down
19 changes: 19 additions & 0 deletions dev/src/ExercismTools/TestResult.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Extension { #name : #TestResult }

{ #category : #'*ExercismTools' }
TestResult >> exercismSummary [
^String streamContents: [ :s | s
nextPutAll: 'Tested on: ';
nextPutAll: self timeStamp asLocalStringYMDHM;
crlf;
nextPutAll: self runCount printString;
nextPutAll: ' run, ';
nextPutAll: self expectedPassCount printString;
nextPutAll: ' passes, ';
nextPutAll: self skippedCount printString;
nextPutAll: ' skipped, ';
nextPutAll: self unexpectedFailureCount printString;
nextPutAll: ' failures, ';
nextPutAll: self unexpectedErrorCount printString;
nextPutAll:' errors ' ]
]

0 comments on commit 42f3eeb

Please sign in to comment.